有沒有哪位仁兄知道用什麼函數可以取得windows當前帳戶的登錄名.等急用!!!!!

解决方案 »

  1.   

    The GetUserName function retrieves the user name of the current thread. This is the name of the user currently logged onto the system. BOOL GetUserName(    LPTSTR lpBuffer, // address of name buffer 
        LPDWORD nSize  // address of size of name buffer 
       );
     ParameterslpBufferPoints to the buffer to receive the null-terminated string containing the user's logon name. If this buffer is not large enough to contain the entire user name, the function fails. nSizePointer to a DWORD that, on input, specifies the maximum size, in characters, of the buffer specified by the lpBuffer parameter. If this buffer is not large enough to contain the entire user name, the function fails. If the function succeeds, it will place the number of characters copied to the buffer into the DWORD that nSize points to.  Return ValuesIf the function succeeds, the return value is nonzero, and the variable pointed to by nSize contains the number of characters copied to the buffer specified by lpBuffer, including the terminating null character.