VirtualBox

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


Ignore:
Timestamp:
Aug 3, 2011 9:22:12 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
73297
Message:

GuestCtrl: Update.

Location:
trunk/src/VBox/Additions/WINNT/VBoxGINA
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxGINA/Helper.cpp

    r36447 r38290  
    1717
    1818#include <windows.h>
     19#ifndef TARGET_NT4
     20# include <Wtsapi32.h>
     21#endif
    1922#include "winwlx.h"
    2023#include "Helper.h"
     
    5962bool isRemoteSession(void)
    6063{
    61     return (0 != GetSystemMetrics(SM_REMOTESESSION)) ? true : false;
     64    bool fIsRemote = false;
     65
     66#if 0
     67#ifndef TARGET_NT4
     68    WTS_SESSION_INFO *pSessionInfo = NULL;
     69    DWORD dwSessions;
     70    if (WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,
     71                             0 /* Reserved */,
     72                             1 /* Version */,
     73                             &pSessionInfo,
     74                             &dwSessions))
     75    {
     76        DWORD dwRemoteSessions = 0;
     77        for (DWORD i = 0; i < dwSessions; i++)
     78        {
     79            switch (pSessionInfo[i].State)
     80            {
     81                case WTSConnected:
     82                case WTSActive:
     83                {
     84                    LPTSTR pBuffer;
     85                    DWORD cbBuffer;
     86                    if (  WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE,
     87                                                     pSessionInfo[i].SessionId,
     88                                                     WTSClientProtocolType,
     89                                                     &pBuffer, &cbBuffer)
     90                        && pBuffer
     91                        && cbBuffer)
     92                    {
     93                        USHORT uProto = (USHORT)(pBuffer);
     94                        /* Only count RDP sessions -- these are the ones we're
     95                         * interested in here. */
     96                        if (uProto == WTS_PROTOCOL_TYPE_RDP)
     97                            dwRemoteSessions++;
     98                        WTSFreeMemory(pBuffer);
     99#ifndef DEBUG
     100                        if (dwRemoteSessions) /* Bail out as soon as possible. */
     101                            break;
     102#endif
     103                    }
     104                    break;
     105                }
     106
     107                default:
     108                    break;
     109            }
     110        }
     111
     112#ifdef DEBUG
     113        Log(("VBoxGINA: %s connections detected\n",
     114             dwRemoteSessions ? "RDP" : "No RDP"));
     115#endif
     116        if (pSessionInfo)
     117            WTSFreeMemory(pSessionInfo);
     118
     119        if (dwSessions)
     120            fIsRemote = true;
     121    }
     122#endif
     123#else
     124    LPTSTR pBuffer;
     125    DWORD cbBuffer;
     126    if (  WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE,
     127                                     WTS_CURRENT_SESSION,
     128                                     WTSClientProtocolType,
     129                                     &pBuffer, &cbBuffer)
     130        && pBuffer
     131        && cbBuffer)
     132    {
     133        USHORT uProto = (USHORT)(pBuffer);
     134        /* Only count RDP sessions -- these are the ones we're
     135         * interested in here. */
     136        fIsRemote = uProto == WTS_PROTOCOL_TYPE_RDP;
     137        WTSFreeMemory(pBuffer);
     138    }
     139    else
     140        Log(("VBoxGINA: Error %ld querying session information\n",
     141             GetLastError()));
     142#endif
     143
     144#ifdef DEBUG
     145    Log(("VBoxGINA: Is remote session: %s\n",
     146         fIsRemote ? "Yes" : "No"));
     147#endif
     148    return fIsRemote;
    62149}
    63150
  • trunk/src/VBox/Additions/WINNT/VBoxGINA/Makefile.kmk

    r28800 r38290  
    3131        $(VBOX_LIB_IPRT_GUEST_R3) \
    3232        $(VBOX_LIB_VBGL_R3)
     33ifndef TARGET_NT4
     34 VBoxGINA_LIBS   += \
     35        WtsApi32.lib
     36endif
    3337
    3438include $(KBUILD_PATH)/subfooter.kmk
  • trunk/src/VBox/Additions/WINNT/VBoxGINA/VBoxGINA.cpp

    r37638 r38290  
    107107    HINSTANCE hDll;
    108108
    109 #ifdef DEBUG
    110     /* enable full log output */
    111     RTLogGroupSettings(RTLogDefaultInstance(), "all=~0");
     109#ifdef DEBUG_andy
     110    /* Enable full log output. */
     111    RTLogGroupSettings(RTLogRelDefaultInstance(), "+default.e.l.f.l2.l3");
    112112#endif
    113113
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