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

Source Code for Module winappdbg.win32.shlwapi

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