GetUserName() fails in ATL COM object
-
Hi All, Does anyone know why I would get a first chance exception occur when I try to get the current Username in a COM object I have? the error message is as follows: First-chance exception in app.exe (SECUR32.DLL): 0xC0000005: Access Violation. The program 'C:\app.exe' has exited with code 0 (0x0). when all I am trying to do is LPTSTR username; DWORD cchBuff = 1024; BOOL result = GetUserName(username, &cchBuff); thanks for your help cheers Bryce
-
Hi All, Does anyone know why I would get a first chance exception occur when I try to get the current Username in a COM object I have? the error message is as follows: First-chance exception in app.exe (SECUR32.DLL): 0xC0000005: Access Violation. The program 'C:\app.exe' has exited with code 0 (0x0). when all I am trying to do is LPTSTR username; DWORD cchBuff = 1024; BOOL result = GetUserName(username, &cchBuff); thanks for your help cheers Bryce
bryces wrote: LPTSTR username; DWORD cchBuff = 1024; BOOL result = GetUserName(username, &cchBuff); Well off the top of my head, Doesn't GetUserName require the buffer to have the memory allocated for the username string? I'd double check on MSDN. Michael Blue canary in the outlet by the light switch Who watches over you Make a little birdhouse in your soul - They Might Be Giants
-
bryces wrote: LPTSTR username; DWORD cchBuff = 1024; BOOL result = GetUserName(username, &cchBuff); Well off the top of my head, Doesn't GetUserName require the buffer to have the memory allocated for the username string? I'd double check on MSDN. Michael Blue canary in the outlet by the light switch Who watches over you Make a little birdhouse in your soul - They Might Be Giants
-
Hi All, Does anyone know why I would get a first chance exception occur when I try to get the current Username in a COM object I have? the error message is as follows: First-chance exception in app.exe (SECUR32.DLL): 0xC0000005: Access Violation. The program 'C:\app.exe' has exited with code 0 (0x0). when all I am trying to do is LPTSTR username; DWORD cchBuff = 1024; BOOL result = GetUserName(username, &cchBuff); thanks for your help cheers Bryce
#define MAX_LEN 255 CString str; char ch[MAX_LEN]; DWORD dwNameSize = MAX_LEN; GetUserName(ch, &dwNameSize); Best Wishes and Happy Holiday's, ez_way