C++學習之:文件目錄操作函數

1.創建目錄(API)

  1. BOOL CreateDirectory(LPCTSTR pstrDirName);//pstrDirName是全路徑 

2.刪除目錄(API)

  1. BOOL RemoveDirectory( LPCTSTR lpPathName ); 

3.判斷目錄是否存在(Shell Function)

  1. #include <shlwapi.h> 
  2. #pragma comment(lib, "shlwapi.lib")  
  3. if (PathIsDirectory(_T("d://temp")))  
  4.     AfxMessageBox(_T("存在")); 
  5. else  
  6.     AfxMessageBox(_T("不存在")); 

4.取得當前目錄(API)

  1. DWORD GetCurrentDirectory( DWORD nBufferLength, LPTSTR lpBuffer ); 

5.取得執行文件所在目錄(API)

  1. DWORD GetModuleFileName( HMODULE hModule, LPTSTR lpFilename, DWORD nSize ); 

6.取得功能目錄(Shell Function)

  1. BOOL SHGetSpecialFolderPath( HWND hwndOwner,  LPTSTR lpszPath, int nFolder, BOOL fCreate); 

 

轉載於:http://blog.csdn.net/chaoguodong/article/details/7349022

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章