Molecular Modeling Software
リビジョン | ef3c3e6802893684d6c38a45fd4afe8816763aec (tree) |
---|---|
日時 | 2014-04-26 11:58:35 |
作者 | toshinagata1964 <toshinagata1964@a2be...> |
コミッター | toshinagata1964 |
MSW: document_home is modified to use the Windows API, instead of hard-coded path (which was wrong on Windows Vista and later)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@536 a2be9bc6-48de-4e38-9406-05402d4bc13c
@@ -1874,16 +1874,24 @@ MyAppCallback_getHomeDir(void) | ||
1874 | 1874 | return (s == NULL ? NULL : strdup(s)); |
1875 | 1875 | } |
1876 | 1876 | |
1877 | +#if __WXMSW__ | |
1878 | +#include <Shlobj.h> | |
1879 | +#endif | |
1880 | + | |
1877 | 1881 | char * |
1878 | 1882 | MyAppCallback_getDocumentHomeDir(void) |
1879 | 1883 | { |
1880 | - char *s; | |
1881 | 1884 | #if __WXMSW__ |
1882 | - char *ss; | |
1883 | - s = getenv("USERPROFILE"); | |
1884 | - asprintf(&ss, "%s\\My Documents", s); | |
1885 | - return ss; | |
1885 | + char appData[MAX_PATH * 2]; | |
1886 | + HRESULT hResult; | |
1887 | + hResult = SHGetFolderPathA(NULL, CSIDL_PERSONAL, NULL, 0, appData); | |
1888 | + if (hResult == S_OK) { | |
1889 | + return strdup(appData); | |
1890 | + } else { | |
1891 | + return MyAppCallback_getHomeDir(); | |
1892 | + } | |
1886 | 1893 | #else |
1894 | + char *s; | |
1887 | 1895 | s = getenv("HOME"); |
1888 | 1896 | return (s == NULL ? NULL : strdup(s)); |
1889 | 1897 | #endif |