Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
anyone knows how Vista is handling the WriteProfileString call? The MSDN help says the string is written to the registry OR to the .INI file, but does not mention how the selection is made. Running in XP and using VC++ 6.0, I get the string in myappl.INI, but when moving to Vista and VS 2008, I can find no trace of what WriteProfileString might have done, nothing in the registry and nothing in any *.INI file. Is this function working in Vista at all?

I ran the following chunk of code on Win7 x64, and it behaves exactly as one would expect. Namely, the write fails if you're not an Administrator, or if UAC is turned on. Otherwise, the text is written to win.ini.
#define WIN32_LEAN_AND_MEAN #include <Windows.h> #include <tchar.h> #include <iostream> int _tmain(int argc, _TCHAR* argv[]) { char c[256]; GetProfileStringA("Test1", "Test2", 0, c, 256); std::cout << c << std::endl; int r = WriteProfileStringA("Test1","Test2","Test3"); std::cout << "Write " << (r ? "Okay" : "Failed") << std::endl; return r; }

Interesting test, but why is the text not put in the registry, as MSDN documentation suggests?. In my case, the XP version does not write to win.INI but to Winnct.INI, Winnct being the name of my application. In Vista I run as administrator, but still nothing seems to work. If I move the exe file from XP to Vista, it works ok, and the Winnct.ini is then stored in C:\Users\lmflho\AppData\Local\VirtualStore\Windows\
To me, this looks as if Visual Studio 2008 is somehow different to VC++ 6.0 in handling WriteProfileString.

![]() |
Find all the file from a ...
|
create a batch file
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |