Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems using WM_SETTINGCHANGE !?!

Status
Not open for further replies.

mamaza

Programmer
Nov 28, 2001
3
DE
hello all,
in my MFC-application I change the value of an environment variable by using CRegKey. After changing the value I call

Code:
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,(LPARAM)"Environment", SMTO_ABORTIFHUNG,5000,&returnValue);

to inform other programs, that the environment has changed. But when I want to use the changed environment variable by using getenv(), it has still the old value. Even other programs I call from my application have still the old value of the variable. First if I restart my program, the new value is available.

Is it possible to refresh the environment setting of my program during runtime, or is a restart allways necessary?
Or do I just misuse SendMessageTimeout()?

thank you!
 
The above code is Okay but I think other programs should handle the WM_SETTINGCHANGE message.
It can be done in the WndProc() function or such program should have a handler to process the WM_SETTINGCHANGE message:
Code:
void CMyFrame::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) 
{
	CFrameWnd::OnSettingChange(uFlags, lpszSection);
	// Reload here the registry key 
        //
}
-obislavu-
 
@obislavu,
my problem is, that my program doesn´t recognize, that the environment has change. I change the variable and later I call an other program, but this program uses still the old value of the variable. And even in my program I got the old value of the variable, when I read it with getenv(). So I have to refresh the environment setting of my program. Thought WM_SETTINGCHANGE would do that, but it doesn´t! After restarting my program everythink is fine and the new value is recognized.

Hope I could explain my problem a little bit better!

Bye!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top