Path related APIs

Source: Internet
Author: User
Header file: shlwapi. H, some of which have repeated function functions. I am adding red to the commonly used functions. Bool pathfileexists (lpctstr lpszpath)Function: Check whether the file/path exists. Lptstr pathfindfilename (lpctstr ppath)Function: Obtain the file name in the path, for example, pathfilefilename ("C: // program files // file.txt") = program file.txt ". If the path does not contain a file name, the returned value is the lowest directory name. Lptstr pathfindextension (lpctstr ppath)Function: Obtain the file extension in a path or file name, for example, pathfindextension (file.txt ") = .txt" Lptstr pathfindnextcomponent (lpctstr pszpath)Example: pathfindnextcomponent ("C: // program files/directory") = "program files/directory" pathfindnextcomponent ("C: // program files") = "Program Files" Bool pathfindonpath (in out lptstr pszfile, in lpctstr * ppszotherdirs)Function: Search for files in a specified directory. Parameters:PszfileThe file name to be searched. Make sure that the pszfile size is sufficient to accommodate max_path characters. If the specified file can be found, this parameter returns the full path of the file.

 

PpszotherdirsThis parameter is the list of directories to be searched for first. It can be null. If it is null, the function will be searched in the system directory, the current directory, and the directory set by path.Lptstr pathgetargs (lpctstr pszpath)Function: Analyze parameters from the path, for example, lptstr pszparam = pathgetargs (notepad.exe C: // temp.txt ") pszparam returns" C: // temp.txt"Int pathgetdrivenumber (lpctstr lpsz)Function: analyze the return value of the drive letter from the path: 0-25 is returned for success, indicating (a-z).-1 is returned for failure.Bool pathiscontenttype (maid, maid)Function: Check whether the file is specifiedContenttypeFor example, pathiscontenttype (export hello.txt "," text/plain ") returns truepathiscontenttype (export hello.txt", "image/GIF") and falseBool pathisdirectory (lpctstr pszpath)Function: Check whether the path is a valid directory. Note: The path cannot contain the file name.Bool pathisfilespec (lpctstr lpszpath)Function: Check whether the path contains the ':' and '/' delimiters.Bool pathishtmlfile (lpctstr pszfile)Function: Check whether the file is an HTML file.Bool pathisprefix (in maid, In maid)Function: Check whether the path contains the specified prefix, for example, "drive letter: //", ".. //",". // "pathisprefix (" C: // "," c: // hello.txt ") returns trueBool pathisrelative (lpctstr lpszpath)Function: Check whether the path is relative.Bool pathisroot (lpctstr ppath)Function: Check whether the path is the root directory.Bool pathissameroot (maid, maid );Function: Compares whether two paths are on the same drive letter.Bool pathisunc (lpctstr pszpath );Function: determines whether the path is in UNC format.Bool pathisurl (in lpctstr pszpath );Function: determines whether the path is a URL.BoolPathmatchspec(Lpctstr pszfileparam, lpctstr pszspec)Function: Use a wildcard (* and? To compare another string, for example:Pathmatchspec("Http://news.sina.com.cn", "* Sina.com *") returns truePathmatchspec("C: // hello.txt", "*. txt") returns true.Void pathremoveargs (lptstr pszpath );Function: delete parameters contained in a path.Lptstr pathremovebackslash (lptstr lpszpath );Function: Delete unnecessary '/' characters at the end of a path.Void pathremoveblanks (lptstr lpszstring );Function: deletes spaces at the beginning and end of a string.Void pathremoveextension (lptstr pszpath );Function: delete the file extension following the path.Bool pathremovefilespec (lptstr pszpath );Function: delete the file name and '/' symbol after the path. This function can analyze the path of a file. For example, szpath = "C: // windows // system32 // nt. dll"; after pathremovefilespec (szpath) is called, szpath = "C: // windows // System32"Bool pathrenameextension (in out lptstr pszpath, lpctstr pszext );Function: Replace the file extension after the path. If pszpath does not have an extension, the new extension will be added. Pszpath requires a space of at least max_path characters. The new extension of pszext must contain.Void pathstrippath (lptstr pszpath );Function: extract the file name from the path. For example, pathstrippath ("C: // test // hello.txt") => hello.txtBool pathstriptoroot (lptstr srorot );Function: analyzes the drive letter from the path.Void pathunquotespaces (lptstr lpsz );Function: Obtain the path from the path with quotation marks. Example: szpath = "/" C: // program files/"" pathunquotespaces (szpath) => szpath = "C: // Program Files "with another path-related function provided by imagehlpBool searchtreeforfile (In lpstr rootpath,In lpstr inputpathname,Out lpstr outputpathbuffer);Function: searches for files in the specified directory tree.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.