Prev: add maskedbox to form on runtime
Next: xy scatter plot
From: David Kerber on 21 Apr 2010 08:37 I'm having trouble reading values from a .ini file on windows 7 x64. Specifically, changes that I make in a text editor are not appearing when I try to read them in through my application. Other settings that have been in the .ini file for ages will read in just fine; just not the new entries. When I try to read the new entries, I'm just getting back my default value, so it's not reading from the .ini file. I have made the changes in both copies of my .ini file: the one in c: \windows, and the one in my appdata\local\virtualstore\windows folder, and while changes in either one of these appear in the other in the text editor, they will not show up when I read them in from my app, even though long-standing entries work fine. Is there a 3rd copy of the .ini file around somewhere that I can't find? I did both a registry search (which turned up nothing, as expected), and a HD search which turned up only those two listed above. I'm sure it's something to do with win7's virtualization, but can't figure out how to get around it; can somebody tell me what I'm missing? Is there some caching I need to work around? My code I'm usiing is: labelName = GetIniString("WebSIRA", "OspFullLabel", "", "WinTM.ini") and GetIniString is: Function GetIniString$(AppName$, KeyName$, Default$, IniFileName$) 'calls windows API call to get the desired string from the specified ..ini file ReturnString$ = Space(255) BuffSize& = Len(ReturnString$) StringLen& = GetPrivateProfileString&(AppName$, KeyName$, Default$, ReturnString$, BuffSize&, IniFileName$) GetIniString$ = Left$(ReturnString$, StringLen&) End Function Thanks! D
From: MikeD on 21 Apr 2010 09:25 "David Kerber" <ns_dkerber(a)ns_warrenrogersassociates.com> wrote in message news:MPG.2638bb89fcf66c9c9896f4(a)news.onecommunications.net... > I'm having trouble reading values from a .ini file on windows 7 x64. > Specifically, changes that I make in a text editor are not appearing > when I try to read them in through my application. Other settings that > have been in the .ini file for ages will read in just fine; just not the > new entries. When I try to read the new entries, I'm just getting back > my default value, so it's not reading from the .ini file. > > I'm sure it's something to do with win7's virtualization, but can't > figure out how to get around it; can somebody tell me what I'm missing? > Is there some caching I need to work around? Don't be so sure of that. > My code I'm usiing is: > > labelName = GetIniString("WebSIRA", "OspFullLabel", "", "WinTM.ini") > > > and GetIniString is: > > > Function GetIniString$(AppName$, KeyName$, Default$, IniFileName$) > 'calls windows API call to get the desired string from the specified > .ini file > ReturnString$ = Space(255) > BuffSize& = Len(ReturnString$) > StringLen& = GetPrivateProfileString&(AppName$, KeyName$, Default$, > ReturnString$, BuffSize&, IniFileName$) > GetIniString$ = Left$(ReturnString$, StringLen&) > > End Function Sounds as if you're either reading the wrong file or the file is in a folder for which there is only read access (so therefore changes aren't being written), which is a possibility under Vista and Win7 even for members of the Administrators group. Provide a full path to the INI file AND make sure it's a folder to which the user has both read and write permissions. But do NOT hard-code the path. Use SHGetSpecialFolderPath to obtain the path. If you need example code for calling that function, search the newsgroups at www.google.com or another search engine. -- Mike
|
Pages: 1 Prev: add maskedbox to form on runtime Next: xy scatter plot |