我正在尝试用安装脚本中的SendMessageTimeout替换SendMessage API(刷新环境 - 注册表和东西)。更换安装程序后崩溃。我已经分别编译了子例程,它可以正常工作。
是因为SendMessageTimeout在不同的模块中 - Win32 :: GUI?我无法找到下载此模块的来源。对于天真的道歉,我对Perl来说是全新的,这是我必须做出的唯一改变。
use Win32::API;
sub refreshEnvironment()
{
use constant WM_WININICHANGE => 0x001A;
use constant HWND_BROADCAST => 0xffff;
use constant SMTO_ABORTIFHUNG => 0x0002;
print("Refreshing the environment.\n");
my $sm = new Win32::API(
"user32",
"SendMessageTimeout",
['N', 'N', 'I', 'P', 'N','I', 'P'], 'N'
);
if (! defined ($sm)) {
print("SendMessage api did not initialize.\n");
return;
}
my $buffer = "Environment";
my $res = $sm->Call(HWND_BROADCAST, WM_WININICHANGE, 0, $buffer, SMTO_ABORTIFHUNG, 2000, NULL);
print("SendMessage refresh environment done\n");
}
refreshEnvironment();