Код (C++): #include <windows.h> #include <lm.h> #include <iostream> #pragma comment(lib, "netapi32.lib") const char* LPWSTR_to_const_char(LPCWSTR lpwstr) { int len = WideCharToMultiByte(CP_ACP, 0, lpwstr, -1, NULL, 0, NULL, NULL); char* buf = new char[len]; WideCharToMultiByte(CP_ACP, 0, lpwstr, -1, buf, len, NULL, NULL); return buf; } int main() { DWORD dwLevel = 1; LPUSER_INFO_1 pBuf = NULL; DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH; DWORD dwEntriesRead = 0; DWORD dwTotalEntries = 0; DWORD dwResumeHandle = 0; // Получение списка пользователей NET_API_STATUS nStatus = NetUserEnum( NULL, // имя сервера (NULL = локальный компьютер) dwLevel, FILTER_NORMAL_ACCOUNT, // фильтр по типу учетных записей (LPBYTE*)&pBuf, dwPrefMaxLen, &dwEntriesRead, &dwTotalEntries, &dwResumeHandle ); if (nStatus == NERR_Success) { // Вывод списка пользователей std::cout << "Users:" << std::endl; for (DWORD i = 0; i < dwEntriesRead; i++) { std::cout << LPWSTR_to_const_char(pBuf[i].usri1_name) << std::endl; } } else { std::cout << "Error: " << nStatus << std::endl; } // Освобождение памяти if (pBuf != NULL) { NetApiBufferFree(pBuf); } return 0; }