Jump to content

Help with shlwapi DLL call


Recommended Posts

Can someone point out what it takes to get the PathMatchSpec or PathMatchSpecW function working?

$str = "C:\CONFIG.SYS"
;$str = "C:\CONFIG.SYS" & Chr(0)
$mask = "*.SYS"
;$mask = "*.SYS" & Chr(0) & Chr(0)

If DllCall("shlwapi.dll","int","PathMatchSpecW","wstr",$str,"wstr",$mask) Then Beep(800,100)

Thanks.

Link to comment
Share on other sites

What a dumb function*.

DllCall() returns an array.

$sFile = "C:\CONFIG.SYS"
$sFileType = "*.SYS"


$aCall = DllCall("shlwapi.dll", "int", "PathMatchSpecW", "wstr", $sFile, "wstr", $sFileType)
; error checking missing here

If $aCall[0] Then Beep(800, 100)

$sFile = "C:\CONFIG.SYS"
If StringRegExpReplace($sFile, ".*\.", "") = "SYS" Then Beep(800, 100)

edit:

* for use with AutoIt

Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Well, it does what it does, matches a string against a DOS filename filter.

StringRegExp's (like the one above) are bogging down the last test version I posted in this thread: FileListToArray

I just thought I'd see if a DLL call could get any where near competing as far as performance. It doesn't. The PathMatchSpecEx function looked interesing, it accepts a semi-colon delimited string containing multiple filename filters. Unfortunately, it is Vista only (and likely still slower than a complex StringRegExp that uses alternation).

Edit: By the way, thank you for the answer. MSDN said PathMatchSpecExW returned an integer, I'd overlooked that my return was actually coming from DLLCall. :) It was 1:30am and I'm not sure both my brain cells were firing at the time.

Edited by Spiff59
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...