http://cboard.cprogramming.com/windows-programming/11473-desktop-path.html
char* getDesktopFolderName() //c:\Users\UserName\Desktop\ 반환
{
ULONG ulDataType;
HKEY hKey;
DWORD dwToRead = 100;
static char strPath[100];
char strKey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
//cannot use in unicode, use multi-byte code http://blog.naver.com/stormor/70171786787
RegOpenKeyEx(HKEY_CURRENT_USER,
strKey, //여기 unicode 안됨
0,KEY_READ,&hKey);
RegQueryValueEx(hKey,"Desktop",NULL,
&ulDataType,(LPBYTE)strPath,&dwToRead);
strPath[dwToRead] = '\0';
RegCloseKey(hKey);
return strPath;
//http://cboard.cprogramming.com/windows-programming/11473-desktop-path.html
}
이거 말고도 MFC 방법으로 있긴 함
char* getDesktopFolderName() //c:\Users\UserName\Desktop\ 반환
{
//http://stackoverflow.com/questions/17933917/get-the-users-desktop-folder-using-windows-api
//mfc함수이고 CSIDL_로 보면 경로들이 존나많다
//멀티 바이트로 안하면 (LPWSTR)desktopPath 해야됨..근데 멀티바이트 아니면 결과 안나옴
SHGetSpecialFolderPath(HWND_DESKTOP,myPathArray,CSIDL_DESKTOP,0);
//SHGetSpecialFolderPath(HWND_DESKTOP,(LPWSTR)desktopPath,CSIDL_DESKTOP,0);
return myPathArray;
}
'컴퓨터 과학 & 영상처리 관련 > C / C++' 카테고리의 다른 글
fscanf 대신 strtok으로 문자열 나누기, C++ tokenizer (0) | 2015.07.05 |
---|---|
C++ int* i = new int[]로 동적할당 시 메모리가 할당되는가? (0) | 2014.11.22 |
C++ process kill (0) | 2014.10.24 |
C++ visual studio 에서 소스 감쌀 때 C# #region 처럼 사용 시 (0) | 2014.03.31 |
c언어 파일 존재 여부 확인 함수 access() (0) | 2014.03.20 |