大家好,又见面了,我是全栈君。
关于函数“GetUserName()”,参见:https://msdn.microsoft.com/en-us/library/windows/desktop/ms724432(v=vs.85).aspx
IDE: Code::Blocks
操作系统:Windows 7 x64
1 #include <windows.h> 2 #include <stdio.h> 3 4 using namespace std; 5 6 int main() 7 { 8 CHAR cUserNameBuffer[256]; 9 DWORD dwUserNameSize = 256; 10 11 /* Retrieves the name of the user associated with the current thread. */ 12 if(GetUserName(cUserNameBuffer, &dwUserNameSize)) { 13 printf("The user name is %s \n", cUserNameBuffer); 14 } 15 else { 16 printf("Get user name failed with error: %lu \n", GetLastError()); 17 } 18 19 return 0; 20 }
转载于:https://www.cnblogs.com/Satu/p/8182948.html
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/107785.html原文链接:https://javaforall.net