1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 """
32 Wrapper for shlwapi.dll in ctypes.
33 """
34
35 __revision__ = "$Id: shlwapi.py 1299 2013-12-20 09:30:55Z qvasimodo $"
36
37 from defines import *
38 from kernel32 import *
39
40
41
42 _all = None
43 _all = set(vars().keys())
44
45
46 OS_WINDOWS = 0
47 OS_NT = 1
48 OS_WIN95ORGREATER = 2
49 OS_NT4ORGREATER = 3
50 OS_WIN98ORGREATER = 5
51 OS_WIN98_GOLD = 6
52 OS_WIN2000ORGREATER = 7
53 OS_WIN2000PRO = 8
54 OS_WIN2000SERVER = 9
55 OS_WIN2000ADVSERVER = 10
56 OS_WIN2000DATACENTER = 11
57 OS_WIN2000TERMINAL = 12
58 OS_EMBEDDED = 13
59 OS_TERMINALCLIENT = 14
60 OS_TERMINALREMOTEADMIN = 15
61 OS_WIN95_GOLD = 16
62 OS_MEORGREATER = 17
63 OS_XPORGREATER = 18
64 OS_HOME = 19
65 OS_PROFESSIONAL = 20
66 OS_DATACENTER = 21
67 OS_ADVSERVER = 22
68 OS_SERVER = 23
69 OS_TERMINALSERVER = 24
70 OS_PERSONALTERMINALSERVER = 25
71 OS_FASTUSERSWITCHING = 26
72 OS_WELCOMELOGONUI = 27
73 OS_DOMAINMEMBER = 28
74 OS_ANYSERVER = 29
75 OS_WOW6432 = 30
76 OS_WEBSERVER = 31
77 OS_SMALLBUSINESSSERVER = 32
78 OS_TABLETPC = 33
79 OS_SERVERADMINUI = 34
80 OS_MEDIACENTER = 35
81 OS_APPLIANCE = 36
82
83
84
85
86
87
103
104
105
106
108 _PathAddBackslashA = windll.shlwapi.PathAddBackslashA
109 _PathAddBackslashA.argtypes = [LPSTR]
110 _PathAddBackslashA.restype = LPSTR
111
112 lpszPath = ctypes.create_string_buffer(lpszPath, MAX_PATH)
113 retval = _PathAddBackslashA(lpszPath)
114 if retval == NULL:
115 raise ctypes.WinError()
116 return lpszPath.value
117
119 _PathAddBackslashW = windll.shlwapi.PathAddBackslashW
120 _PathAddBackslashW.argtypes = [LPWSTR]
121 _PathAddBackslashW.restype = LPWSTR
122
123 lpszPath = ctypes.create_unicode_buffer(lpszPath, MAX_PATH)
124 retval = _PathAddBackslashW(lpszPath)
125 if retval == NULL:
126 raise ctypes.WinError()
127 return lpszPath.value
128
129 PathAddBackslash = GuessStringType(PathAddBackslashA, PathAddBackslashW)
130
131
132
133
134
136 _PathAddExtensionA = windll.shlwapi.PathAddExtensionA
137 _PathAddExtensionA.argtypes = [LPSTR, LPSTR]
138 _PathAddExtensionA.restype = bool
139 _PathAddExtensionA.errcheck = RaiseIfZero
140
141 if not pszExtension:
142 pszExtension = None
143 lpszPath = ctypes.create_string_buffer(lpszPath, MAX_PATH)
144 _PathAddExtensionA(lpszPath, pszExtension)
145 return lpszPath.value
146
148 _PathAddExtensionW = windll.shlwapi.PathAddExtensionW
149 _PathAddExtensionW.argtypes = [LPWSTR, LPWSTR]
150 _PathAddExtensionW.restype = bool
151 _PathAddExtensionW.errcheck = RaiseIfZero
152
153 if not pszExtension:
154 pszExtension = None
155 lpszPath = ctypes.create_unicode_buffer(lpszPath, MAX_PATH)
156 _PathAddExtensionW(lpszPath, pszExtension)
157 return lpszPath.value
158
159 PathAddExtension = GuessStringType(PathAddExtensionA, PathAddExtensionW)
160
161
162
163
164
166 _PathAppendA = windll.shlwapi.PathAppendA
167 _PathAppendA.argtypes = [LPSTR, LPSTR]
168 _PathAppendA.restype = bool
169 _PathAppendA.errcheck = RaiseIfZero
170
171 if not pszMore:
172 pszMore = None
173 lpszPath = ctypes.create_string_buffer(lpszPath, MAX_PATH)
174 _PathAppendA(lpszPath, pszMore)
175 return lpszPath.value
176
178 _PathAppendW = windll.shlwapi.PathAppendW
179 _PathAppendW.argtypes = [LPWSTR, LPWSTR]
180 _PathAppendW.restype = bool
181 _PathAppendW.errcheck = RaiseIfZero
182
183 if not pszMore:
184 pszMore = None
185 lpszPath = ctypes.create_unicode_buffer(lpszPath, MAX_PATH)
186 _PathAppendW(lpszPath, pszMore)
187 return lpszPath.value
188
189 PathAppend = GuessStringType(PathAppendA, PathAppendW)
190
191
192
193
194
195
197 _PathCombineA = windll.shlwapi.PathCombineA
198 _PathCombineA.argtypes = [LPSTR, LPSTR, LPSTR]
199 _PathCombineA.restype = LPSTR
200
201 lpszDest = ctypes.create_string_buffer("", max(MAX_PATH, len(lpszDir) + len(lpszFile) + 1))
202 retval = _PathCombineA(lpszDest, lpszDir, lpszFile)
203 if retval == NULL:
204 return None
205 return lpszDest.value
206
208 _PathCombineW = windll.shlwapi.PathCombineW
209 _PathCombineW.argtypes = [LPWSTR, LPWSTR, LPWSTR]
210 _PathCombineW.restype = LPWSTR
211
212 lpszDest = ctypes.create_unicode_buffer(u"", max(MAX_PATH, len(lpszDir) + len(lpszFile) + 1))
213 retval = _PathCombineW(lpszDest, lpszDir, lpszFile)
214 if retval == NULL:
215 return None
216 return lpszDest.value
217
218 PathCombine = GuessStringType(PathCombineA, PathCombineW)
219
220
221
222
223
225 _PathCanonicalizeA = windll.shlwapi.PathCanonicalizeA
226 _PathCanonicalizeA.argtypes = [LPSTR, LPSTR]
227 _PathCanonicalizeA.restype = bool
228 _PathCanonicalizeA.errcheck = RaiseIfZero
229
230 lpszDst = ctypes.create_string_buffer("", MAX_PATH)
231 _PathCanonicalizeA(lpszDst, lpszSrc)
232 return lpszDst.value
233
235 _PathCanonicalizeW = windll.shlwapi.PathCanonicalizeW
236 _PathCanonicalizeW.argtypes = [LPWSTR, LPWSTR]
237 _PathCanonicalizeW.restype = bool
238 _PathCanonicalizeW.errcheck = RaiseIfZero
239
240 lpszDst = ctypes.create_unicode_buffer(u"", MAX_PATH)
241 _PathCanonicalizeW(lpszDst, lpszSrc)
242 return lpszDst.value
243
244 PathCanonicalize = GuessStringType(PathCanonicalizeA, PathCanonicalizeW)
245
246
247
248
249
250
251
252
254 _PathRelativePathToA = windll.shlwapi.PathRelativePathToA
255 _PathRelativePathToA.argtypes = [LPSTR, LPSTR, DWORD, LPSTR, DWORD]
256 _PathRelativePathToA.restype = bool
257 _PathRelativePathToA.errcheck = RaiseIfZero
258
259
260 if pszFrom:
261 pszFrom = GetFullPathNameA(pszFrom)[0]
262 else:
263 pszFrom = GetCurrentDirectoryA()
264 if pszTo:
265 pszTo = GetFullPathNameA(pszTo)[0]
266 else:
267 pszTo = GetCurrentDirectoryA()
268
269
270
271 dwPath = max((len(pszFrom) + len(pszTo)) * 2 + 1, MAX_PATH + 1)
272 pszPath = ctypes.create_string_buffer('', dwPath)
273
274
275
276
277
278 SetLastError(ERROR_INVALID_PARAMETER)
279
280 _PathRelativePathToA(pszPath, pszFrom, dwAttrFrom, pszTo, dwAttrTo)
281 return pszPath.value
282
284 _PathRelativePathToW = windll.shlwapi.PathRelativePathToW
285 _PathRelativePathToW.argtypes = [LPWSTR, LPWSTR, DWORD, LPWSTR, DWORD]
286 _PathRelativePathToW.restype = bool
287 _PathRelativePathToW.errcheck = RaiseIfZero
288
289
290 if pszFrom:
291 pszFrom = GetFullPathNameW(pszFrom)[0]
292 else:
293 pszFrom = GetCurrentDirectoryW()
294 if pszTo:
295 pszTo = GetFullPathNameW(pszTo)[0]
296 else:
297 pszTo = GetCurrentDirectoryW()
298 dwPath = max((len(pszFrom) + len(pszTo)) * 2 + 1, MAX_PATH + 1)
299 pszPath = ctypes.create_unicode_buffer(u'', dwPath)
300 SetLastError(ERROR_INVALID_PARAMETER)
301 _PathRelativePathToW(pszPath, pszFrom, dwAttrFrom, pszTo, dwAttrTo)
302 return pszPath.value
303
304 PathRelativePathTo = GuessStringType(PathRelativePathToA, PathRelativePathToW)
305
306
307
308
310 _PathFileExistsA = windll.shlwapi.PathFileExistsA
311 _PathFileExistsA.argtypes = [LPSTR]
312 _PathFileExistsA.restype = bool
313 return _PathFileExistsA(pszPath)
314
316 _PathFileExistsW = windll.shlwapi.PathFileExistsW
317 _PathFileExistsW.argtypes = [LPWSTR]
318 _PathFileExistsW.restype = bool
319 return _PathFileExistsW(pszPath)
320
321 PathFileExists = GuessStringType(PathFileExistsA, PathFileExistsW)
322
323
324
325
327 _PathFindExtensionA = windll.shlwapi.PathFindExtensionA
328 _PathFindExtensionA.argtypes = [LPSTR]
329 _PathFindExtensionA.restype = LPSTR
330 pszPath = ctypes.create_string_buffer(pszPath)
331 return _PathFindExtensionA(pszPath)
332
334 _PathFindExtensionW = windll.shlwapi.PathFindExtensionW
335 _PathFindExtensionW.argtypes = [LPWSTR]
336 _PathFindExtensionW.restype = LPWSTR
337 pszPath = ctypes.create_unicode_buffer(pszPath)
338 return _PathFindExtensionW(pszPath)
339
340 PathFindExtension = GuessStringType(PathFindExtensionA, PathFindExtensionW)
341
342
343
344
346 _PathFindFileNameA = windll.shlwapi.PathFindFileNameA
347 _PathFindFileNameA.argtypes = [LPSTR]
348 _PathFindFileNameA.restype = LPSTR
349 pszPath = ctypes.create_string_buffer(pszPath)
350 return _PathFindFileNameA(pszPath)
351
353 _PathFindFileNameW = windll.shlwapi.PathFindFileNameW
354 _PathFindFileNameW.argtypes = [LPWSTR]
355 _PathFindFileNameW.restype = LPWSTR
356 pszPath = ctypes.create_unicode_buffer(pszPath)
357 return _PathFindFileNameW(pszPath)
358
359 PathFindFileName = GuessStringType(PathFindFileNameA, PathFindFileNameW)
360
361
362
363
365 _PathFindNextComponentA = windll.shlwapi.PathFindNextComponentA
366 _PathFindNextComponentA.argtypes = [LPSTR]
367 _PathFindNextComponentA.restype = LPSTR
368 pszPath = ctypes.create_string_buffer(pszPath)
369 return _PathFindNextComponentA(pszPath)
370
372 _PathFindNextComponentW = windll.shlwapi.PathFindNextComponentW
373 _PathFindNextComponentW.argtypes = [LPWSTR]
374 _PathFindNextComponentW.restype = LPWSTR
375 pszPath = ctypes.create_unicode_buffer(pszPath)
376 return _PathFindNextComponentW(pszPath)
377
378 PathFindNextComponent = GuessStringType(PathFindNextComponentA, PathFindNextComponentW)
379
380
381
382
383
385 _PathFindOnPathA = windll.shlwapi.PathFindOnPathA
386 _PathFindOnPathA.argtypes = [LPSTR, LPSTR]
387 _PathFindOnPathA.restype = bool
388
389 pszFile = ctypes.create_string_buffer(pszFile, MAX_PATH)
390 if not ppszOtherDirs:
391 ppszOtherDirs = None
392 else:
393 szArray = ""
394 for pszOtherDirs in ppszOtherDirs:
395 if pszOtherDirs:
396 szArray = "%s%s\0" % (szArray, pszOtherDirs)
397 szArray = szArray + "\0"
398 pszOtherDirs = ctypes.create_string_buffer(szArray)
399 ppszOtherDirs = ctypes.pointer(pszOtherDirs)
400 if _PathFindOnPathA(pszFile, ppszOtherDirs):
401 return pszFile.value
402 return None
403
405 _PathFindOnPathW = windll.shlwapi.PathFindOnPathA
406 _PathFindOnPathW.argtypes = [LPWSTR, LPWSTR]
407 _PathFindOnPathW.restype = bool
408
409 pszFile = ctypes.create_unicode_buffer(pszFile, MAX_PATH)
410 if not ppszOtherDirs:
411 ppszOtherDirs = None
412 else:
413 szArray = u""
414 for pszOtherDirs in ppszOtherDirs:
415 if pszOtherDirs:
416 szArray = u"%s%s\0" % (szArray, pszOtherDirs)
417 szArray = szArray + u"\0"
418 pszOtherDirs = ctypes.create_unicode_buffer(szArray)
419 ppszOtherDirs = ctypes.pointer(pszOtherDirs)
420 if _PathFindOnPathW(pszFile, ppszOtherDirs):
421 return pszFile.value
422 return None
423
424 PathFindOnPath = GuessStringType(PathFindOnPathA, PathFindOnPathW)
425
426
427
428
430 _PathGetArgsA = windll.shlwapi.PathGetArgsA
431 _PathGetArgsA.argtypes = [LPSTR]
432 _PathGetArgsA.restype = LPSTR
433 pszPath = ctypes.create_string_buffer(pszPath)
434 return _PathGetArgsA(pszPath)
435
437 _PathGetArgsW = windll.shlwapi.PathGetArgsW
438 _PathGetArgsW.argtypes = [LPWSTR]
439 _PathGetArgsW.restype = LPWSTR
440 pszPath = ctypes.create_unicode_buffer(pszPath)
441 return _PathGetArgsW(pszPath)
442
443 PathGetArgs = GuessStringType(PathGetArgsA, PathGetArgsW)
444
445
446
447
448
449 -def PathIsContentTypeA(pszPath, pszContentType):
450 _PathIsContentTypeA = windll.shlwapi.PathIsContentTypeA
451 _PathIsContentTypeA.argtypes = [LPSTR, LPSTR]
452 _PathIsContentTypeA.restype = bool
453 return _PathIsContentTypeA(pszPath, pszContentType)
454
455 -def PathIsContentTypeW(pszPath, pszContentType):
456 _PathIsContentTypeW = windll.shlwapi.PathIsContentTypeW
457 _PathIsContentTypeW.argtypes = [LPWSTR, LPWSTR]
458 _PathIsContentTypeW.restype = bool
459 return _PathIsContentTypeW(pszPath, pszContentType)
460
461 PathIsContentType = GuessStringType(PathIsContentTypeA, PathIsContentTypeW)
462
463
464
465
467 _PathIsDirectoryA = windll.shlwapi.PathIsDirectoryA
468 _PathIsDirectoryA.argtypes = [LPSTR]
469 _PathIsDirectoryA.restype = bool
470 return _PathIsDirectoryA(pszPath)
471
473 _PathIsDirectoryW = windll.shlwapi.PathIsDirectoryW
474 _PathIsDirectoryW.argtypes = [LPWSTR]
475 _PathIsDirectoryW.restype = bool
476 return _PathIsDirectoryW(pszPath)
477
478 PathIsDirectory = GuessStringType(PathIsDirectoryA, PathIsDirectoryW)
479
480
481
482
484 _PathIsDirectoryEmptyA = windll.shlwapi.PathIsDirectoryEmptyA
485 _PathIsDirectoryEmptyA.argtypes = [LPSTR]
486 _PathIsDirectoryEmptyA.restype = bool
487 return _PathIsDirectoryEmptyA(pszPath)
488
490 _PathIsDirectoryEmptyW = windll.shlwapi.PathIsDirectoryEmptyW
491 _PathIsDirectoryEmptyW.argtypes = [LPWSTR]
492 _PathIsDirectoryEmptyW.restype = bool
493 return _PathIsDirectoryEmptyW(pszPath)
494
495 PathIsDirectoryEmpty = GuessStringType(PathIsDirectoryEmptyA, PathIsDirectoryEmptyW)
496
497
498
499
501 _PathIsNetworkPathA = windll.shlwapi.PathIsNetworkPathA
502 _PathIsNetworkPathA.argtypes = [LPSTR]
503 _PathIsNetworkPathA.restype = bool
504 return _PathIsNetworkPathA(pszPath)
505
507 _PathIsNetworkPathW = windll.shlwapi.PathIsNetworkPathW
508 _PathIsNetworkPathW.argtypes = [LPWSTR]
509 _PathIsNetworkPathW.restype = bool
510 return _PathIsNetworkPathW(pszPath)
511
512 PathIsNetworkPath = GuessStringType(PathIsNetworkPathA, PathIsNetworkPathW)
513
514
515
516
518 _PathIsRelativeA = windll.shlwapi.PathIsRelativeA
519 _PathIsRelativeA.argtypes = [LPSTR]
520 _PathIsRelativeA.restype = bool
521 return _PathIsRelativeA(pszPath)
522
524 _PathIsRelativeW = windll.shlwapi.PathIsRelativeW
525 _PathIsRelativeW.argtypes = [LPWSTR]
526 _PathIsRelativeW.restype = bool
527 return _PathIsRelativeW(pszPath)
528
529 PathIsRelative = GuessStringType(PathIsRelativeA, PathIsRelativeW)
530
531
532
533
535 _PathIsRootA = windll.shlwapi.PathIsRootA
536 _PathIsRootA.argtypes = [LPSTR]
537 _PathIsRootA.restype = bool
538 return _PathIsRootA(pszPath)
539
541 _PathIsRootW = windll.shlwapi.PathIsRootW
542 _PathIsRootW.argtypes = [LPWSTR]
543 _PathIsRootW.restype = bool
544 return _PathIsRootW(pszPath)
545
546 PathIsRoot = GuessStringType(PathIsRootA, PathIsRootW)
547
548
549
550
551
553 _PathIsSameRootA = windll.shlwapi.PathIsSameRootA
554 _PathIsSameRootA.argtypes = [LPSTR, LPSTR]
555 _PathIsSameRootA.restype = bool
556 return _PathIsSameRootA(pszPath1, pszPath2)
557
559 _PathIsSameRootW = windll.shlwapi.PathIsSameRootW
560 _PathIsSameRootW.argtypes = [LPWSTR, LPWSTR]
561 _PathIsSameRootW.restype = bool
562 return _PathIsSameRootW(pszPath1, pszPath2)
563
564 PathIsSameRoot = GuessStringType(PathIsSameRootA, PathIsSameRootW)
565
566
567
568
570 _PathIsUNCA = windll.shlwapi.PathIsUNCA
571 _PathIsUNCA.argtypes = [LPSTR]
572 _PathIsUNCA.restype = bool
573 return _PathIsUNCA(pszPath)
574
576 _PathIsUNCW = windll.shlwapi.PathIsUNCW
577 _PathIsUNCW.argtypes = [LPWSTR]
578 _PathIsUNCW.restype = bool
579 return _PathIsUNCW(pszPath)
580
581 PathIsUNC = GuessStringType(PathIsUNCA, PathIsUNCW)
582
583
584
585
586
587
588
589
591 _PathMakePrettyA = windll.shlwapi.PathMakePrettyA
592 _PathMakePrettyA.argtypes = [LPSTR]
593 _PathMakePrettyA.restype = bool
594 _PathMakePrettyA.errcheck = RaiseIfZero
595
596 pszPath = ctypes.create_string_buffer(pszPath, MAX_PATH)
597 _PathMakePrettyA(pszPath)
598 return pszPath.value
599
601 _PathMakePrettyW = windll.shlwapi.PathMakePrettyW
602 _PathMakePrettyW.argtypes = [LPWSTR]
603 _PathMakePrettyW.restype = bool
604 _PathMakePrettyW.errcheck = RaiseIfZero
605
606 pszPath = ctypes.create_unicode_buffer(pszPath, MAX_PATH)
607 _PathMakePrettyW(pszPath)
608 return pszPath.value
609
610 PathMakePretty = GuessStringType(PathMakePrettyA, PathMakePrettyW)
611
612
613
614
616 _PathRemoveArgsA = windll.shlwapi.PathRemoveArgsA
617 _PathRemoveArgsA.argtypes = [LPSTR]
618
619 pszPath = ctypes.create_string_buffer(pszPath, MAX_PATH)
620 _PathRemoveArgsA(pszPath)
621 return pszPath.value
622
624 _PathRemoveArgsW = windll.shlwapi.PathRemoveArgsW
625 _PathRemoveArgsW.argtypes = [LPWSTR]
626
627 pszPath = ctypes.create_unicode_buffer(pszPath, MAX_PATH)
628 _PathRemoveArgsW(pszPath)
629 return pszPath.value
630
631 PathRemoveArgs = GuessStringType(PathRemoveArgsA, PathRemoveArgsW)
632
633
634
635
637 _PathRemoveBackslashA = windll.shlwapi.PathRemoveBackslashA
638 _PathRemoveBackslashA.argtypes = [LPSTR]
639
640 pszPath = ctypes.create_string_buffer(pszPath, MAX_PATH)
641 _PathRemoveBackslashA(pszPath)
642 return pszPath.value
643
645 _PathRemoveBackslashW = windll.shlwapi.PathRemoveBackslashW
646 _PathRemoveBackslashW.argtypes = [LPWSTR]
647
648 pszPath = ctypes.create_unicode_buffer(pszPath, MAX_PATH)
649 _PathRemoveBackslashW(pszPath)
650 return pszPath.value
651
652 PathRemoveBackslash = GuessStringType(PathRemoveBackslashA, PathRemoveBackslashW)
653
654
655
656
658 _PathRemoveExtensionA = windll.shlwapi.PathRemoveExtensionA
659 _PathRemoveExtensionA.argtypes = [LPSTR]
660
661 pszPath = ctypes.create_string_buffer(pszPath, MAX_PATH)
662 _PathRemoveExtensionA(pszPath)
663 return pszPath.value
664
666 _PathRemoveExtensionW = windll.shlwapi.PathRemoveExtensionW
667 _PathRemoveExtensionW.argtypes = [LPWSTR]
668
669 pszPath = ctypes.create_unicode_buffer(pszPath, MAX_PATH)
670 _PathRemoveExtensionW(pszPath)
671 return pszPath.value
672
673 PathRemoveExtension = GuessStringType(PathRemoveExtensionA, PathRemoveExtensionW)
674
675
676
677
679 _PathRemoveFileSpecA = windll.shlwapi.PathRemoveFileSpecA
680 _PathRemoveFileSpecA.argtypes = [LPSTR]
681
682 pszPath = ctypes.create_string_buffer(pszPath, MAX_PATH)
683 _PathRemoveFileSpecA(pszPath)
684 return pszPath.value
685
687 _PathRemoveFileSpecW = windll.shlwapi.PathRemoveFileSpecW
688 _PathRemoveFileSpecW.argtypes = [LPWSTR]
689
690 pszPath = ctypes.create_unicode_buffer(pszPath, MAX_PATH)
691 _PathRemoveFileSpecW(pszPath)
692 return pszPath.value
693
694 PathRemoveFileSpec = GuessStringType(PathRemoveFileSpecA, PathRemoveFileSpecW)
695
696
697
698
699
701 _PathRenameExtensionA = windll.shlwapi.PathRenameExtensionA
702 _PathRenameExtensionA.argtypes = [LPSTR, LPSTR]
703 _PathRenameExtensionA.restype = bool
704
705 pszPath = ctypes.create_string_buffer(pszPath, MAX_PATH)
706 if _PathRenameExtensionA(pszPath, pszExt):
707 return pszPath.value
708 return None
709
711 _PathRenameExtensionW = windll.shlwapi.PathRenameExtensionW
712 _PathRenameExtensionW.argtypes = [LPWSTR, LPWSTR]
713 _PathRenameExtensionW.restype = bool
714
715 pszPath = ctypes.create_unicode_buffer(pszPath, MAX_PATH)
716 if _PathRenameExtensionW(pszPath, pszExt):
717 return pszPath.value
718 return None
719
720 PathRenameExtension = GuessStringType(PathRenameExtensionA, PathRenameExtensionW)
721
722
723
724
725
726
728 _PathUnExpandEnvStringsA = windll.shlwapi.PathUnExpandEnvStringsA
729 _PathUnExpandEnvStringsA.argtypes = [LPSTR, LPSTR]
730 _PathUnExpandEnvStringsA.restype = bool
731 _PathUnExpandEnvStringsA.errcheck = RaiseIfZero
732
733 cchBuf = MAX_PATH
734 pszBuf = ctypes.create_string_buffer("", cchBuf)
735 _PathUnExpandEnvStringsA(pszPath, pszBuf, cchBuf)
736 return pszBuf.value
737
739 _PathUnExpandEnvStringsW = windll.shlwapi.PathUnExpandEnvStringsW
740 _PathUnExpandEnvStringsW.argtypes = [LPWSTR, LPWSTR]
741 _PathUnExpandEnvStringsW.restype = bool
742 _PathUnExpandEnvStringsW.errcheck = RaiseIfZero
743
744 cchBuf = MAX_PATH
745 pszBuf = ctypes.create_unicode_buffer(u"", cchBuf)
746 _PathUnExpandEnvStringsW(pszPath, pszBuf, cchBuf)
747 return pszBuf.value
748
749 PathUnExpandEnvStrings = GuessStringType(PathUnExpandEnvStringsA, PathUnExpandEnvStringsW)
750
751
752
753 _all = set(vars().keys()).difference(_all)
754 __all__ = [_x for _x in _all if not _x.startswith('_')]
755 __all__.sort()
756
757