有些时候需要获取到当前系统登录的用户名
#include <iostream>
#include <windows.h>
#pragma comment(lib,"Advapi32.lib")
using namespace std;
int main()
{
char strBuffer[256] = { 0 };
DWORD dwSize = 256;
GetUserName(strBuffer, &dwSize);
cout << "当前用户名:" << strBuffer << endl;
while (1);
return 0;
}
好了,成功了
发表评论: