zoukankan      html  css  js  c++  java
  • 获得所有系统账号

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]   public struct USER_INFO_0   {    public string Username;   }   [DllImport("Netapi32.dll ")]   extern static int NetUserEnum(     [MarshalAs(UnmanagedType.LPWStr)]           string servername,     int level,     int filter,     out   IntPtr bufptr,     int prefmaxlen,     out   int entriesread,     out   int totalentries,     out   int resume_handle);

      [DllImport("Netapi32.dll ")]   extern static int NetApiBufferFree(IntPtr Buffer);   public static List<string> GetSysUserNames()   {    int EntriesRead;    int TotalEntries;    int Resume;    IntPtr bufPtr;    List<string> temp = new List<string>();

       NetUserEnum(null, 0, 2, out   bufPtr, -1, out   EntriesRead,      out   TotalEntries, out   Resume);    if (EntriesRead > 0)    {     USER_INFO_0[] Users = new USER_INFO_0[EntriesRead];     IntPtr iter = bufPtr;     for (int i = 0; i < EntriesRead; i++)     {      Users[i] = (USER_INFO_0)Marshal.PtrToStructure(iter,        typeof(USER_INFO_0));      iter = (IntPtr)((int)iter + Marshal.SizeOf(typeof(USER_INFO_0)));      temp.Add(Users[i].Username);     }     NetApiBufferFree(bufPtr);    }    return temp;   }

  • 相关阅读:
    ubuntu 下安装Angular2-cli脚手架
    git的使用及常用命令(二)
    framework7+node+mongo项目
    LINUX下安装搭建nodejs及创建nodejs-express-mongoose项目
    初学strurs基础
    JAVA Struts2 搭建
    mongodb的基本操作
    LightOj_1342 Aladdin and the Magical Sticks
    Codeforces Round #Pi (Div. 2)
    Codeforces Round #315 (Div. 2)
  • 原文地址:https://www.cnblogs.com/ctriphire/p/2790177.html
Copyright © 2011-2022 走看看