diff options
author | Simon Clitherow <aphex@nildram.co.uk> | 2003-06-12 00:26:35 +0400 |
---|---|---|
committer | Simon Clitherow <aphex@nildram.co.uk> | 2003-06-12 00:26:35 +0400 |
commit | ed6885d72891c63c39bb63a0eb936b454fef753c (patch) | |
tree | 27912acde82d73c113b60534ff7c78e8010202e4 /source/blender/blenlib/intern/winstuff.c | |
parent | 8ffd18a56c41e41e9a486b911194a3d55b9d9b30 (diff) |
A better method for finding the installation dir on Windows.
Now works properly for _all_ Windows versions!
Diffstat (limited to 'source/blender/blenlib/intern/winstuff.c')
-rw-r--r-- | source/blender/blenlib/intern/winstuff.c | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index 813e2942bc9..59212ee444c 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -49,25 +49,15 @@ #include "BKE_utildefines.h" /* FILE_MAXDIR + FILE_MAXFILE */ int BLI_getInstallationDir( char * str ) { - LONG lresult; - HKEY hkey = 0; - LONG type; - char buffer[FILE_MAXDIR+FILE_MAXFILE]; - DWORD size; + char dir[FILE_MAXDIR]; + char file[FILE_MAXFILE]; - size = sizeof(buffer); - - lresult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\BlenderFoundation\\Blender", 0, - KEY_ALL_ACCESS, &hkey); - - if (lresult == ERROR_SUCCESS) { - lresult = RegQueryValueEx(hkey, "Inst_Dir", 0, NULL, (LPBYTE)buffer, &size); - strcpy(str, buffer); - RegCloseKey(hkey); - return 1; - } - else - return 0; + GetModuleFileName(NULL,str,FILE_MAXDIR+FILE_MAXFILE); + BLI_split_dirfile(str,dir,file); + + strcpy(str,dir); + + return 1; } @@ -75,21 +65,8 @@ void RegisterBlendExtension(char * str) { LONG lresult; HKEY hkey = 0; DWORD dwd = 0; - char *dir; char buffer[128]; - /* Add installation dir to registry --aphex */ - - strncpy(dir, str, strlen(str)-11); - - lresult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\BlenderFoundation\\Blender", 0, - "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd); - - if (lresult == ERROR_SUCCESS) { - lresult = RegSetValueEx(hkey, "Inst_Dir", 0, REG_SZ, dir, strlen(dir)+1); - RegCloseKey(hkey); - } - lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, "blendfile\\shell\\open\\command", 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd); |