随笔 - 2146  文章 - 97 评论 - 11767 trackbacks - 253

//声明:
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;
posted on 2008-02-07 21:27  万一  阅读(...)  评论(...编辑  收藏