パスからドライブを取得する
AnsiString strDrvPath;
strDrvPath = ExtractFileDrive (ParamStr (0));
実行ファイルのパスのみを取得する
AnsiString strDirPath;
strDirPath = ExtractFilePath (ParamStr (0));
フォルダが存在しているかを調べる
AnsiString strDir;
bool boolExist;
boolExist = DirectoryExists (strDir);
Windows フォルダを取得する
AnsiString strWinDir;
char cPath[MAX_PATH + 1];
ZeroMemory (cPath, MAX_PATH + 1);
GetWindowsDirectory (cPath, MAX_PATH);
strWinDir = (AnsiString)cPath;
Program Files フォルダを取得する
LPSTR pszPathBuffer[MAX_PATH + 1];
DWORD dwRetVal = 0;
HKEY hkey;
static LPCTSTR g_pcszMain = _T("Software\\Microsoft\\Windows\\CurrentVersion");
ZeroMemory (pszPathBuffer, MAX_PATH + 1);
if (RegOpenKey (HKEY_LOCAL_MACHINE, g_pcszMain, &hkey) == ERROR_SUCCESS){
DWORD dwType = REG_EXPAND_SZ;
dwRetVal = MAX_PATH;
TCHAR szPath[MAX_PATH];
if (RegQueryValueEx (hkey, _T("ProgramFilesPath"), 0, &dwType, (LPBYTE)szPath, &dwRetVal) == ERROR_SUCCESS){
dwRetVal = ExpandEnvironmentStrings (szPath, pszPathBuffer, MAX_PATH);
}
RegCloseKey (hkey);
}
System フォルダを取得する
AnsiString strWinDir;
char cPath[MAX_PATH + 1];
ZeroMemory (cPath, MAX_PATH + 1);
GetSystemDirectory (cPath, MAX_PATH);
strWinDir = (AnsiString)cPath;
Current フォルダを取得する
AnsiString strWinDir;
char cPath[MAX_PATH + 1];
ZeroMemory (cPath, MAX_PATH + 1);
GetCurrentDirectory (cPath, MAX_PATH);
strWinDir = (AnsiString)cPath;
Temporary フォルダを取得する
AnsiString strWinDir;
char cPath[MAX_PATH + 1];
ZeroMemory (cPath, MAX_PATH + 1);
GetTempPath (cPath, MAX_PATH);
strWinDir = (AnsiString)cPath;
各種個人設定フォルダを取得する
AnsiString strDir;
char cPath[MAX_PATH + 1];
ITEMIDLIST *pidl;
AnsiString strDir;
char cPath[MAX_PATH + 1];
ITEMIDLIST *pidl;
/*
CSIDL_DESKTOP
CSIDL_INTERNET
CSIDL_PROGRAMS
CSIDL_CONTROLS
CSIDL_PRINTERS
CSIDL_PERSONAL
CSIDL_FAVORITES
CSIDL_STARTUP
CSIDL_RECENT
CSIDL_SENDTO
CSIDL_BITBUCKET
CSIDL_STARTMENU
CSIDL_DESKTOPDIRECTORY
CSIDL_DRIVES
CSIDL_NETWORK
CSIDL_NETHOOD
CSIDL_FONTS
CSIDL_TEMPLATES
CSIDL_COMMON_STARTMENU
CSIDL_COMMON_PROGRAMS
CSIDL_COMMON_STARTUP
CSIDL_COMMON_DESKTOPDIRECTORY
CSIDL_APPDATA
CSIDL_PRINTHOOD
CSIDL_LOCAL_APPDATA
CSIDL_ALTSTARTUP
CSIDL_COMMON_ALTSTARTUP
CSIDL_COMMON_FAVORITES
CSIDL_INTERNET_CACHE
CSIDL_COOKIES
CSIDL_HISTORY
CSIDL_COMMON_APPDATA
CSIDL_WINDOWS
CSIDL_SYSTEM
CSIDL_PROGRAM_FILES
CSIDL_MYPICTURES
CSIDL_PROFILE
CSIDL_PROGRAM_FILES_COMMON
CSIDL_COMMON_TEMPLATES
CSIDL_COMMON_DOCUMENTS
CSIDL_COMMON_ADMINTOOLS
CSIDL_ADMINTOOLS
CSIDL_FLAG_CREATE
CSIDL_FLAG_DONT_VERIFY
CSIDL_FLAG_MASK
*/
if (!SHGetSpecialFolderLocation (0, CSIDL_PERSONAL, &pidl)){
if (SHGetPathFromIDList (pidl, iPath)){
strDir = (AnsiString)iPath;
}
}
最終更新日 2007-04-12 00:32:57
コメント