|
-
May 13th, 2008, 12:25 AM
#1
Thread Starter
Hyperactive Member
PathMatchSpec Alternative
How can I use PathMatchSpec? Thanks
Last edited by abazabam; May 13th, 2008 at 04:36 PM.
-
May 13th, 2008, 01:01 AM
#2
Re: PathMatchSpec Alternative
I think you may have a problem with the API definition or the use of a Boolean to return the value from the API. This works ok for me
Code:
Private Declare Function PathMatchSpec Lib "shlwapi.dll" Alias "PathMatchSpecA" _
(ByVal pszfile As String, _
ByVal pszspec As String) As Long
Private Sub Command1_Click()
Dim strFile As String
Dim strSpec As String
Dim lngReturn As Long
strFile = "c:\testdir\test.txt"
strSpec = "*.txt"
lngReturn = PathMatchSpec(strFile, strSpec)
If lngReturn <> 0 Then
Debug.Print strSpec & " exists in " & strFile
Else
Debug.Print strSpec & " does not exist in " & strFile
End If
strSpec = "*.doc"
lngReturn = PathMatchSpec(strFile, strSpec)
If lngReturn <> 0 Then
Debug.Print strSpec & " exists in " & strFile
Else
Debug.Print strSpec & " does not exist in " & strFile
End If
End Sub
-
May 13th, 2008, 01:27 AM
#3
Thread Starter
Hyperactive Member
Re: PathMatchSpec Alternative
Well, it does work but I have a file with a very long path that it doesn't work on. If you want to know how I was able to get the file path so long, the folder was originally on the desktop and then I moved it into 3 folders in My Documents. If I right-click on the file, it doesn't even have the properties option. I'm just trying to make sure it can handle everything so please don't tell me to move the folder to a shorter path or anything like that. Thanks
-
May 13th, 2008, 01:34 AM
#4
Thread Starter
Hyperactive Member
Re: PathMatchSpec Alternative
Sorry, I think I just need to do a little more research on this. Can you please delete this topic? I think I'm just getting mixed up here. Thanks for your code Doogle.
-
May 13th, 2008, 01:43 AM
#5
Re: PathMatchSpec Alternative
You have to be aware that the path cannot exceed MAX_PATH (260) characters in order to use that API.
Is there any particular reason why you can't use InStr or InstRev ?
-
May 13th, 2008, 02:15 AM
#6
Thread Starter
Hyperactive Member
Re: PathMatchSpec Alternative
Actually, I just got mixed up with some other part of my code. Thanks for the info. I would've use InStr but I wasn't sure exactly how PathMatchSpec worked so I thought maybe it was a lot more different from InStr.
-
May 13th, 2008, 02:37 AM
#7
Re: PathMatchSpec Alternative
Thanks for the PM abazabam, but we prefer not to delete threads once started (unless they violate our AUP or are duplicates).
Even though the OP may have found their own solutions, others may experience the same or similiar situation in which case, the resolution could benefit them.
In fact, I ask that you edit your first post, and reenter the originial question.
Thanks.
-
May 13th, 2008, 04:30 PM
#8
Thread Starter
Hyperactive Member
Re: PathMatchSpec Alternative
I don't think anyone else can have the same problem because I got mixed up and what I said in my original post wasn't true. Maybe I'll just change it to something that works. Can you please change the title to "PathMatchSpec" and delete my other posts in this page? Thanks
Last edited by abazabam; May 13th, 2008 at 04:35 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|