udfPathMatchSpec
bln udfPathMatchSpecA (str, str)
bln udfPathMatchSpecW (str, str)
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfPathMatchSpecA (strPath, strWild)
Return DllCall (DirWindows (1) : "SHLWAPI.DLL", long : "PathMatchSpecA", lpstr : strPath, lpstr : strWild)
;..........................................................................................................................................
; Searches a string using a Microsoft MS-DOS wildcard match type.
; Returns @TRUE if strings match or @FALSE if not.
;
; (c)Detlev Dalitz.20010807.
;..........................................................................................................................................
;   Syntax
;   Copy
;    BOOL PathMatchSpec(
;     __in  LPCSTR pszFile,
;     __in  LPCSTR pszSpec
;   );
;   Parameters
;   pszFile [in]
;   Type: LPCSTR
;
;   A pointer to a null-terminated string of maximum length MAX_PATH that contains the path to be searched.
;
;   pszSpec [in]
;   Type: LPCSTR
;
;   A pointer to a null-terminated string of maximum length MAX_PATH that contains the file type for which to search. For example, to test whether pszFile is a .doc file, pszSpec should be set to "*.doc".
;
;   Return value
;   Type: BOOL
;
;   Returns TRUE if the string matches, or FALSE otherwise.
;..........................................................................................................................................
; Note: There might be a quirk with the function PathMatchSpec, when using a filename, which contains one or more semicolons.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfPathMatchSpecW (strPath, strWild)
Return DllCall (DirWindows (1) : "SHLWAPI.DLL", long : "PathMatchSpecW", lpwstr : ChrStringToUnicode (strPath), lpwstr : ChrStringToUnicode (strWild))
;..........................................................................................................................................
; Searches a string using a Microsoft MS-DOS wildcard match type.
; Returns @TRUE if strings match or @FALSE if not.
;
; (c)Detlev Dalitz.20120601.
;..........................................................................................................................................
;   Syntax
;   Copy
;    BOOL PathMatchSpec(
;     __in  LPCSTR pszFile,
;     __in  LPCSTR pszSpec
;   );
;   Parameters
;   pszFile [in]
;   Type: LPCSTR
;
;   A pointer to a null-terminated string of maximum length MAX_PATH that contains the path to be searched.
;
;   pszSpec [in]
;   Type: LPCSTR
;
;   A pointer to a null-terminated string of maximum length MAX_PATH that contains the file type for which to search. For example, to test whether pszFile is a .doc file, pszSpec should be set to "*.doc".
;
;   Return value
;   Type: BOOL
;
;   Returns TRUE if the string matches, or FALSE otherwise.
;..........................................................................................................................................
; Note: There might be a quirk with the function PathMatchSpec, when using a filename, which contains one or more semicolons.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test.

strPath1 = "Z:\Test\File.txt"
strPath2 = "Z:\Test\File.bmp"
strPath3 = "*.txt"
strPath4 = "*.bmp"
strPath5 = "Z:\Test\File"

blnResult11 = udfPathMatchSpecA (strPath1, strPath3) ; @TRUE.
blnResult12 = udfPathMatchSpecA (strPath1, strPath4) ; @FALSE.

blnResult21 = udfPathMatchSpecW (strPath1, strPath3) ; @TRUE.
blnResult22 = udfPathMatchSpecW (strPath1, strPath4) ; @FALSE.

blnResult32 = udfPathMatchSpecW (strPath2, strPath4) ; @TRUE.
blnResult33 = udfPathMatchSpecW (strPath5, strPath2) ; @FALSE.

:CANCEL
Exit