[src/c++/vs2005] 현재 사용중 Windows의 로컬계정 목록들 확인
// NetGroupEnum.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
//
// VC 콘솔 어플리케이션으로 수행했습니다.
#include "stdafx.h"
#define UNICODE
#include <windows.h>
#include <lmaccess.h>
#include <lmapibuf.h>
#include <iostream>
#pragma comment(lib, "Netapi32.lib")
int _tmain(int argc, _TCHAR* argv[])
{
LOCALGROUP_INFO_0 *l_info;
DWORD read;
DWORD total;
NetLocalGroupEnum(NULL,
0,
(unsigned char **)&l_info,
MAX_PREFERRED_LENGTH,
&read,
&total,
NULL);
std::wcout << L"[Local Groups]\n";
int i;
for (i=0; i<read; i++) {
std::wcout << l_info[i].lgrpi0_name << std::endl;
LOCALGROUP_MEMBERS_INFO_1 *members;
DWORD entries, total_entries;
NetLocalGroupGetMembers(NULL,
l_info[i].lgrpi0_name,
1,
reinterpret_cast<BYTE **>(&members),
MAX_PREFERRED_LENGTH,
&entries,
&total_entries,
NULL);
for (int mem_num = 0; mem_num<entries; mem_num++)
std::wcout << L"\t" << members[mem_num].lgrmi1_name << L"\n";
NetApiBufferFree(members);
}
NetApiBufferFree(l_info);
return 0;
}
댓글
댓글 쓰기