October 24, 200421 yr Is there a way to detect the location of the fs9.cfg automatically by C gauges? I can read it with e.g. GetPrivateProfileString if I know the exact path, no problem. But how to get that path? Or, are there global variables that store that "user data" path somewhere?Arne Bartels
October 24, 200421 yr There's shell variable called "USERPROFILE" which contains the path you need but I'm pretty sure that it only exists in Windows XP so it won't be very helpful.
October 24, 200421 yr OK, found it myself:#include ...char appdata[MAX_PATH+1]="";char value[255+1]="";...SHGetSpecialFolderPath(NULL,appdata,CSIDL_APPDATA,FALSE);strcat(appdata,"MicrosoftFS9fs9.cfg"); ...GetPrivateProfileString("PANELS","IMAGE_QUALITY","",value,sizeof(value)-1,appdata);link shell32.lib.Possibly the exename has to be used, not "fs9.cfg" hardwired. If the exe is renamed, the .cfg file uses this new name.Arne BartelsP.S. checked with XP SP2 and W98SE
October 24, 200421 yr Wildes Suchen hilft manchmal. Erst hatte ich Appdata als Begriff gefunden, bei MSDN fiel mir dann irgendwann "SHGetSpecialFolderPath" vor die F
October 24, 200421 yr I was going to suggest you guys get new keyboards!:-lolW. Sieffert Bill Sieffert
October 24, 200421 yr You can also scan the software keys in the Windows registry - I haven't looked but I'm pretty sure that the install folder is in the LOCAL_MACHINE/software hive and the path to the CFG is in the LOCAL_USER/software hive (since each user has a personal copy of the CFG file).That should work with Windows 2000 or Windows XP.
October 26, 200421 yr In adition a check if the exe name/cfg name is NOT fs9:#include #include ... char appdata[MAX_PATH+1] = "", exename[MAX_PATH+1] = "", *helper = NULL;... //get full exe pathname GetModuleFileName(NULL,exename,MAX_PATH); //cut path helper=strrchr(exename,''); if(helper) sprintf(exename,"%s",helper+1); //cut .exe suffix helper=strstr(exename,".exe"); if(helper) *helper=0; //get FS9.cfg path, first appdata, then rest SHGetSpecialFolderPath(NULL,appdata,CSIDL_APPDATA,FALSE); sprintf(appdata,"%sMicrosoftFS9%s.cfg",appdata,exename); ...Arne Bartels
Create an account or sign in to comment