Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
pathmatchspec (shlwapi)
 
.
Summary
PathMatchSpec - Searches a string using a Microsoft MS-DOS wildcard match type.

C# Signature:

[DllImport("shlwapi.dll", CharSet=CharSet.Auto)]
static extern bool PathMatchSpec([In] String pszFileParam, [In] String pszSpec);

VB.NET Signature:

''' <summary>
''' Searches a string using a Microsoft MS-DOS wildcard match type.
''' </summary>
''' <param name="pszFile">A pointer to a null-terminated string of maximum length MAX_PATH that contains the path to be searched.</param>
''' <param name="pszSpec">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".</param>
''' <returns>Returns TRUE if the string matches, or FALSE otherwise.</returns>
<DllImport("shlwapi.dll", EntryPoint:="PathMatchSpecW",  SetLastError:=True, CharSet:=CharSet.Unicode)> _
Public Function PathMatchSpec(<MarshalAs(UnmanagedType.LPTStr)>pszFile As String, _
             <MarshalAs(UnmanagedType.LPTStr)>pszSpec As String) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function

VB Signature:

    Private Declare Auto Function PathMatchSpec Lib "shlwapi" _
    (ByVal pszFileParam As String, _
     ByVal pszSpec As String) As Boolean

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

C# Example

if(PathMatchSpec("C:\\test.txt", "*.txt"))
{
   // This is text file.
}

VB.NET Example

Private Function MatchSpec(ByVal sFile As String, ByVal sSpec As String) As Boolean

    Return PathMatchSpec(sFile, sSpec)

End Function

VB Example

Private Function MatchSpec(ByVal sFile As String, ByVal sSpec As String) As Boolean

    MatchSpec = PathMatchSpec(sFile, sSpec)

End Function

Alternative Managed API:

Do you know one? Please contribute it!

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions