Changeset 58306 in vbox for trunk/src/VBox/Additions/WINNT
- Timestamp:
- Oct 18, 2015 11:44:25 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxIPC.cpp
r58305 r58306 31 31 #include <iprt/localipc.h> 32 32 #include <iprt/mem.h> 33 #include <iprt/process.h> 34 33 35 #include <VBoxGuestInternal.h> 34 36 … … 179 181 if (RT_SUCCESS(rc)) 180 182 { 181 RTUTF16 wszUserName[255];182 DWORD cchUserName = sizeof(wszUserName) / sizeof(RTUTF16);183 BOOL fRc = GetUserNameW(wszUserName, &cchUserName);184 if (!fRc)185 rc = RTErrConvertFromWin32(GetLastError());186 183 char szPipeName[512 + sizeof(VBOXTRAY_IPC_PIPE_PREFIX)]; 184 strcpy(szPipeName, VBOXTRAY_IPC_PIPE_PREFIX); 185 rc = RTProcQueryUsername(NIL_RTPROCESS, 186 &szPipeName[sizeof(VBOXTRAY_IPC_PIPE_PREFIX) - 1], 187 sizeof(szPipeName) - sizeof(VBOXTRAY_IPC_PIPE_PREFIX) + 1, 188 NULL /*pcbUser*/); 187 189 if (RT_SUCCESS(rc)) 188 190 { 189 char *pszUserName; 190 rc = RTUtf16ToUtf8(wszUserName, &pszUserName); 191 rc = RTLocalIpcServerCreate(&pCtx->hServer, szPipeName, 0 /*fFlags*/); 191 192 if (RT_SUCCESS(rc)) 192 193 { 193 char szPipeName[255]; 194 if (RTStrPrintf(szPipeName, sizeof(szPipeName), "%s%s", 195 VBOXTRAY_IPC_PIPE_PREFIX, pszUserName)) 196 { 197 rc = RTLocalIpcServerCreate(&pCtx->hServer, szPipeName, 0 /*fFlags*/); 198 if (RT_SUCCESS(rc)) 199 { 200 RTStrFree(pszUserName); 201 202 pCtx->pEnv = pEnv; 203 RTListInit(&pCtx->SessionList); 204 205 *ppInstance = pCtx; 206 207 /* GetLastInputInfo only is available starting at Windows 2000 -- might fail. */ 208 s_pfnGetLastInputInfo = (PFNGETLASTINPUTINFO) 209 RTLdrGetSystemSymbol("User32.dll", "GetLastInputInfo"); 210 211 LogRelFunc(("Local IPC server now running at \"%s\"\n", szPipeName)); 212 return VINF_SUCCESS; 213 } 214 215 } 216 else 217 rc = VERR_NO_MEMORY; 218 219 RTStrFree(pszUserName); 220 } 194 pCtx->pEnv = pEnv; 195 RTListInit(&pCtx->SessionList); 196 197 *ppInstance = pCtx; 198 199 /* GetLastInputInfo only is available starting at Windows 2000 -- might fail. */ 200 s_pfnGetLastInputInfo = (PFNGETLASTINPUTINFO) 201 RTLdrGetSystemSymbol("User32.dll", "GetLastInputInfo"); 202 203 LogRelFunc(("Local IPC server now running at \"%s\"\n", szPipeName)); 204 return VINF_SUCCESS; 205 } 206 221 207 } 222 208
Note:
See TracChangeset
for help on using the changeset viewer.