VirtualBox

Ignore:
Timestamp:
Jul 18, 2013 12:00:49 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
87348
Message:

Windows Guest Additions: Support for querying user idle times.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Installer/InstallHelper/VBoxGuestInstallHelper.cpp

    r47212 r47232  
    124124        StringCchPrintf(szErr, sizeof(szErr), "0");
    125125    pushstring(szErr);
     126}
     127
     128/**
     129 * Connects to VBoxTray IPC under the behalf of the user running
     130 * in the current thread context.
     131 *
     132 * @return  IPRT status code.
     133 * @param   phSession               Where to store the IPC session.
     134 */
     135static int vboxConnectToVBoxTray(RTLOCALIPCSESSION hSession)
     136{
     137    int rc = VINF_SUCCESS;
     138
     139    RTUTF16 wszUserName[255];
     140    DWORD cchUserName = sizeof(wszUserName) / sizeof(RTUTF16);
     141    BOOL fRc = GetUserNameW(wszUserName, &cchUserName);
     142    if (!fRc)
     143        rc = RTErrConvertFromWin32(GetLastError());
     144
     145    if (RT_SUCCESS(rc))
     146    {
     147        char *pszUserName;
     148        rc = RTUtf16ToUtf8(wszUserName, &pszUserName);
     149        if (RT_SUCCESS(rc))
     150        {
     151            char szPipeName[255];
     152            if (RTStrPrintf(szPipeName, sizeof(szPipeName), "%s%s",
     153                            VBOXTRAY_IPC_PIPE_PREFIX, pszUserName))
     154            {
     155                rc = RTLocalIpcSessionConnect(&hSession, szPipeName, 0 /* Flags */);
     156            }
     157            else
     158                rc = VERR_NO_MEMORY;
     159
     160            RTStrFree(pszUserName);
     161        }
     162    }
     163
     164    return rc;
    126165}
    127166
     
    437476            {
    438477                RTLOCALIPCSESSION hSession;
    439                 int rc = RTLocalIpcSessionConnect(&hSession, VBOXTRAY_IPC_PIPENAME, 0 /* Flags */);
     478                int rc = vboxConnectToVBoxTray(hSession);
    440479                if (RT_SUCCESS(rc))
    441480                {
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette