獲取系統臨時目錄

 

  1. CString VengConfig::GetSysCheckTmpPath(void
  2.     TCHAR TmpPath[MAX_PATH]={0}; 
  3.     LPITEMIDLIST pidl; 
  4.     LPMALLOC pShellMalloc; 
  5.  
  6.     if(SUCCEEDED(SHGetMalloc(&pShellMalloc))) 
  7.     {     
  8.         if(SUCCEEDED(SHGetSpecialFolderLocation(NULL,CSIDL_APPDATA ,&pidl))) 
  9.         { 
  10.             SHGetPathFromIDList(pidl, TmpPath); 
  11.             pShellMalloc->Free(pidl); 
  12.         } 
  13.  
  14.         pShellMalloc->Release(); 
  15.     } 
  16. //創建自己的臨時目錄,如C:\Users\**\AppData\Roaming\veng\SysCheck\ 
  17.     wcscat_s(TmpPath,_T("\\veng")); 
  18.     if(!PathFileExists(TmpPath)) 
  19.     { 
  20.         CreateDirectory(TmpPath,NULL); 
  21.     } 
  22.     wcscat_s(TmpPath,_T("\\SysCheck")); 
  23.     if(!PathFileExists(TmpPath)) 
  24.     { 
  25.         CreateDirectory(TmpPath,NULL); 
  26.     } 
  27.     wcscat_s(TmpPath,_T("\")); 
  28.  
  29.     return TmpPath; 
  30.  

  1. wstring VengFuncConfig::GetCommonAppDataPath(void
  2.  
  3.     wstring cRtValue; 
  4.     cRtValue = VengFuncConfig::ReadCfg(_T("Common AppData"),_T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders")); 
  5.     cRtValue += _T("\\test"); 
  6.  
  7.     if(!PathFileExists(cRtValue.c_str())) 
  8.     { 
  9.         CreateDirectory(cRtValue.c_str(),NULL); 
  10.     } 
  11.  
  12.     cRtValue += _T("\\SysCheck"); 
  13.     if(!PathFileExists(cRtValue.c_str())) 
  14.     { 
  15.         CreateDirectory(cRtValue.c_str(),NULL); 
  16.     } 
  17.     cRtValue += _T("\\"); 
  18.  
  19.     return cRtValue; 

 

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