cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
urbarobe
Level 2

Set Environment path variable SendMessage hangs on Win10

Hello,

on a Windows 10 depends SendMessage after setting the PATH variable. After 15 minutes the setup continues. On a Windows 8.1 there are no problems.

I do this:
#define HWND_BROADCAST 0xffff
#define WM_WININICHANGE 0x001A

szEnv = "Environment";
pEnv = &szEnv;
SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, pEnv );


With SendMessageTimeout there is no error. I change my code to:
#define WM_SETTINGCHANGE 0x001A
#define SMTO_ABORTIFHUNG 0x0002
#define SMTO_TIMEOUT 50

if (!SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, pEnv, SMTO_ABORTIFHUNG, SMTO_TIMEOUT, pResult)) then
SprintfBox(WARNING, "", "SendMessageTimeout failed in RefreshEnvironment, Error %d", Err.LastDllError());
endif;


Is there an explanation for why SendMessage Windows 10 takes so long?

Best Regards,
urbarobe
Labels (1)
0 Kudos

(1) Reply
tgvishnupriyabe
Level 3

We are seeing a similar issue with Windows 7 -64 bit itself, where

SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, pEnv );

is taking more time. I read similar posts suggesting to use SendMessageTimeout,
I see there is some restart required after environmental variables being set and so SendMessage is taking more time.
Is my understanding correct?

Also by using SendMessageTimeout will the problem of taking more time to refresh env will get solved?

Please do reply back.

Thanks,
Priya
0 Kudos