VirtualBox

Changeset 1135 in vbox


Ignore:
Timestamp:
Mar 1, 2007 4:53:51 PM (18 years ago)
Author:
vboxsync
Message:

Main: Win32: Don't show the RunAs dialog during network interface creation/deletion on hosts with no UAC (user account control) installed/enabled.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/HostImpl.cpp

    r815 r1135  
    640640#ifdef __WIN__
    641641
     642/**
     643 * Returns TRUE if the Windows version is 6.0 or greater (i.e. it's Vista and
     644 * later OSes) and it has the UAC (User Account Control) feature enabled.
     645 */
     646static BOOL IsUACEnabled()
     647{
     648    LONG rc = 0;
     649
     650    OSVERSIONINFOEX info;
     651    ZeroMemory (&info, sizeof (OSVERSIONINFOEX));
     652    info.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
     653    rc = GetVersionEx ((OSVERSIONINFO *) &info);
     654    AssertReturn (rc != 0, FALSE);
     655
     656    LogFlowFunc (("dwMajorVersion=%d, dwMinorVersion=%d\n",
     657                  info.dwMajorVersion, info.dwMinorVersion));
     658
     659    /* we are interested only in Vista (and newer versions...). In all
     660     * earlier versions UAC is not present. */
     661    if (info.dwMajorVersion < 6)
     662        return FALSE;
     663
     664    /* the default EnableLUA value is 1 (Enabled) */
     665    DWORD dwEnableLUA = 1;
     666
     667    HKEY hKey;
     668    rc = RegOpenKeyExA (HKEY_LOCAL_MACHINE,
     669                        "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
     670                        0, KEY_QUERY_VALUE, &hKey);
     671
     672    Assert (rc == ERROR_SUCCESS || rc == ERROR_PATH_NOT_FOUND);
     673    if (rc == ERROR_SUCCESS)
     674    {
     675
     676        DWORD cbEnableLUA = sizeof (dwEnableLUA);
     677        rc = RegQueryValueExA (hKey, "EnableLUA", NULL, NULL,
     678                               (LPBYTE) dwEnableLUA, &cbEnableLUA);
     679
     680        RegCloseKey (hKey);
     681
     682        Assert (rc == ERROR_SUCCESS || rc == ERROR_FILE_NOT_FOUND);
     683    }
     684
     685    LogFlowFunc (("rc=%d, dwEnableLUA=%d\n", rc, dwEnableLUA));
     686
     687    return dwEnableLUA == 1;
     688}
     689
    642690struct NetworkInterfaceHelperClientData
    643691{
     
    702750
    703751    rc = mParent->startSVCHelperClient (
    704         true /* aPrivileged */,
     752        IsUACEnabled() == TRUE /* aPrivileged */,
    705753        networkInterfaceHelperClient,
    706754        static_cast <void *> (d.get()),
     
    764812
    765813    rc = mParent->startSVCHelperClient (
    766         true /* aPrivileged */,
     814        IsUACEnabled() == TRUE /* aPrivileged */,
    767815        networkInterfaceHelperClient,
    768816        static_cast <void *> (d.get()),
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