@@ -78,6 +78,19 @@ def is_equal_guid(guid1, guid2):
78
78
)
79
79
80
80
81
+ def create_shelllink_persist (typ ):
82
+ ppst = typ ()
83
+ # https://learn.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-cocreateinstance
84
+ ole32 .CoCreateInstance (
85
+ byref (CLSID_ShellLink ),
86
+ None ,
87
+ CLSCTX_SERVER ,
88
+ byref (IID_IPersist ),
89
+ byref (ppst ),
90
+ )
91
+ return ppst
92
+
93
+
81
94
class ForeignFunctionsThatWillCallComMethodsTests (unittest .TestCase ):
82
95
def setUp (self ):
83
96
# https://learn.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-coinitializeex
@@ -88,19 +101,6 @@ def tearDown(self):
88
101
ole32 .CoUninitialize ()
89
102
gc .collect ()
90
103
91
- @staticmethod
92
- def create_shelllink_persist (typ ):
93
- ppst = typ ()
94
- # https://learn.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-cocreateinstance
95
- ole32 .CoCreateInstance (
96
- byref (CLSID_ShellLink ),
97
- None ,
98
- CLSCTX_SERVER ,
99
- byref (IID_IPersist ),
100
- byref (ppst ),
101
- )
102
- return ppst
103
-
104
104
def test_without_paramflags_and_iid (self ):
105
105
class IUnknown (c_void_p ):
106
106
QueryInterface = proto_query_interface ()
@@ -110,7 +110,7 @@ class IUnknown(c_void_p):
110
110
class IPersist (IUnknown ):
111
111
GetClassID = proto_get_class_id ()
112
112
113
- ppst = self . create_shelllink_persist (IPersist )
113
+ ppst = create_shelllink_persist (IPersist )
114
114
115
115
clsid = GUID ()
116
116
hr_getclsid = ppst .GetClassID (byref (clsid ))
@@ -142,7 +142,7 @@ class IUnknown(c_void_p):
142
142
class IPersist (IUnknown ):
143
143
GetClassID = proto_get_class_id (((OUT , "pClassID" ),))
144
144
145
- ppst = self . create_shelllink_persist (IPersist )
145
+ ppst = create_shelllink_persist (IPersist )
146
146
147
147
clsid = ppst .GetClassID ()
148
148
self .assertEqual (TRUE , is_equal_guid (CLSID_ShellLink , clsid ))
@@ -167,7 +167,7 @@ class IUnknown(c_void_p):
167
167
class IPersist (IUnknown ):
168
168
GetClassID = proto_get_class_id (((OUT , "pClassID" ),), IID_IPersist )
169
169
170
- ppst = self . create_shelllink_persist (IPersist )
170
+ ppst = create_shelllink_persist (IPersist )
171
171
172
172
clsid = ppst .GetClassID ()
173
173
self .assertEqual (TRUE , is_equal_guid (CLSID_ShellLink , clsid ))
0 commit comments