請問如何用代碼在本地機中查打文件, 並獲得它所以的路徑?

解决方案 »

  1.   

    用API:FindFileUsingFileOpen或 FindFileInTree
    LPSTR FindFileInTree(LPSTR szFile, LPSTR szDir, LPSTR szBuf, int cbBuf);FindFileInTree searches for the specified file in a directory and its subdirectories.ArgumentsszFileSpecifies the name of the file you are trying to locate.szDirSpecifies the top-level directory of the tree structure you want to search.szBufPoints to the destination buffer that will receive the path string.cbBufLength, in bytes, of the destination buffer.Return ValueThe return value is the full path of the first instance of the file. If the file isn't found, the return value is an empty string./////////////////////////////////////////////////////////////////
    LPSTR FindFileUsingFileOpen(LPSTR szFile, LPSTR szBuf, INT cbBuf);FindFileUsingFileOpen locates a file by using the Windows FileOpen function.ArgumentsszFileSpecifies the name of the file you want to find.szBufPoints to the destination buffer that will receive the path string.cbBufLength, in bytes, of the destination buffer.Return ValueThe return value is the full path of the file. If the file isn't found, the return value is an empty string.