A better method for finding the installation dir on Windows.

Now works properly for _all_ Windows versions!
This commit is contained in:
2003-06-11 20:26:35 +00:00
parent 8ffd18a56c
commit ed6885d728

View File

@@ -49,47 +49,24 @@
#include "BKE_utildefines.h" /* FILE_MAXDIR + FILE_MAXFILE */ #include "BKE_utildefines.h" /* FILE_MAXDIR + FILE_MAXFILE */
int BLI_getInstallationDir( char * str ) { int BLI_getInstallationDir( char * str ) {
LONG lresult; char dir[FILE_MAXDIR];
HKEY hkey = 0; char file[FILE_MAXFILE];
LONG type;
char buffer[FILE_MAXDIR+FILE_MAXFILE];
DWORD size;
size = sizeof(buffer); GetModuleFileName(NULL,str,FILE_MAXDIR+FILE_MAXFILE);
BLI_split_dirfile(str,dir,file);
lresult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\BlenderFoundation\\Blender", 0, strcpy(str,dir);
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; return 1;
} }
else
return 0;
}
void RegisterBlendExtension(char * str) { void RegisterBlendExtension(char * str) {
LONG lresult; LONG lresult;
HKEY hkey = 0; HKEY hkey = 0;
DWORD dwd = 0; DWORD dwd = 0;
char *dir;
char buffer[128]; 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, lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, "blendfile\\shell\\open\\command", 0,
"", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd); "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);