Win32Files

BOOL CopyFile(
    LPCTSTR lpExistingFileName,
    LPCTSTR lpNewFileName,
    BOOL bFailIfExists)


Copies an existing file to a new file.


BOOL CreateDirectory(
    LPCTSTR lpPathName)


Creates a new directory.


BOOL DeleteFile(
    LPCTSTR lpFileName)


Deletes an existing file.


BOOL FindClose(
    HANDLE hObject)


Closes a file search handle opened by the FindFirstFile function.


HANDLE FindFirstFile(
    LPCTSTR lpFileName,
    LPWIN32_FIND_DATA lpFindFileData)


Searches a directory for a file or subdirectory with a name that matches a specific name.


BOOL FindNextFile(
    HANDLE hFindFile,
    LPWIN32_FIND_DATA lpFindFileData)


Continues a file search from a previous call to the FindFirstFile function.


BOOL MoveFile(
    LPCTSTR lpExistingFileName,
    LPCTSTR lpNewFileName)


Moves an existing file or a directory, including its children.


BOOL PathCanonicalize(
    LPTSTR lpszDst,
    LPCTSTR lpszSrc)


Canonicalizes a path.


LPTSTR PathCombine(
    LPTSTR lpszDest,
    LPCTSTR lpszDir,
    LPCTSTR lpszFile)


Concatenates two strings that represent properly formed paths into one path, as well as any relative path pieces. The directory path should be in the form of A:, B:, Ö, Z:. The file path should be in a correct form that represents the file part of the path. The file path must not be null, and if it ends with a backslash, the backslash will be maintained.


BOOL PathIsURL(
    LPCTSTR pszPath)


Tests a given string to determine if it conforms to a valid URL format.


VOID PathQuoteSpaces(
    LPTSTR pszPath)


Searches a path for spaces. If spaces are found, the entire path is enclosed in quotation marks.


BOOL PathRelativePathTo(
    LPTSTR pszPath,
    LPCTSTR pszFrom,
    DWORD dwAttrFrom,
    LPCTSTR pszTo,
    DWORD dwAttrTo)


This function takes a pair of paths and generates a relative path from one to the other. The paths do not have to be fully-qualified, but they must have a common prefix, or the function will fail and return FALSE.
For example, let the starting point, pszFrom, be"C:\FolderA\FolderB\FolderC", and the ending point, pszTo, be"C:\FolderA\FolderD\FolderE". PathRelativePathTo will return the relative path from pszFrom to pszTo as:"..\..\FolderD\FolderE". You will get the same result if you set pszFrom to "\FolderA\FolderB\FolderC"and pszTo to"\FolderA\FolderD\FolderE". On the other hand, "C:\FolderA\FolderB"and "A:\FolderA\FolderD"do not share a common prefix, and the function will fail.


VOID PathRemoveArgs(
    LPTSTR pszPath)


Removes any arguments from a given path.


LPTSTR PathRemoveBackslash(
    LPTSTR pszPath)


Removes the trailing backslash from a given path. Returns the address of the NULL that replaced the backslash, or the address of the last character if itís not a backslash.


VOID PathRemoveBlanks(
    LPTSTR lpszString)


Removes all leading and trailing spaces from a string.


VOID PathRemoveExtension(
    LPTSTR pszPath)


Removes the file extension from a path, if there is one.


BOOL PathRemoveFileSpec(
    LPTSTR pszPath)


Removes the trailing file name and backslash from a path, if it has them.


BOOL PathRenameExtension(
    LPTSTR pszPath,
    LPCTSTR pszExt)


Replaces the extension of a file name with a new extension. If the file name does not contain an extension, the extension will be attached to the end of the string.


BOOL RemoveDirectory(
    LPCTSTR lpPathName)


Deletes an existing empty directory.


Copyright © 2006 Shawn (L. Spiro) Wilcoxen