WriteProfileString not working in V

March 4, 2009 at 22:54:26
Specs: Windows Vista

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?

See More: WriteProfileString not working in V

Report •

March 5, 2009 at 09:52:46
You can ask on
Professional Win32 api Group
for source code of any Win32 api... (C)

Report •

March 5, 2009 at 15:33:24
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.
#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;

Report •

March 5, 2009 at 23:58:49
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.

Report •

Related Solutions

Ask Question