VirtualBox

Changeset 47977 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
Aug 21, 2013 4:37:27 PM (11 years ago)
Author:
vboxsync
Message:

VBoxService/VBoxTray: User idle detection: Reset usage status to idle when VBoxTray exits, cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxIPC.cpp

    r47973 r47977  
    5252} VBOXIPCCONTEXT, *PVBOXIPCCONTEXT;
    5353static VBOXIPCCONTEXT gCtx = {0};
     54
     55/** Function pointer for GetLastInputInfo(). */
     56typedef BOOL (WINAPI *PFNGETLASTINPUTINFO)(PLASTINPUTINFO);
    5457
    5558/**
     
    6972    /** The thread handle. */
    7073    RTTHREAD                            hThread;
    71     /** Pointer to GetLastInputInfo() function. */
    72     BOOL (WINAPI * pfnGetLastInputInfo)(PLASTINPUTINFO);
    7374
    7475} VBOXIPCSESSION, *PVBOXIPCSESSION;
     76
     77/** Static pointer to GetLastInputInfo() function. */
     78static PFNGETLASTINPUTINFO s_pfnGetLastInputInfo = NULL;
    7579
    7680int vboxIPCSessionDestroyLocked(PVBOXIPCSESSION pSession);
     
    118122    bool fLastInputAvailable = false;
    119123    VBOXTRAYIPCRES_USERLASTINPUT ipcRes;
    120     if (pSession->pfnGetLastInputInfo)
     124    if (s_pfnGetLastInputInfo)
    121125    {
    122126        /* Note: This only works up to 49.7 days (= 2^32, 32-bit counter)
     
    124128        LASTINPUTINFO lastInput;
    125129        lastInput.cbSize = sizeof(LASTINPUTINFO);
    126         BOOL fRc = pSession->pfnGetLastInputInfo(&lastInput);
     130        BOOL fRc = s_pfnGetLastInputInfo(&lastInput);
    127131        if (fRc)
    128132        {
    129             VBOXTRAYIPCRES_USERLASTINPUT ipcRes;
    130133            ipcRes.uLastInput = (GetTickCount() - lastInput.dwTime) / 1000;
    131134            fLastInputAvailable = true;
     
    196199                        *ppInstance = &gCtx;
    197200                        *pfStartThread = true;
     201
     202                        /* GetLastInputInfo only is available starting at Windows 2000. */
     203                        s_pfnGetLastInputInfo = (PFNGETLASTINPUTINFO)
     204                            RTLdrGetSystemSymbol("User32.dll", "GetLastInputInfo");
    198205
    199206                        LogRelFunc(("Local IPC server now running at \"%s\"\n",
     
    438445            rc = VERR_NO_MEMORY;
    439446
    440         if (RT_SUCCESS(rc))
    441         {
    442             *(void **)&pSession->pfnGetLastInputInfo =
    443                 RTLdrGetSystemSymbol("User32.dll", "GetLastInputInfo");
    444             /* GetLastInputInfo only is available starting at Windows 2000. */
    445         }
    446 
    447447        int rc2 = RTCritSectLeave(&pCtx->CritSect);
    448448        AssertRC(rc2);
     
    457457
    458458    pSession->hThread = NIL_RTTHREAD;
    459     pSession->pfnGetLastInputInfo = NULL;
    460459
    461460    RTLOCALIPCSESSION hSession;
Note: See TracChangeset for help on using the changeset viewer.

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