Package winappdbg :: Package win32 :: Module shlwapi
[hide private]
[frames] | no frames]

Source Code for Module winappdbg.win32.shlwapi

  1  # Copyright (c) 2009-2010, Mario Vilas 
  2  # All rights reserved. 
  3  # 
  4  # Redistribution and use in source and binary forms, with or without 
  5  # modification, are permitted provided that the following conditions are met: 
  6  # 
  7  #     * Redistributions of source code must retain the above copyright notice, 
  8  #       this list of conditions and the following disclaimer. 
  9  #     * Redistributions in binary form must reproduce the above copyright 
 10  #       notice,this list of conditions and the following disclaimer in the 
 11  #       documentation and/or other materials provided with the distribution. 
 12  #     * Neither the name of the copyright holder nor the names of its 
 13  #       contributors may be used to endorse or promote products derived from 
 14  #       this software without specific prior written permission. 
 15  # 
 16  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 17  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 18  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 19  # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 20  # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 21  # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 22  # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 23  # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 24  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 25  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 26  # POSSIBILITY OF SUCH DAMAGE. 
 27   
 28  """ 
 29  Wrapper for shlwapi.dll in ctypes. 
 30  """ 
 31   
 32  __revision__ = "$Id: shlwapi.py 618 2010-02-11 02:15:09Z qvasimodo $" 
 33   
 34  from defines import * 
 35   
 36  OS_WINDOWS                  = 0 
 37  OS_NT                       = 1 
 38  OS_WIN95ORGREATER           = 2 
 39  OS_NT4ORGREATER             = 3 
 40  OS_WIN98ORGREATER           = 5 
 41  OS_WIN98_GOLD               = 6 
 42  OS_WIN2000ORGREATER         = 7 
 43  OS_WIN2000PRO               = 8 
 44  OS_WIN2000SERVER            = 9 
 45  OS_WIN2000ADVSERVER         = 10 
 46  OS_WIN2000DATACENTER        = 11 
 47  OS_WIN2000TERMINAL          = 12 
 48  OS_EMBEDDED                 = 13 
 49  OS_TERMINALCLIENT           = 14 
 50  OS_TERMINALREMOTEADMIN      = 15 
 51  OS_WIN95_GOLD               = 16 
 52  OS_MEORGREATER              = 17 
 53  OS_XPORGREATER              = 18 
 54  OS_HOME                     = 19 
 55  OS_PROFESSIONAL             = 20 
 56  OS_DATACENTER               = 21 
 57  OS_ADVSERVER                = 22 
 58  OS_SERVER                   = 23 
 59  OS_TERMINALSERVER           = 24 
 60  OS_PERSONALTERMINALSERVER   = 25 
 61  OS_FASTUSERSWITCHING        = 26 
 62  OS_WELCOMELOGONUI           = 27 
 63  OS_DOMAINMEMBER             = 28 
 64  OS_ANYSERVER                = 29 
 65  OS_WOW6432                  = 30 
 66  OS_WEBSERVER                = 31 
 67  OS_SMALLBUSINESSSERVER      = 32 
 68  OS_TABLETPC                 = 33 
 69  OS_SERVERADMINUI            = 34 
 70  OS_MEDIACENTER              = 35 
 71  OS_APPLIANCE                = 36 
 72   
 73  #--- shlwapi.dll -------------------------------------------------------------- 
 74   
 75  # BOOL IsOS( 
 76  #     DWORD dwOS 
 77  # ); 
78 -def IsOS(dwOS):
79 try: 80 _IsOS = windll.shlwapi.IsOS 81 _IsOS.argtypes = [DWORD] 82 _IsOS.restype = bool 83 except: 84 # According to MSDN, on Windows versions prior to Vista 85 # this function is exported only by ordinal number 437. 86 # http://msdn.microsoft.com/en-us/library/bb773795%28VS.85%29.aspx 87 _GetProcAddress = windll.kernel32.GetProcAddress 88 _GetProcAddress.argtypes = [HINSTANCE, DWORD] 89 _GetProcAddress.restype = LPVOID 90 _IsOS = windll.kernel32.GetProcAddress(windll.shlwapi._handle, 437) 91 _IsOS = WINFUNCTYPE(bool, DWORD)(_IsOS) 92 return _IsOS(dwOS)
93 94 # LPTSTR PathAddBackslash( 95 # LPTSTR lpszPath 96 # );
97 -def PathAddBackslashA(lpszPath):
98 _PathAddBackslashA = windll.shlwapi.PathAddBackslashA 99 _PathAddBackslashA.argtypes = [LPSTR] 100 _PathAddBackslashA.restype = LPSTR 101 102 lpszPath = ctypes.create_string_buffer(lpszPath, MAX_PATH) 103 retval = _PathAddBackslashA(lpszPath) 104 if retval == NULL: 105 raise ctypes.WinError() 106 return lpszPath.value
107
108 -def PathAddBackslashW(lpszPath):
109 _PathAddBackslashW = windll.shlwapi.PathAddBackslashW 110 _PathAddBackslashW.argtypes = [LPWSTR] 111 _PathAddBackslashW.restype = LPWSTR 112 113 lpszPath = ctypes.create_unicode_buffer(lpszPath, MAX_PATH) 114 retval = _PathAddBackslashW(lpszPath) 115 if retval == NULL: 116 raise ctypes.WinError() 117 return lpszPath.value
118 119 PathAddBackslash = GuessStringType(PathAddBackslashA, PathAddBackslashW) 120 121 # BOOL PathAddExtension( 122 # LPTSTR pszPath, 123 # LPCTSTR pszExtension 124 # );
125 -def PathAddExtensionA(lpszPath, pszExtension = None):
126 _PathAddExtensionA = windll.shlwapi.PathAddExtensionA 127 _PathAddExtensionA.argtypes = [LPSTR, LPSTR] 128 _PathAddExtensionA.restype = bool 129 _PathAddExtensionA.errcheck = RaiseIfZero 130 131 if not pszExtension: 132 pszExtension = None 133 lpszPath = ctypes.create_string_buffer(lpszPath, MAX_PATH) 134 _PathAddExtensionA(lpszPath, pszExtension) 135 return lpszPath.value
136
137 -def PathAddExtensionW(lpszPath, pszExtension = None):
138 _PathAddExtensionW = windll.shlwapi.PathAddExtensionW 139 _PathAddExtensionW.argtypes = [LPWSTR, LPWSTR] 140 _PathAddExtensionW.restype = bool 141 _PathAddExtensionW.errcheck = RaiseIfZero 142 143 if not pszExtension: 144 pszExtension = None 145 lpszPath = ctypes.create_unicode_buffer(lpszPath, MAX_PATH) 146 _PathAddExtensionW(lpszPath, pszExtension) 147 return lpszPath.value
148 149 PathAddExtension = GuessStringType(PathAddExtensionA, PathAddExtensionW) 150 151 # BOOL PathAppend( 152 # LPTSTR pszPath, 153 # LPCTSTR pszMore 154 # );
155 -def PathAppendA(lpszPath, pszMore = None):
156 _PathAppendA = windll.shlwapi.PathAppendA 157 _PathAppendA.argtypes = [LPSTR, LPSTR] 158 _PathAppendA.restype = bool 159 _PathAppendA.errcheck = RaiseIfZero 160 161 if not pszMore: 162 pszMore = None 163 lpszPath = ctypes.create_string_buffer(lpszPath, MAX_PATH) 164 _PathAppendA(lpszPath, pszMore) 165 return lpszPath.value
166
167 -def PathAppendW(lpszPath, pszMore = None):
168 _PathAppendW = windll.shlwapi.PathAppendW 169 _PathAppendW.argtypes = [LPWSTR, LPWSTR] 170 _PathAppendW.restype = bool 171 _PathAppendW.errcheck = RaiseIfZero 172 173 if not pszMore: 174 pszMore = None 175 lpszPath = ctypes.create_unicode_buffer(lpszPath, MAX_PATH) 176 _PathAppendW(lpszPath, pszMore) 177 return lpszPath.value
178 179 PathAppend = GuessStringType(PathAppendA, PathAppendW) 180 181 # LPTSTR PathCombine( 182 # LPTSTR lpszDest, 183 # LPCTSTR lpszDir, 184 # LPCTSTR lpszFile 185 # );
186 -def PathCombineA(lpszDir, lpszFile):
187 _PathCombineA = windll.shlwapi.PathCombineA 188 _PathCombineA.argtypes = [LPSTR, LPSTR, LPSTR] 189 _PathCombineA.restype = LPSTR 190 191 lpszDest = ctypes.create_string_buffer("", max(MAX_PATH, len(lpszDir) + len(lpszFile) + 1)) 192 retval = _PathCombineA(lpszDest, lpszDir, lpszFile) 193 if retval == NULL: 194 return None 195 return lpszDest.value
196
197 -def PathCombineW(lpszDir, lpszFile):
198 _PathCombineW = windll.shlwapi.PathCombineW 199 _PathCombineW.argtypes = [LPWSTR, LPWSTR, LPWSTR] 200 _PathCombineW.restype = LPWSTR 201 202 lpszDest = ctypes.create_unicode_buffer(u"", max(MAX_PATH, len(lpszDir) + len(lpszFile) + 1)) 203 retval = _PathCombineW(lpszDest, lpszDir, lpszFile) 204 if retval == NULL: 205 return None 206 return lpszDest.value
207 208 PathCombine = GuessStringType(PathCombineA, PathCombineW) 209 210 # BOOL PathCanonicalize( 211 # LPTSTR lpszDst, 212 # LPCTSTR lpszSrc 213 # );
214 -def PathCanonicalizeA(lpszSrc):
215 _PathCanonicalizeA = windll.shlwapi.PathCanonicalizeA 216 _PathCanonicalizeA.argtypes = [LPSTR, LPSTR] 217 _PathCanonicalizeA.restype = bool 218 _PathCanonicalizeA.errcheck = RaiseIfZero 219 220 lpszDst = ctypes.create_string_buffer("", MAX_PATH) 221 _PathCanonicalizeA(lpszDst, lpszSrc) 222 return lpszDst.value
223
224 -def PathCanonicalizeW(lpszSrc):
225 _PathCanonicalizeW = windll.shlwapi.PathCanonicalizeW 226 _PathCanonicalizeW.argtypes = [LPWSTR, LPWSTR] 227 _PathCanonicalizeW.restype = bool 228 _PathCanonicalizeW.errcheck = RaiseIfZero 229 230 lpszDst = ctypes.create_unicode_buffer(u"", MAX_PATH) 231 _PathCanonicalizeW(lpszDst, lpszSrc) 232 return lpszDst.value
233 234 PathCanonicalize = GuessStringType(PathCanonicalizeA, PathCanonicalizeW) 235 236 # BOOL PathFileExists( 237 # LPCTSTR pszPath 238 # );
239 -def PathFileExistsA(pszPath):
240 _PathFileExistsA = windll.shlwapi.PathFileExistsA 241 _PathFileExistsA.argtypes = [LPSTR] 242 _PathFileExistsA.restype = bool 243 return _PathFileExistsA(pszPath)
244
245 -def PathFileExistsW(pszPath):
246 _PathFileExistsW = windll.shlwapi.PathFileExistsW 247 _PathFileExistsW.argtypes = [LPWSTR] 248 _PathFileExistsW.restype = bool 249 return _PathFileExistsW(pszPath)
250 251 PathFileExists = GuessStringType(PathFileExistsA, PathFileExistsW) 252 253 # LPTSTR PathFindExtension( 254 # LPCTSTR pszPath 255 # );
256 -def PathFindExtensionA(pszPath):
257 _PathFindExtensionA = windll.shlwapi.PathFindExtensionA 258 _PathFindExtensionA.argtypes = [LPSTR] 259 _PathFindExtensionA.restype = LPSTR 260 pszPath = ctypes.create_string_buffer(pszPath) 261 return _PathFindExtensionA(pszPath)
262
263 -def PathFindExtensionW(pszPath):
264 _PathFindExtensionW = windll.shlwapi.PathFindExtensionW 265 _PathFindExtensionW.argtypes = [LPWSTR] 266 _PathFindExtensionW.restype = LPWSTR 267 pszPath = ctypes.create_unicode_buffer(pszPath) 268 return _PathFindExtensionW(pszPath)
269 270 PathFindExtension = GuessStringType(PathFindExtensionA, PathFindExtensionW) 271 272 # LPTSTR PathFindFileName( 273 # LPCTSTR pszPath 274 # );
275 -def PathFindFileNameA(pszPath):
276 _PathFindFileNameA = windll.shlwapi.PathFindFileNameA 277 _PathFindFileNameA.argtypes = [LPSTR] 278 _PathFindFileNameA.restype = LPSTR 279 pszPath = ctypes.create_string_buffer(pszPath) 280 return _PathFindFileNameA(pszPath)
281
282 -def PathFindFileNameW(pszPath):
283 _PathFindFileNameW = windll.shlwapi.PathFindFileNameW 284 _PathFindFileNameW.argtypes = [LPWSTR] 285 _PathFindFileNameW.restype = LPWSTR 286 pszPath = ctypes.create_unicode_buffer(pszPath) 287 return _PathFindFileNameW(pszPath)
288 289 PathFindFileName = GuessStringType(PathFindFileNameA, PathFindFileNameW) 290 291 # LPTSTR PathFindNextComponent( 292 # LPCTSTR pszPath 293 # );
294 -def PathFindNextComponentA(pszPath):
295 _PathFindNextComponentA = windll.shlwapi.PathFindNextComponentA 296 _PathFindNextComponentA.argtypes = [LPSTR] 297 _PathFindNextComponentA.restype = LPSTR 298 pszPath = ctypes.create_string_buffer(pszPath) 299 return _PathFindNextComponentA(pszPath)
300
301 -def PathFindNextComponentW(pszPath):
302 _PathFindNextComponentW = windll.shlwapi.PathFindNextComponentW 303 _PathFindNextComponentW.argtypes = [LPWSTR] 304 _PathFindNextComponentW.restype = LPWSTR 305 pszPath = ctypes.create_unicode_buffer(pszPath) 306 return _PathFindNextComponentW(pszPath)
307 308 PathFindNextComponent = GuessStringType(PathFindNextComponentA, PathFindNextComponentW) 309 310 # BOOL PathFindOnPath( 311 # LPTSTR pszFile, 312 # LPCTSTR *ppszOtherDirs 313 # );
314 -def PathFindOnPathA(pszFile, ppszOtherDirs = None):
315 _PathFindOnPathA = windll.shlwapi.PathFindOnPathA 316 _PathFindOnPathA.argtypes = [LPSTR, LPSTR] 317 _PathFindOnPathA.restype = bool 318 319 pszFile = ctypes.create_string_buffer(pszFile, MAX_PATH) 320 if not ppszOtherDirs: 321 ppszOtherDirs = None 322 else: 323 szArray = "" 324 for pszOtherDirs in ppszOtherDirs: 325 if pszOtherDirs: 326 szArray = "%s%s\0" % (szArray, pszOtherDirs) 327 szArray = szArray + "\0" 328 pszOtherDirs = ctypes.create_string_buffer(szArray) 329 ppszOtherDirs = ctypes.pointer(pszOtherDirs) 330 if _PathFindOnPathA(pszFile, ppszOtherDirs): 331 return pszFile.value 332 return None
333
334 -def PathFindOnPathW(pszFile, ppszOtherDirs = None):
335 _PathFindOnPathW = windll.shlwapi.PathFindOnPathA 336 _PathFindOnPathW.argtypes = [LPWSTR, LPWSTR] 337 _PathFindOnPathW.restype = bool 338 339 pszFile = ctypes.create_unicode_buffer(pszFile, MAX_PATH) 340 if not ppszOtherDirs: 341 ppszOtherDirs = None 342 else: 343 szArray = u"" 344 for pszOtherDirs in ppszOtherDirs: 345 if pszOtherDirs: 346 szArray = u"%s%s\0" % (szArray, pszOtherDirs) 347 szArray = szArray + u"\0" 348 pszOtherDirs = ctypes.create_unicode_buffer(szArray) 349 ppszOtherDirs = ctypes.pointer(pszOtherDirs) 350 if _PathFindOnPathW(pszFile, ppszOtherDirs): 351 return pszFile.value 352 return None
353 354 PathFindOnPath = GuessStringType(PathFindOnPathA, PathFindOnPathW) 355 356 # LPTSTR PathGetArgs( 357 # LPCTSTR pszPath 358 # );
359 -def PathGetArgsA(pszPath):
360 _PathGetArgsA = windll.shlwapi.PathGetArgsA 361 _PathGetArgsA.argtypes = [LPSTR] 362 _PathGetArgsA.restype = LPSTR 363 pszPath = ctypes.create_string_buffer(pszPath) 364 return _PathGetArgsA(pszPath)
365
366 -def PathGetArgsW(pszPath):
367 _PathGetArgsW = windll.shlwapi.PathGetArgsW 368 _PathGetArgsW.argtypes = [LPWSTR] 369 _PathGetArgsW.restype = LPWSTR 370 pszPath = ctypes.create_unicode_buffer(pszPath) 371 return _PathGetArgsW(pszPath)
372 373 PathGetArgs = GuessStringType(PathGetArgsA, PathGetArgsW) 374 375 # BOOL PathIsContentType( 376 # LPCTSTR pszPath, 377 # LPCTSTR pszContentType 378 # );
379 -def PathIsContentTypeA(pszPath, pszContentType):
380 _PathIsContentTypeA = windll.shlwapi.PathIsContentTypeA 381 _PathIsContentTypeA.argtypes = [LPSTR, LPSTR] 382 _PathIsContentTypeA.restype = bool 383 return _PathIsContentTypeA(pszPath, pszContentType)
384
385 -def PathIsContentTypeW(pszPath, pszContentType):
386 _PathIsContentTypeW = windll.shlwapi.PathIsContentTypeW 387 _PathIsContentTypeW.argtypes = [LPWSTR, LPWSTR] 388 _PathIsContentTypeW.restype = bool 389 return _PathIsContentTypeW(pszPath, pszContentType)
390 391 PathIsContentType = GuessStringType(PathIsContentTypeA, PathIsContentTypeW) 392 393 # BOOL PathIsDirectory( 394 # LPCTSTR pszPath 395 # );
396 -def PathIsDirectoryA(pszPath):
397 _PathIsDirectoryA = windll.shlwapi.PathIsDirectoryA 398 _PathIsDirectoryA.argtypes = [LPSTR] 399 _PathIsDirectoryA.restype = bool 400 return _PathIsDirectoryA(pszPath)
401
402 -def PathIsDirectoryW(pszPath):
403 _PathIsDirectoryW = windll.shlwapi.PathIsDirectoryW 404 _PathIsDirectoryW.argtypes = [LPWSTR] 405 _PathIsDirectoryW.restype = bool 406 return _PathIsDirectoryW(pszPath)
407 408 PathIsDirectory = GuessStringType(PathIsDirectoryA, PathIsDirectoryW) 409 410 # BOOL PathIsDirectoryEmpty( 411 # LPCTSTR pszPath 412 # );
413 -def PathIsDirectoryEmptyA(pszPath):
414 _PathIsDirectoryEmptyA = windll.shlwapi.PathIsDirectoryEmptyA 415 _PathIsDirectoryEmptyA.argtypes = [LPSTR] 416 _PathIsDirectoryEmptyA.restype = bool 417 return _PathIsDirectoryEmptyA(pszPath)
418
419 -def PathIsDirectoryEmptyW(pszPath):
420 _PathIsDirectoryEmptyW = windll.shlwapi.PathIsDirectoryEmptyW 421 _PathIsDirectoryEmptyW.argtypes = [LPWSTR] 422 _PathIsDirectoryEmptyW.restype = bool 423 return _PathIsDirectoryEmptyW(pszPath)
424 425 PathIsDirectoryEmpty = GuessStringType(PathIsDirectoryEmptyA, PathIsDirectoryEmptyW) 426 427 # BOOL PathIsNetworkPath( 428 # LPCTSTR pszPath 429 # );
430 -def PathIsNetworkPathA(pszPath):
431 _PathIsNetworkPathA = windll.shlwapi.PathIsNetworkPathA 432 _PathIsNetworkPathA.argtypes = [LPSTR] 433 _PathIsNetworkPathA.restype = bool 434 return _PathIsNetworkPathA(pszPath)
435
436 -def PathIsNetworkPathW(pszPath):
437 _PathIsNetworkPathW = windll.shlwapi.PathIsNetworkPathW 438 _PathIsNetworkPathW.argtypes = [LPWSTR] 439 _PathIsNetworkPathW.restype = bool 440 return _PathIsNetworkPathW(pszPath)
441 442 PathIsNetworkPath = GuessStringType(PathIsNetworkPathA, PathIsNetworkPathW) 443 444 # BOOL PathIsRelative( 445 # LPCTSTR lpszPath 446 # );
447 -def PathIsRelativeA(pszPath):
448 _PathIsRelativeA = windll.shlwapi.PathIsRelativeA 449 _PathIsRelativeA.argtypes = [LPSTR] 450 _PathIsRelativeA.restype = bool 451 return _PathIsRelativeA(pszPath)
452
453 -def PathIsRelativeW(pszPath):
454 _PathIsRelativeW = windll.shlwapi.PathIsRelativeW 455 _PathIsRelativeW.argtypes = [LPWSTR] 456 _PathIsRelativeW.restype = bool 457 return _PathIsRelativeW(pszPath)
458 459 PathIsRelative = GuessStringType(PathIsRelativeA, PathIsRelativeW) 460 461 # BOOL PathIsRoot( 462 # LPCTSTR pPath 463 # );
464 -def PathIsRootA(pszPath):
465 _PathIsRootA = windll.shlwapi.PathIsRootA 466 _PathIsRootA.argtypes = [LPSTR] 467 _PathIsRootA.restype = bool 468 return _PathIsRootA(pszPath)
469
470 -def PathIsRootW(pszPath):
471 _PathIsRootW = windll.shlwapi.PathIsRootW 472 _PathIsRootW.argtypes = [LPWSTR] 473 _PathIsRootW.restype = bool 474 return _PathIsRootW(pszPath)
475 476 PathIsRoot = GuessStringType(PathIsRootA, PathIsRootW) 477 478 # BOOL PathIsSameRoot( 479 # LPCTSTR pszPath1, 480 # LPCTSTR pszPath2 481 # );
482 -def PathIsSameRootA(pszPath1, pszPath2):
483 _PathIsSameRootA = windll.shlwapi.PathIsSameRootA 484 _PathIsSameRootA.argtypes = [LPSTR, LPSTR] 485 _PathIsSameRootA.restype = bool 486 return _PathIsSameRootA(pszPath1, pszPath2)
487
488 -def PathIsSameRootW(pszPath1, pszPath2):
489 _PathIsSameRootW = windll.shlwapi.PathIsSameRootW 490 _PathIsSameRootW.argtypes = [LPWSTR, LPWSTR] 491 _PathIsSameRootW.restype = bool 492 return _PathIsSameRootW(pszPath1, pszPath2)
493 494 PathIsSameRoot = GuessStringType(PathIsSameRootA, PathIsSameRootW) 495 496 # BOOL PathIsUNC( 497 # LPCTSTR pszPath 498 # );
499 -def PathIsUNCA(pszPath):
500 _PathIsUNCA = windll.shlwapi.PathIsUNCA 501 _PathIsUNCA.argtypes = [LPSTR] 502 _PathIsUNCA.restype = bool 503 return _PathIsUNCA(pszPath)
504
505 -def PathIsUNCW(pszPath):
506 _PathIsUNCW = windll.shlwapi.PathIsUNCW 507 _PathIsUNCW.argtypes = [LPWSTR] 508 _PathIsUNCW.restype = bool 509 return _PathIsUNCW(pszPath)
510 511 PathIsUNC = GuessStringType(PathIsUNCA, PathIsUNCW) 512 513 # XXX WARNING 514 # PathMakePretty turns filenames into all lowercase. 515 # I'm not sure how well that might work on Wine. 516 517 # BOOL PathMakePretty( 518 # LPCTSTR pszPath 519 # );
520 -def PathMakePrettyA(pszPath):
521 _PathMakePrettyA = windll.shlwapi.PathMakePrettyA 522 _PathMakePrettyA.argtypes = [LPSTR] 523 _PathMakePrettyA.restype = bool 524 _PathMakePrettyA.errcheck = RaiseIfZero 525 526 pszPath = ctypes.create_string_buffer(pszPath, MAX_PATH) 527 _PathMakePrettyA(pszPath) 528 return pszPath.value
529
530 -def PathMakePrettyW(pszPath):
531 _PathMakePrettyW = windll.shlwapi.PathMakePrettyW 532 _PathMakePrettyW.argtypes = [LPWSTR] 533 _PathMakePrettyW.restype = bool 534 _PathMakePrettyW.errcheck = RaiseIfZero 535 536 pszPath = ctypes.create_unicode_buffer(pszPath, MAX_PATH) 537 _PathMakePrettyW(pszPath) 538 return pszPath.value
539 540 PathMakePretty = GuessStringType(PathMakePrettyA, PathMakePrettyW) 541 542 # void PathRemoveArgs( 543 # LPTSTR pszPath 544 # );
545 -def PathRemoveArgsA(pszPath):
546 _PathRemoveArgsA = windll.shlwapi.PathRemoveArgsA 547 _PathRemoveArgsA.argtypes = [LPSTR] 548 549 pszPath = ctypes.create_string_buffer(pszPath, MAX_PATH) 550 _PathRemoveArgsA(pszPath) 551 return pszPath.value
552
553 -def PathRemoveArgsW(pszPath):
554 _PathRemoveArgsW = windll.shlwapi.PathRemoveArgsW 555 _PathRemoveArgsW.argtypes = [LPWSTR] 556 557 pszPath = ctypes.create_unicode_buffer(pszPath, MAX_PATH) 558 _PathRemoveArgsW(pszPath) 559 return pszPath.value
560 561 PathRemoveArgs = GuessStringType(PathRemoveArgsA, PathRemoveArgsW) 562 563 # void PathRemoveBackslash( 564 # LPTSTR pszPath 565 # );
566 -def PathRemoveBackslashA(pszPath):
567 _PathRemoveBackslashA = windll.shlwapi.PathRemoveBackslashA 568 _PathRemoveBackslashA.argtypes = [LPSTR] 569 570 pszPath = ctypes.create_string_buffer(pszPath, MAX_PATH) 571 _PathRemoveBackslashA(pszPath) 572 return pszPath.value
573
574 -def PathRemoveBackslashW(pszPath):
575 _PathRemoveBackslashW = windll.shlwapi.PathRemoveBackslashW 576 _PathRemoveBackslashW.argtypes = [LPWSTR] 577 578 pszPath = ctypes.create_unicode_buffer(pszPath, MAX_PATH) 579 _PathRemoveBackslashW(pszPath) 580 return pszPath.value
581 582 PathRemoveBackslash = GuessStringType(PathRemoveBackslashA, PathRemoveBackslashW) 583 584 # void PathRemoveExtension( 585 # LPTSTR pszPath 586 # );
587 -def PathRemoveExtensionA(pszPath):
588 _PathRemoveExtensionA = windll.shlwapi.PathRemoveExtensionA 589 _PathRemoveExtensionA.argtypes = [LPSTR] 590 591 pszPath = ctypes.create_string_buffer(pszPath, MAX_PATH) 592 _PathRemoveExtensionA(pszPath) 593 return pszPath.value
594
595 -def PathRemoveExtensionW(pszPath):
596 _PathRemoveExtensionW = windll.shlwapi.PathRemoveExtensionW 597 _PathRemoveExtensionW.argtypes = [LPWSTR] 598 599 pszPath = ctypes.create_unicode_buffer(pszPath, MAX_PATH) 600 _PathRemoveExtensionW(pszPath) 601 return pszPath.value
602 603 PathRemoveExtension = GuessStringType(PathRemoveExtensionA, PathRemoveExtensionW) 604 605 # void PathRemoveFileSpec( 606 # LPTSTR pszPath 607 # );
608 -def PathRemoveFileSpecA(pszPath):
609 _PathRemoveFileSpecA = windll.shlwapi.PathRemoveFileSpecA 610 _PathRemoveFileSpecA.argtypes = [LPSTR] 611 612 pszPath = ctypes.create_string_buffer(pszPath, MAX_PATH) 613 _PathRemoveFileSpecA(pszPath) 614 return pszPath.value
615
616 -def PathRemoveFileSpecW(pszPath):
617 _PathRemoveFileSpecW = windll.shlwapi.PathRemoveFileSpecW 618 _PathRemoveFileSpecW.argtypes = [LPWSTR] 619 620 pszPath = ctypes.create_unicode_buffer(pszPath, MAX_PATH) 621 _PathRemoveFileSpecW(pszPath) 622 return pszPath.value
623 624 PathRemoveFileSpec = GuessStringType(PathRemoveFileSpecA, PathRemoveFileSpecW) 625 626 # BOOL PathRenameExtension( 627 # LPTSTR pszPath, 628 # LPCTSTR pszExt 629 # );
630 -def PathRenameExtensionA(pszPath, pszExt):
631 _PathRenameExtensionA = windll.shlwapi.PathRenameExtensionA 632 _PathRenameExtensionA.argtypes = [LPSTR, LPSTR] 633 _PathRenameExtensionA.restype = bool 634 635 pszPath = ctypes.create_string_buffer(pszPath, MAX_PATH) 636 if _PathRenameExtensionA(pszPath, pszExt): 637 return pszPath.value 638 return None
639
640 -def PathRenameExtensionW(pszPath, pszExt):
641 _PathRenameExtensionW = windll.shlwapi.PathRenameExtensionW 642 _PathRenameExtensionW.argtypes = [LPWSTR, LPWSTR] 643 _PathRenameExtensionW.restype = bool 644 645 pszPath = ctypes.create_unicode_buffer(pszPath, MAX_PATH) 646 if _PathRenameExtensionW(pszPath, pszExt): 647 return pszPath.value 648 return None
649 650 PathRenameExtension = GuessStringType(PathRenameExtensionA, PathRenameExtensionW) 651 652 # BOOL PathUnExpandEnvStrings( 653 # LPCTSTR pszPath, 654 # LPTSTR pszBuf, 655 # UINT cchBuf 656 # );
657 -def PathUnExpandEnvStringsA(pszPath):
658 _PathUnExpandEnvStringsA = windll.shlwapi.PathUnExpandEnvStringsA 659 _PathUnExpandEnvStringsA.argtypes = [LPSTR, LPSTR] 660 _PathUnExpandEnvStringsA.restype = bool 661 _PathUnExpandEnvStringsA.errcheck = RaiseIfZero 662 663 cchBuf = MAX_PATH 664 pszBuf = ctypes.create_string_buffer("", cchBuf) 665 _PathUnExpandEnvStringsA(pszPath, pszBuf, cchBuf) 666 return pszBuf.value
667
668 -def PathUnExpandEnvStringsW(pszPath):
669 _PathUnExpandEnvStringsW = windll.shlwapi.PathUnExpandEnvStringsW 670 _PathUnExpandEnvStringsW.argtypes = [LPWSTR, LPWSTR] 671 _PathUnExpandEnvStringsW.restype = bool 672 _PathUnExpandEnvStringsW.errcheck = RaiseIfZero 673 674 cchBuf = MAX_PATH 675 pszBuf = ctypes.create_unicode_buffer(u"", cchBuf) 676 _PathUnExpandEnvStringsW(pszPath, pszBuf, cchBuf) 677 return pszBuf.value
678 679 PathUnExpandEnvStrings = GuessStringType(PathUnExpandEnvStringsA, PathUnExpandEnvStringsW) 680