博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
枚举NT系统用户
阅读量:7021 次
发布时间:2019-06-28

本文共 1282 字,大约阅读时间需要 4 分钟。

#define UNICODE

#include <windows.h>
#include <stdio.h>
#include <lm.h>

void main( int argc, char *argv[ ] )

{
   PNET_DISPLAY_USER pBuff, p;
   DWORD res, dwRec, i = 0;
   //
   // You can pass a NULL or empty string
   //  to retrieve the local information.
   //
   TCHAR szServer[255]=TEXT("");

   if(argc > 1)

      //
      // Check to see if a server name was passed;
      //  if so, convert it to Unicode.
      //
      MultiByteToWideChar(CP_ACP, 0, argv[1], -1, szServer, 255);

   do // begin do

   {
      //
      // Call the NetQueryDisplayInformation function;
      //   specify information level 1 (user account information).
      //
      res = NetQueryDisplayInformation(szServer, 1, i, 1000, MAX_PREFERRED_LENGTH, &dwRec, (void**)&pBuff);
      //
      // If the call succeeds,
      //
      if((res==ERROR_SUCCESS) || (res==ERROR_MORE_DATA))
      {
         p = pBuff;
         for(;dwRec>0;dwRec--)
         {
            //
            // Print the retrieved group information.
            //
            printf("Name:      %S\n"
                  "Comment:   %S\n"
                  "Group ID:  %u\n"
                  "Attributes: %u\n"
                  "--------------------------------\n",
                  p->usri1_name,
                  p->usri1_comment,
                  p->usri1_user_id,
                  p->usri1_flags);
            //
            // If there is more data, set the index.
            //
            i = p->usri1_next_index;
            p++;
         }
         //
         // Free the allocated memory.
         //
         NetApiBufferFree(pBuff);
      }
      else
         printf("Error: %u\n", res);
   //
   // Continue while there is more data.
   //
   } while (res==ERROR_MORE_DATA); // end do
   return;
}

转载地址:http://ihbxl.baihongyu.com/

你可能感兴趣的文章
shell脚本中的逻辑判断,文件目录属性判断, if特殊用法,case判断
查看>>
【JavaWeb】权限管理系统
查看>>
火币网程显峰:区块链技术风险到底是些什么鬼?
查看>>
已知bug列表——Solidity中文文档(12)
查看>>
Java面向对象(二)
查看>>
Mybatis——构造方法
查看>>
Amino——范围层
查看>>
使用 QuickBI 搭建酷炫可视化分析
查看>>
SpringCloud 微服务 (六) 服务通信 RestTemplate
查看>>
PageOfficeV4.0 隐藏Excel的行号列标
查看>>
从MySQL到HBase:数据存储方案转型的演进
查看>>
Qt5开发及实例学习之不规则窗体:没看懂
查看>>
为什么不推荐用JWT保护你的Web应用
查看>>
带你了解MySQL数据库小技巧
查看>>
Java代码自动部署
查看>>
cmake 自动add_subdirectory
查看>>
凑个热闹,分析下Padavan的代码,一
查看>>
RabbitMQ 高可用之镜像队列
查看>>
你真的懂redis的数据结构了吗?
查看>>
人工智能的下一步是什么?我们应如何定义生命?
查看>>