~pythonregexp2.7/python/issue2636

« back to all changes in this revision

Viewing changes to PC/bdist_wininst/install.c

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-06-09 14:36:32 UTC
  • mfrom: (39021.1.402 Regexp-2.6)
  • Revision ID: darklord@timehorse.com-20080609143632-wwwkx92u1t5l7yd3
Merged in changes from the latest python source snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2115
2115
{
2116
2116
        HKEY hk;
2117
2117
        char key_name[80];
2118
 
        OSVERSIONINFO winverinfo;
2119
 
        winverinfo.dwOSVersionInfoSize = sizeof(winverinfo);
2120
 
        // If less than XP, then we can't do it (and its not necessary).
2121
 
        if (!GetVersionEx(&winverinfo) || winverinfo.dwMajorVersion < 5)
2122
 
                return FALSE;
2123
2118
        // no Python version info == we can't know yet.
2124
2119
        if (target_version[0] == '\0')
2125
2120
                return FALSE;
2135
2130
        return TRUE;
2136
2131
}
2137
2132
 
 
2133
// Returns TRUE if the platform supports UAC.
 
2134
BOOL PlatformSupportsUAC()
 
2135
{
 
2136
        // Note that win2k does seem to support ShellExecute with 'runas',
 
2137
        // but does *not* support IsUserAnAdmin - so we just pretend things
 
2138
        // only work on XP and later.
 
2139
        BOOL bIsWindowsXPorLater;
 
2140
        OSVERSIONINFO winverinfo;
 
2141
        winverinfo.dwOSVersionInfoSize = sizeof(winverinfo);
 
2142
        if (!GetVersionEx(&winverinfo))
 
2143
                return FALSE; // something bad has gone wrong
 
2144
        bIsWindowsXPorLater = 
 
2145
       ( (winverinfo.dwMajorVersion > 5) ||
 
2146
       ( (winverinfo.dwMajorVersion == 5) && (winverinfo.dwMinorVersion >= 1) ));
 
2147
        return bIsWindowsXPorLater;
 
2148
}
 
2149
 
2138
2150
// Spawn ourself as an elevated application.  On failure, a message is
2139
2151
// displayed to the user - but this app will always terminate, even
2140
2152
// on error.
2190
2202
 
2191
2203
        // See if we need to do the Vista UAC magic.
2192
2204
        if (strcmp(user_access_control, "force")==0) {
2193
 
                if (!MyIsUserAnAdmin()) {
 
2205
                if (PlatformSupportsUAC() && !MyIsUserAnAdmin()) {
2194
2206
                        SpawnUAC();
2195
2207
                        return 0;
2196
2208
                }
2198
2210
        } else if (strcmp(user_access_control, "auto")==0) {
2199
2211
                // Check if it looks like we need UAC control, based
2200
2212
                // on how Python itself was installed.
2201
 
                if (!MyIsUserAnAdmin() && NeedAutoUAC()) {
 
2213
                if (PlatformSupportsUAC() && !MyIsUserAnAdmin() && NeedAutoUAC()) {
2202
2214
                        SpawnUAC();
2203
2215
                        return 0;
2204
2216
                }