//声明: GetUserName( lpBuffer: PChar; {缓冲区} var nSize: DWORD {缓冲区大小} ): BOOL; //举例: var arr: array[0..254] of Char; d: DWORD; begin d := SizeOf(arr); GetUserName(arr, d); ShowMessage(arr); {wy} end; //另一例: var p: PChar; num: DWORD; begin num := 0; GetUserName(nil, num); ShowMessage(IntToStr(num)); GetMem(p, num); GetUserName(p, num); ShowMessage(p); {wy} FreeMem(p); end; //再一例: var p: PChar; num: DWORD; begin num := 0; GetUserName(nil, num); p := StrAlloc(num); if GetUserName(p,num) then ShowMessage(p) {wy} else ShowMessage('无'); StrDispose(p); end;
WinAPI: GetUserName - 获取当前用户名
最新推荐文章于 2020-05-10 22:09:41 发布