Skip to content

Commit e87d36e

Browse files
authored
Remove considerations for Windows 2000 and Windows Vista (#2667)
1 parent 1407001 commit e87d36e

32 files changed

+86
-339
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Coming in build 312, as yet unreleased
2222
* Implement multidimensional SAFEARRAY(COM Record) and SAFEARRAY(double) (mhammond#2655, [@geppi][geppi])
2323
* Added many missing license and copyright notice files (mhammond#2590, [@Avasam][Avasam])
2424
* Fixed missing version stamp on built `.dll` and `.exe` files (mhammond#2647, [@Avasam][Avasam])
25+
* Removed considerations for Windows 2000 and Windows Vista (mhammond#2667, [@Avasam][Avasam])
26+
* This mostly updates obsolete documentation and tests
2527
* Removed considerations for Windows 95/98/ME (mhammond#2400, [@Avasam][Avasam])
2628
This removes the following constants:
2729
* `win32con.FILE_ATTRIBUTE_ATOMIC_WRITE`

com/help/active_directory.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,11 @@ <h2><a name="getobj">Getting Active Directory Objects</a></h2>
8383

8484
<h3><a name="discovery">Discovery</a></h3>
8585
<p>
86-
A tool that can be of a great help is ADSIedit which is in the Windows
87-
2000 support tools on the Windows 2000 server cdrom. It gives you the
88-
raw ldap view of active directory.</p>
86+
A tool that can be of a great help is the ADSI Edit MMC snap-in, aka <b>ADSIEdit.msc</b>. See
87+
<a href="https://www.microsoft.com/en-us/download/details.aspx?id=45520"
88+
>Remote Server Administration Tools for Windows 10</a> for installation instructions.
89+
It gives you the raw ldap view of active directory.
90+
Note that it is not available for the Home edition of Windows.</p>
8991
<code>
9092
def discover():
9193
Here is a function that helps you determine the active directory ldap strings that you can actually use.

com/win32com/server/register.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import os
1111
import sys
12+
import tempfile
1213

1314
import pythoncom
1415
import win32api
@@ -541,8 +542,6 @@ def UnregisterInfoClasses(*classes, **flags):
541542

542543
# Attempt to 're-execute' our current process with elevation.
543544
def ReExecuteElevated(flags):
544-
import tempfile
545-
546545
import win32console
547546
import win32event # we've already checked we are running XP above
548547
import win32process
@@ -646,14 +645,9 @@ def UseCommandLine(*classes, **flags):
646645
else:
647646
RegisterClasses(*classes, **flags)
648647
except win32api.error as exc:
649-
# If we are on xp+ and have "access denied", retry using
650-
# ShellExecuteEx with 'runas' verb to force elevation (vista) and/or
651-
# admin login dialog (vista/xp)
652-
if (
653-
flags["unattended"]
654-
or exc.winerror != winerror.ERROR_ACCESS_DENIED
655-
or sys.getwindowsversion()[0] < 5
656-
):
648+
# If we have "access denied", retry using
649+
# ShellExecuteEx with 'runas' verb to force elevation
650+
if flags["unattended"] or exc.winerror != winerror.ERROR_ACCESS_DENIED:
657651
raise
658652
ReExecuteElevated(flags)
659653

com/win32com/src/PythonCOM.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ extern LONG _PyCom_GetGatewayCount(void);
9292
typedef HRESULT(STDAPICALLTYPE *CreateURLMonikerExfunc)(LPMONIKER, LPCWSTR, LPMONIKER *, DWORD);
9393
static CreateURLMonikerExfunc pfnCreateURLMonikerEx = NULL;
9494

95-
// Win2k or later
9695
typedef HRESULT(STDAPICALLTYPE *CoWaitForMultipleHandlesfunc)(DWORD dwFlags, DWORD dwTimeout, ULONG cHandles,
9796
LPHANDLE pHandles, LPDWORD lpdwindex);
9897
static CoWaitForMultipleHandlesfunc pfnCoWaitForMultipleHandles = NULL;
@@ -104,7 +103,6 @@ typedef HRESULT(STDAPICALLTYPE *CoSetCancelObjectfunc)(IUnknown *);
104103
static CoSetCancelObjectfunc pfnCoSetCancelObject = NULL;
105104

106105
// typedefs for the function pointers are in OleAcc.h
107-
// WinXP or later
108106
LPFNOBJECTFROMLRESULT pfnObjectFromLresult = NULL;
109107

110108
typedef HRESULT(STDAPICALLTYPE *CoCreateInstanceExfunc)(REFCLSID, IUnknown *, DWORD, COSERVERINFO *, ULONG, MULTI_QI *);

com/win32comext/propsys/src/propsys.cpp

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// $Id$
33

44
// Implements wrappers for the Property System functions and interfaces.
5-
// These interfaces are present on Windows Vista and later, but can also
6-
// be installed on XP with Desktop Search 3.
7-
// However, this module doeen't dynamically load any libraries or functions,
8-
// so it will fail to import if the components are not installed.
95

106
// This source file contains autoduck documentation.
117
// @doc
@@ -38,13 +34,6 @@
3834
#include "propvarutil.h"
3935
#include "Shobjidl.h"
4036

41-
#define CHECK_PFN(fname) \
42-
if (pfn##fname == NULL) \
43-
return PyErr_Format(PyExc_NotImplementedError, "%s is not available on this platform", #fname);
44-
// Not available on Vista or earlier
45-
typedef HRESULT(WINAPI *PFNSHGetPropertyStoreForWindow)(HWND, REFIID, void **);
46-
static PFNSHGetPropertyStoreForWindow pfnSHGetPropertyStoreForWindow = NULL;
47-
4837
// @object PyPROPERTYKEY|A tuple of a fmtid and property id (IID, int) that uniquely identifies a property
4938
BOOL PyWinObject_AsPROPERTYKEY(PyObject *obkey, PROPERTYKEY *pkey)
5039
{
@@ -390,12 +379,10 @@ static PyObject *PyPSLookupPropertyHandlerCLSID(PyObject *self, PyObject *args)
390379
};
391380

392381
// @pymethod <o PyIPropertyStore>|propsys|SHGetPropertyStoreForWindow|Retrieves a collection of a window's properties
393-
// @comm Requires Windows 7 or later.
394382
// @rdesc The returned store can be used to set the System.AppUserModel.ID property that determines how windows
395383
// are grouped on the taskbar
396384
static PyObject *PySHGetPropertyStoreForWindow(PyObject *self, PyObject *args)
397385
{
398-
CHECK_PFN(SHGetPropertyStoreForWindow);
399386
HWND hwnd;
400387
IID riid = IID_IPropertyStore;
401388
void *ret;
@@ -407,7 +394,7 @@ static PyObject *PySHGetPropertyStoreForWindow(PyObject *self, PyObject *args)
407394

408395
HRESULT hr;
409396
PY_INTERFACE_PRECALL;
410-
hr = (*pfnSHGetPropertyStoreForWindow)(hwnd, riid, &ret);
397+
hr = SHGetPropertyStoreForWindow(hwnd, riid, &ret);
411398
PY_INTERFACE_POSTCALL;
412399
if (FAILED(hr))
413400
return PyCom_BuildPyException(hr);
@@ -546,7 +533,7 @@ static PyObject *PySHSetDefaultProperties(PyObject *self, PyObject *args)
546533
}
547534

548535
/* List of module functions */
549-
// @module propsys|A module, encapsulating the Vista Property System interfaces
536+
// @module propsys|A module, encapsulating the Property System interfaces
550537
static struct PyMethodDef propsys_methods[] = {
551538
// { "SHGetPropertyStoreFromIDList", PySHGetPropertyStoreFromIDList, 1 }, // @pymeth
552539
// SHGetPropertyStoreFromIDList|Retrieves the property store from an absolute ID list
@@ -618,10 +605,7 @@ static const PyCom_InterfaceSupportInfo g_interfaceSupportData[] = {
618605
/* Module initialisation */
619606
PYWIN_MODULE_INIT_FUNC(propsys)
620607
{
621-
PYWIN_MODULE_INIT_PREPARE(propsys, propsys_methods,
622-
"A module, encapsulating the Property System interfaces."
623-
"Available on Windows Vista and later, but can also be used"
624-
"on XP if Desktop Search 3 is installed.");
608+
PYWIN_MODULE_INIT_PREPARE(propsys, propsys_methods, "A module, encapsulating the Property System interfaces.");
625609

626610
if (PyDict_SetItemString(dict, "error", PyWinExc_COMError) == -1)
627611
PYWIN_MODULE_INIT_RETURN_ERROR;
@@ -636,10 +620,5 @@ PYWIN_MODULE_INIT_FUNC(propsys)
636620
sizeof(g_interfaceSupportData) / sizeof(PyCom_InterfaceSupportInfo)) != 0)
637621
PYWIN_MODULE_INIT_RETURN_ERROR;
638622

639-
HMODULE hmod = GetModuleHandle(L"shell32.dll");
640-
if (hmod)
641-
pfnSHGetPropertyStoreForWindow =
642-
(PFNSHGetPropertyStoreForWindow)GetProcAddress(hmod, "SHGetPropertyStoreForWindow");
643-
644623
PYWIN_MODULE_INIT_RETURN_SUCCESS;
645624
}

com/win32comext/shell/demos/explorer_browser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# A sample of using Vista's IExplorerBrowser interfaces...
1+
# A sample of using IExplorerBrowser interfaces...
22
# Currently doesn't quite work:
33
# * CPU sits at 100% while running.
44

com/win32comext/shell/demos/servers/context_menu.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,11 @@ def InvokeCommand(self, ci):
7878
mask, hwnd, verb, params, dir, nShow, hotkey, hicon = ci
7979
win32gui.MessageBox(hwnd, "Hello", "Wow", win32con.MB_OK)
8080

81-
def GetCommandString(self, cmd, typ):
81+
def GetCommandString(self, cmd: int, typ):
8282
# If GetCommandString returns the same string for all items then
83-
# the shell seems to ignore all but one. This is even true in
84-
# Win7 etc where there is no status bar (and hence this string seems
85-
# ignored)
86-
return "Hello from Python (cmd=%d)!!" % (cmd,)
83+
# the shell seems to ignore all but one. This is even true if the
84+
# status bar is turned off (and hence this string seems ignored).
85+
return f"Hello from Python ({cmd=})!!"
8786

8887

8988
def DllRegisterServer():

com/win32comext/shell/demos/servers/folder_view.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
import os
99
import pickle
1010
import random
11-
import sys
11+
import struct
12+
import winreg
1213

1314
import commctrl
1415
import pythoncom
@@ -796,12 +797,6 @@ def get_schema_fname():
796797

797798

798799
def DllRegisterServer():
799-
import winreg
800-
801-
if sys.getwindowsversion()[0] < 6:
802-
print("This sample only works on Vista")
803-
sys.exit(1)
804-
805800
key = winreg.CreateKey(
806801
winreg.HKEY_LOCAL_MACHINE,
807802
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
@@ -816,7 +811,6 @@ def DllRegisterServer():
816811
attr = (
817812
shellcon.SFGAO_FOLDER | shellcon.SFGAO_HASSUBFOLDER | shellcon.SFGAO_BROWSABLE
818813
)
819-
import struct
820814

821815
s = struct.pack("i", attr)
822816
winreg.SetValueEx(key, "Attributes", 0, winreg.REG_BINARY, s)
@@ -832,8 +826,6 @@ def DllRegisterServer():
832826

833827

834828
def DllUnregisterServer():
835-
import winreg
836-
837829
paths = [
838830
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\Namespace\\"
839831
+ ShellFolder._reg_clsid_,

com/win32comext/shell/src/PyIFileOperation.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,6 @@ PyObject *PyIFileOperation::GetAnyOperationsAborted(PyObject *self, PyObject *ar
629629
// performed by the shell as a unit. Serves as a replacement for <om shell.SHFileOperation>.
630630
// <nl>No changes are actually made until PerformOperations is called.
631631
// <nl>Progress can be monitored by implementing <o PyGFileOperationProgressSink>.
632-
// <nl>Requires Vista or later.
633632
static struct PyMethodDef PyIFileOperation_methods[] = {
634633
{"Advise", PyIFileOperation::Advise, 1}, // @pymeth Advise|Connects an event sink to receive updates
635634
{"Unadvise", PyIFileOperation::Unadvise, 1}, // @pymeth Unadvise|Disconnects a progress sink

com/win32comext/shell/src/PyIKnownFolder.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ PyObject *PyIKnownFolder::GetFolderDefinition(PyObject *self, PyObject *args)
211211

212212
// @object PyIKnownFolder|Interface representing a known folder that serves
213213
// as a replacement for the numeric CSIDL definitions and API functions.
214-
// Requires Vista or later.
215214
static struct PyMethodDef PyIKnownFolder_methods[] = {
216215
{"GetId", PyIKnownFolder::GetId, 1}, // @pymeth GetId|Returns the id of the folder
217216
{"GetCategory", PyIKnownFolder::GetCategory,

0 commit comments

Comments
 (0)