Hi,
Iam using SetTimeZoneInformation to set time. It works ok that is my
system clock in the taskbar is updated. But when i call GetLocalTime it
shows the time of my previous timezone. I think it is the cause of
applications not knowing that the time zone has changed. So i used
SendMessageTimeout()
to broadcast the message. Is it correct? iam getting a error when i
call this function as "Incorrect function" ie error code of the above
fun is 1. I dont know what is wrong. Please help.
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern bool SetTimeZoneInformation(ref
TimeZoneInformation lpTimeZoneInformation);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int SendMessageTimeout(IntPtr hWnd, uint
Msg,IntPtr wParam, string lParam, int fuFlags,uint uTimeout, out
UIntPtr lpdwResult);
public const int HWND_BROADCAST = 0xffff;
public const int WM_SETTINGCHANGE = 0x001A;
public const int SMTO_ABORTIFHUNG = 0x0002;
public void SetTimeZone(TimeZoneInformation Info)
{
UIntPtr lres;
int iRet;
if (SetTimeZoneInformation(ref Info) == false)
{
/*Do error check*/
}
if ((iRet = SendMessageTimeout((IntPtr)0xffffffff, 0x001A,
IntPtr.Zero, "Environment", 0x0002, 15000, out lres)) != 0)
{
}
/* if ((iRet = SendMessage((IntPtr)0xffff, 0x001A, 0, null))
!= 0)
{
}*/
}
Please help.Its urgent
Varun