Sample Code For Daylight Savings Adjustment?

  • Thread starter Thread starter Tim Houle
  • Start date Start date
T

Tim Houle

I'm looking For Sample Code For Daylight Savings
Adjustment using EWF - Detect, Commit and Reboot. Doug H -
I've looked everywhere for your old post that has sample
code but couldnt find it. Any ideas?

Thanks,
Tim
 
Tim:

I couldn't find it either. Maybe I was dreamin...

Here it is. You will have to ignore some stuff as this won't compile for
you as is:

bool Verify_LocalTime(void)
{
TIME_ZONE_INFORMATION tzi;
DWORD tzstat = 0;
TCHAR message[512];
int status = 0;
HKEY hKey;
DWORD keyType = 0;
DWORD size = sizeof(DWORD);
DWORD tzi_key = 0;
char command_line[120];
BOOL bstatus = 0;
int iShutdownDelay = 30;

// determine the active time zone
tzstat = GetTimeZoneInformation(&tzi);

// open CAE2_TIME_HIVE
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, CAE2_TIME_HIVE_KEY_NAME, NULL,
KEY_READ | KEY_WRITE, &hKey);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// query the value at "TZI (...)"
status = RegQueryValueEx(hKey, TZI_KEY, NULL, &keyType, (LPBYTE)&tzi_key,
&size);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

if (tzi_key == 99)
{
// Initial condition detected:
// set correct value based on active time zone which is assumed to be
correct
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),

((tzstat==TIME_ZONE_ID_STANDARD)||(tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Stand
ard"):_T("Daylight"));
}
}
else // 0, 1, or 2
{
// determine if we switched in/out of daylight savings depending
// on the active time zone
switch (tzstat)
{
case TIME_ZONE_ID_STANDARD:
case TIME_ZONE_ID_DAYLIGHT:
// determine if we need to commit a time change
if (tzstat != tzi_key)
{
// a time change has occured... set "TZI (...)" to adjusted value
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// log this change
ctx_log(GEN_LOG_INFO, _T("Local time has changed from %s to %s"),

(((tzi_key==TIME_ZONE_ID_STANDARD)||(tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Sta
ndard"):_T("Daylight")),
(tzstat==TIME_ZONE_ID_STANDARD?_T("Standard"):_T("Daylight")));

// blank the display
kpdDisplayBlank();
kpdClearLEDs();

// perform EWF commit and perform graceful restart
strcpy(command_line, "EWFCMT.BAT");
ctx_log(GEN_LOG_TRACE, _T("ShellProcessA cmd line: %s"),
TSTR(command_line));
bstatus = ShellProcessA(command_line);
if (bstatus)
{
// update line 1 with time change message
status = kpdTextlineUpdate(KPD_LINE1, (char *)time_change_text);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate error - status = %d"),
status);
// update line 2 with restart system message
status = kpdTextlineUpdate(KPD_LINE2, (char *)restart_system);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate error - status = %d"),
status);

// get the Shutdown Delay from the registry
CConfigData::Instance()->Get_Shutdown_Delay(iShutdownDelay);

// send Shutdown command to Remote firmware
if (RemoteOutThread::Instance()->postShutdownDisplay(iShutdownDelay,
KPD_LINE1, (char *)restart_system) != REMOUT_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("Unable to post Shutdown message to
remote."));

ctx_log(GEN_LOG_INFO, _T("Graceful RESTART has been requested!"));
// delay before the restart
Sleep(2000);
// perform graceful shutdown and restart
Shutdown_and_Restart();
}
else // shell process error
{
ctx_log(GEN_LOG_ERROR, _T("ShellProcessA error: %s"),
TSTR(command_line));
}
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),
(tzstat==TIME_ZONE_ID_STANDARD?_T("Standard"):_T("Daylight")));
}
break;

case TIME_ZONE_ID_UNKNOWN:
if (tzstat != tzi_key)
{
// set "TZI (...)" to correct value
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
}
// daylight saving time is not used in the current time zone
ctx_log(GEN_LOG_INFO, _T("Daylight saving time is not used in the
current time zone."));
break;

default:
// error
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
break;
}
}

Done:
if (hKey)
RegCloseKey(hKey);

return true;
}
 
Thanks alot Doug. Much appreciated.

Tim
-----Original Message-----
Tim:

I couldn't find it either. Maybe I was dreamin...

Here it is. You will have to ignore some stuff as this won't compile for
you as is:

bool Verify_LocalTime(void)
{
TIME_ZONE_INFORMATION tzi;
DWORD tzstat = 0;
TCHAR message[512];
int status = 0;
HKEY hKey;
DWORD keyType = 0;
DWORD size = sizeof(DWORD);
DWORD tzi_key = 0;
char command_line[120];
BOOL bstatus = 0;
int iShutdownDelay = 30;

// determine the active time zone
tzstat = GetTimeZoneInformation(&tzi);

// open CAE2_TIME_HIVE
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, CAE2_TIME_HIVE_KEY_NAME, NULL,
KEY_READ | KEY_WRITE, &hKey);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// query the value at "TZI (...)"
status = RegQueryValueEx(hKey, TZI_KEY, NULL, &keyType, (LPBYTE)&tzi_key,
&size);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

if (tzi_key == 99)
{
// Initial condition detected:
// set correct value based on active time zone which is assumed to be
correct
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),

((tzstat==TIME_ZONE_ID_STANDARD)|| (tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Stand
ard"):_T("Daylight"));
}
}
else // 0, 1, or 2
{
// determine if we switched in/out of daylight savings depending
// on the active time zone
switch (tzstat)
{
case TIME_ZONE_ID_STANDARD:
case TIME_ZONE_ID_DAYLIGHT:
// determine if we need to commit a time change
if (tzstat != tzi_key)
{
// a time change has occured... set "TZI (...)" to adjusted value
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// log this change
ctx_log(GEN_LOG_INFO, _T("Local time has changed from %s to %s"),

(((tzi_key==TIME_ZONE_ID_STANDARD)|| (tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Sta
ndard"):_T("Daylight")),
(tzstat==TIME_ZONE_ID_STANDARD?_T("Standard"):_T
("Daylight")));

// blank the display
kpdDisplayBlank();
kpdClearLEDs();

// perform EWF commit and perform graceful restart
strcpy(command_line, "EWFCMT.BAT");
ctx_log(GEN_LOG_TRACE, _T("ShellProcessA cmd line: % s"),
TSTR(command_line));
bstatus = ShellProcessA(command_line);
if (bstatus)
{
// update line 1 with time change message
status = kpdTextlineUpdate(KPD_LINE1, (char *) time_change_text);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate error - status = %d"),
status);
// update line 2 with restart system message
status = kpdTextlineUpdate(KPD_LINE2, (char *) restart_system);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate error - status = %d"),
status);

// get the Shutdown Delay from the registry
CConfigData::Instance()->Get_Shutdown_Delay (iShutdownDelay);

// send Shutdown command to Remote firmware
if (RemoteOutThread::Instance()-
postShutdownDisplay(iShutdownDelay,
KPD_LINE1, (char *)restart_system) != REMOUT_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("Unable to post Shutdown message to
remote."));

ctx_log(GEN_LOG_INFO, _T("Graceful RESTART has been requested!"));
// delay before the restart
Sleep(2000);
// perform graceful shutdown and restart
Shutdown_and_Restart();
}
else // shell process error
{
ctx_log(GEN_LOG_ERROR, _T("ShellProcessA error: % s"),
TSTR(command_line));
}
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),
(tzstat==TIME_ZONE_ID_STANDARD?_T("Standard"):_T ("Daylight")));
}
break;

case TIME_ZONE_ID_UNKNOWN:
if (tzstat != tzi_key)
{
// set "TZI (...)" to correct value
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
}
// daylight saving time is not used in the current time zone
ctx_log(GEN_LOG_INFO, _T("Daylight saving time is not used in the
current time zone."));
break;

default:
// error
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
break;
}
}

Done:
if (hKey)
RegCloseKey(hKey);

return true;
}

Tim Houle said:
I'm looking For Sample Code For Daylight Savings
Adjustment using EWF - Detect, Commit and Reboot. Doug H -
I've looked everywhere for your old post that has sample
code but couldnt find it. Any ideas?

Thanks,
Tim


.
 
Doug,

What are the keys: CAE2_TIME_HIVE_KEY_NAME and TZI_KEY?

Thanks,
Tim
-----Original Message-----
Tim:

I couldn't find it either. Maybe I was dreamin...

Here it is. You will have to ignore some stuff as this won't compile for
you as is:

bool Verify_LocalTime(void)
{
TIME_ZONE_INFORMATION tzi;
DWORD tzstat = 0;
TCHAR message[512];
int status = 0;
HKEY hKey;
DWORD keyType = 0;
DWORD size = sizeof(DWORD);
DWORD tzi_key = 0;
char command_line[120];
BOOL bstatus = 0;
int iShutdownDelay = 30;

// determine the active time zone
tzstat = GetTimeZoneInformation(&tzi);

// open CAE2_TIME_HIVE
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, CAE2_TIME_HIVE_KEY_NAME, NULL,
KEY_READ | KEY_WRITE, &hKey);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// query the value at "TZI (...)"
status = RegQueryValueEx(hKey, TZI_KEY, NULL, &keyType, (LPBYTE)&tzi_key,
&size);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

if (tzi_key == 99)
{
// Initial condition detected:
// set correct value based on active time zone which is assumed to be
correct
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),

((tzstat==TIME_ZONE_ID_STANDARD)|| (tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Stand
ard"):_T("Daylight"));
}
}
else // 0, 1, or 2
{
// determine if we switched in/out of daylight savings depending
// on the active time zone
switch (tzstat)
{
case TIME_ZONE_ID_STANDARD:
case TIME_ZONE_ID_DAYLIGHT:
// determine if we need to commit a time change
if (tzstat != tzi_key)
{
// a time change has occured... set "TZI (...)" to adjusted value
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// log this change
ctx_log(GEN_LOG_INFO, _T("Local time has changed from %s to %s"),

(((tzi_key==TIME_ZONE_ID_STANDARD)|| (tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Sta
ndard"):_T("Daylight")),
(tzstat==TIME_ZONE_ID_STANDARD?_T("Standard"):_T
("Daylight")));

// blank the display
kpdDisplayBlank();
kpdClearLEDs();

// perform EWF commit and perform graceful restart
strcpy(command_line, "EWFCMT.BAT");
ctx_log(GEN_LOG_TRACE, _T("ShellProcessA cmd line: % s"),
TSTR(command_line));
bstatus = ShellProcessA(command_line);
if (bstatus)
{
// update line 1 with time change message
status = kpdTextlineUpdate(KPD_LINE1, (char *) time_change_text);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate error - status = %d"),
status);
// update line 2 with restart system message
status = kpdTextlineUpdate(KPD_LINE2, (char *) restart_system);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate error - status = %d"),
status);

// get the Shutdown Delay from the registry
CConfigData::Instance()->Get_Shutdown_Delay (iShutdownDelay);

// send Shutdown command to Remote firmware
if (RemoteOutThread::Instance()-
postShutdownDisplay(iShutdownDelay,
KPD_LINE1, (char *)restart_system) != REMOUT_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("Unable to post Shutdown message to
remote."));

ctx_log(GEN_LOG_INFO, _T("Graceful RESTART has been requested!"));
// delay before the restart
Sleep(2000);
// perform graceful shutdown and restart
Shutdown_and_Restart();
}
else // shell process error
{
ctx_log(GEN_LOG_ERROR, _T("ShellProcessA error: % s"),
TSTR(command_line));
}
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),
(tzstat==TIME_ZONE_ID_STANDARD?_T("Standard"):_T ("Daylight")));
}
break;

case TIME_ZONE_ID_UNKNOWN:
if (tzstat != tzi_key)
{
// set "TZI (...)" to correct value
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
}
// daylight saving time is not used in the current time zone
ctx_log(GEN_LOG_INFO, _T("Daylight saving time is not used in the
current time zone."));
break;

default:
// error
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
break;
}
}

Done:
if (hKey)
RegCloseKey(hKey);

return true;
}

Tim Houle said:
I'm looking For Sample Code For Daylight Savings
Adjustment using EWF - Detect, Commit and Reboot. Doug H -
I've looked everywhere for your old post that has sample
code but couldnt find it. Any ideas?

Thanks,
Tim


.
 
Tim:

const TCHAR* const CAE2_TIME_HIVE_KEY_NAME = _T("CAE2_TIME_HIVE");
const TCHAR* const TZI_KEY = _T("TZI (0=none,1=Std,2=Daylight)");

CAE2_TIME_HIVE is the name of a registry hive that I use to store the TZI
key value. This registry hive is stored on a partition not protected by
EWF. In my master ghost image, TZI is preset to 99 which is the
uninitialized state. When my product is first built, TZI becomes 0, 1, or 2
depending on the current date and time zone.

HTH
.... Doug

Tim Houle said:
Doug,

What are the keys: CAE2_TIME_HIVE_KEY_NAME and TZI_KEY?

Thanks,
Tim
-----Original Message-----
Tim:

I couldn't find it either. Maybe I was dreamin...

Here it is. You will have to ignore some stuff as this won't compile for
you as is:

bool Verify_LocalTime(void)
{
TIME_ZONE_INFORMATION tzi;
DWORD tzstat = 0;
TCHAR message[512];
int status = 0;
HKEY hKey;
DWORD keyType = 0;
DWORD size = sizeof(DWORD);
DWORD tzi_key = 0;
char command_line[120];
BOOL bstatus = 0;
int iShutdownDelay = 30;

// determine the active time zone
tzstat = GetTimeZoneInformation(&tzi);

// open CAE2_TIME_HIVE
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, CAE2_TIME_HIVE_KEY_NAME, NULL,
KEY_READ | KEY_WRITE, &hKey);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// query the value at "TZI (...)"
status = RegQueryValueEx(hKey, TZI_KEY, NULL, &keyType, (LPBYTE)&tzi_key,
&size);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

if (tzi_key == 99)
{
// Initial condition detected:
// set correct value based on active time zone which is assumed to be
correct
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),

((tzstat==TIME_ZONE_ID_STANDARD)|| (tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Stand
ard"):_T("Daylight"));
}
}
else // 0, 1, or 2
{
// determine if we switched in/out of daylight savings depending
// on the active time zone
switch (tzstat)
{
case TIME_ZONE_ID_STANDARD:
case TIME_ZONE_ID_DAYLIGHT:
// determine if we need to commit a time change
if (tzstat != tzi_key)
{
// a time change has occured... set "TZI (...)" to adjusted value
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// log this change
ctx_log(GEN_LOG_INFO, _T("Local time has changed from %s to %s"),

(((tzi_key==TIME_ZONE_ID_STANDARD)|| (tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Sta
ndard"):_T("Daylight")),
(tzstat==TIME_ZONE_ID_STANDARD?_T("Standard"):_T
("Daylight")));

// blank the display
kpdDisplayBlank();
kpdClearLEDs();

// perform EWF commit and perform graceful restart
strcpy(command_line, "EWFCMT.BAT");
ctx_log(GEN_LOG_TRACE, _T("ShellProcessA cmd line: % s"),
TSTR(command_line));
bstatus = ShellProcessA(command_line);
if (bstatus)
{
// update line 1 with time change message
status = kpdTextlineUpdate(KPD_LINE1, (char *) time_change_text);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate error - status = %d"),
status);
// update line 2 with restart system message
status = kpdTextlineUpdate(KPD_LINE2, (char *) restart_system);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate error - status = %d"),
status);

// get the Shutdown Delay from the registry
CConfigData::Instance()->Get_Shutdown_Delay (iShutdownDelay);

// send Shutdown command to Remote firmware
if (RemoteOutThread::Instance()-
postShutdownDisplay(iShutdownDelay,
KPD_LINE1, (char *)restart_system) != REMOUT_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("Unable to post Shutdown message to
remote."));

ctx_log(GEN_LOG_INFO, _T("Graceful RESTART has been requested!"));
// delay before the restart
Sleep(2000);
// perform graceful shutdown and restart
Shutdown_and_Restart();
}
else // shell process error
{
ctx_log(GEN_LOG_ERROR, _T("ShellProcessA error: % s"),
TSTR(command_line));
}
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),
(tzstat==TIME_ZONE_ID_STANDARD?_T("Standard"):_T ("Daylight")));
}
break;

case TIME_ZONE_ID_UNKNOWN:
if (tzstat != tzi_key)
{
// set "TZI (...)" to correct value
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
}
// daylight saving time is not used in the current time zone
ctx_log(GEN_LOG_INFO, _T("Daylight saving time is not used in the
current time zone."));
break;

default:
// error
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
break;
}
}

Done:
if (hKey)
RegCloseKey(hKey);

return true;
}

Tim Houle said:
I'm looking For Sample Code For Daylight Savings
Adjustment using EWF - Detect, Commit and Reboot. Doug H -
I've looked everywhere for your old post that has sample
code but couldnt find it. Any ideas?

Thanks,
Tim


.
 
Cool. So Doug, I have an .ini file that stores persistent
information on a non-protected partition. I could store
CAE2_TIME_HIVE and TZI_KEY in this file and I would not
need to commit anything or reboot. Am I on the right
page?

Thanks again,
Tim

-----Original Message-----
Tim:

const TCHAR* const CAE2_TIME_HIVE_KEY_NAME = _T ("CAE2_TIME_HIVE");
const TCHAR* const TZI_KEY = _T("TZI (0=none,1=Std,2=Daylight)");

CAE2_TIME_HIVE is the name of a registry hive that I use to store the TZI
key value. This registry hive is stored on a partition not protected by
EWF. In my master ghost image, TZI is preset to 99 which is the
uninitialized state. When my product is first built, TZI becomes 0, 1, or 2
depending on the current date and time zone.

HTH
.... Doug

Doug,

What are the keys: CAE2_TIME_HIVE_KEY_NAME and TZI_KEY?

Thanks,
Tim
-----Original Message-----
Tim:

I couldn't find it either. Maybe I was dreamin...

Here it is. You will have to ignore some stuff as
this
won't compile for
you as is:

bool Verify_LocalTime(void)
{
TIME_ZONE_INFORMATION tzi;
DWORD tzstat = 0;
TCHAR message[512];
int status = 0;
HKEY hKey;
DWORD keyType = 0;
DWORD size = sizeof(DWORD);
DWORD tzi_key = 0;
char command_line[120];
BOOL bstatus = 0;
int iShutdownDelay = 30;

// determine the active time zone
tzstat = GetTimeZoneInformation(&tzi);

// open CAE2_TIME_HIVE
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, CAE2_TIME_HIVE_KEY_NAME, NULL,
KEY_READ | KEY_WRITE, &hKey);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// query the value at "TZI (...)"
status = RegQueryValueEx(hKey, TZI_KEY, NULL,
&keyType,
(LPBYTE)&tzi_key,
&size);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

if (tzi_key == 99)
{
// Initial condition detected:
// set correct value based on active time zone which is assumed to be
correct
status = RegSetValueEx(hKey, TZI_KEY, NULL,
REG_DWORD,
(LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),

((tzstat==TIME_ZONE_ID_STANDARD)|| (tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Stand
ard"):_T("Daylight"));
}
}
else // 0, 1, or 2
{
// determine if we switched in/out of daylight
savings
depending
// on the active time zone
switch (tzstat)
{
case TIME_ZONE_ID_STANDARD:
case TIME_ZONE_ID_DAYLIGHT:
// determine if we need to commit a time change
if (tzstat != tzi_key)
{
// a time change has occured... set "TZI (...)"
to
adjusted value
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// log this change
ctx_log(GEN_LOG_INFO, _T("Local time has changed from %s to %s"),

(((tzi_key==TIME_ZONE_ID_STANDARD)|| (tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Sta
ndard"):_T("Daylight")),
(tzstat==TIME_ZONE_ID_STANDARD?_T("Standard"):_T
("Daylight")));

// blank the display
kpdDisplayBlank();
kpdClearLEDs();

// perform EWF commit and perform graceful restart
strcpy(command_line, "EWFCMT.BAT");
ctx_log(GEN_LOG_TRACE, _T("ShellProcessA cmd
line: %
s"),
TSTR(command_line));
bstatus = ShellProcessA(command_line);
if (bstatus)
{
// update line 1 with time change message
status = kpdTextlineUpdate(KPD_LINE1, (char *) time_change_text);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate error - status = %d"),
status);
// update line 2 with restart system message
status = kpdTextlineUpdate(KPD_LINE2, (char *) restart_system);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate error - status = %d"),
status);

// get the Shutdown Delay from the registry
CConfigData::Instance()->Get_Shutdown_Delay (iShutdownDelay);

// send Shutdown command to Remote firmware
if (RemoteOutThread::Instance()-
postShutdownDisplay(iShutdownDelay,
KPD_LINE1, (char *)restart_system) != REMOUT_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("Unable to post Shutdown message to
remote."));

ctx_log(GEN_LOG_INFO, _T("Graceful RESTART has been requested!"));
// delay before the restart
Sleep(2000);
// perform graceful shutdown and restart
Shutdown_and_Restart();
}
else // shell process error
{
ctx_log(GEN_LOG_ERROR, _T("ShellProcessA error:
%
s"),
TSTR(command_line));
}
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),
(tzstat==TIME_ZONE_ID_STANDARD?_T("Standard"):_T ("Daylight")));
}
break;

case TIME_ZONE_ID_UNKNOWN:
if (tzstat != tzi_key)
{
// set "TZI (...)" to correct value
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
}
// daylight saving time is not used in the current time zone
ctx_log(GEN_LOG_INFO, _T("Daylight saving time is not used in the
current time zone."));
break;

default:
// error
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
break;
}
}

Done:
if (hKey)
RegCloseKey(hKey);

return true;
}

I'm looking For Sample Code For Daylight Savings
Adjustment using EWF - Detect, Commit and Reboot.
Doug
H -
I've looked everywhere for your old post that has sample
code but couldnt find it. Any ideas?

Thanks,
Tim



.


.
 
Doug, one more thing. You say you store it in a non-
protected hive in the registry. Can we separate registry
hives to another non-protected partition other than where
the OS exists?
-----Original Message-----
Tim:

const TCHAR* const CAE2_TIME_HIVE_KEY_NAME = _T ("CAE2_TIME_HIVE");
const TCHAR* const TZI_KEY = _T("TZI (0=none,1=Std,2=Daylight)");

CAE2_TIME_HIVE is the name of a registry hive that I use to store the TZI
key value. This registry hive is stored on a partition not protected by
EWF. In my master ghost image, TZI is preset to 99 which is the
uninitialized state. When my product is first built, TZI becomes 0, 1, or 2
depending on the current date and time zone.

HTH
.... Doug

Doug,

What are the keys: CAE2_TIME_HIVE_KEY_NAME and TZI_KEY?

Thanks,
Tim
-----Original Message-----
Tim:

I couldn't find it either. Maybe I was dreamin...

Here it is. You will have to ignore some stuff as
this
won't compile for
you as is:

bool Verify_LocalTime(void)
{
TIME_ZONE_INFORMATION tzi;
DWORD tzstat = 0;
TCHAR message[512];
int status = 0;
HKEY hKey;
DWORD keyType = 0;
DWORD size = sizeof(DWORD);
DWORD tzi_key = 0;
char command_line[120];
BOOL bstatus = 0;
int iShutdownDelay = 30;

// determine the active time zone
tzstat = GetTimeZoneInformation(&tzi);

// open CAE2_TIME_HIVE
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, CAE2_TIME_HIVE_KEY_NAME, NULL,
KEY_READ | KEY_WRITE, &hKey);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// query the value at "TZI (...)"
status = RegQueryValueEx(hKey, TZI_KEY, NULL,
&keyType,
(LPBYTE)&tzi_key,
&size);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

if (tzi_key == 99)
{
// Initial condition detected:
// set correct value based on active time zone which is assumed to be
correct
status = RegSetValueEx(hKey, TZI_KEY, NULL,
REG_DWORD,
(LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),

((tzstat==TIME_ZONE_ID_STANDARD)|| (tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Stand
ard"):_T("Daylight"));
}
}
else // 0, 1, or 2
{
// determine if we switched in/out of daylight
savings
depending
// on the active time zone
switch (tzstat)
{
case TIME_ZONE_ID_STANDARD:
case TIME_ZONE_ID_DAYLIGHT:
// determine if we need to commit a time change
if (tzstat != tzi_key)
{
// a time change has occured... set "TZI (...)"
to
adjusted value
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// log this change
ctx_log(GEN_LOG_INFO, _T("Local time has changed from %s to %s"),

(((tzi_key==TIME_ZONE_ID_STANDARD)|| (tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Sta
ndard"):_T("Daylight")),
(tzstat==TIME_ZONE_ID_STANDARD?_T("Standard"):_T
("Daylight")));

// blank the display
kpdDisplayBlank();
kpdClearLEDs();

// perform EWF commit and perform graceful restart
strcpy(command_line, "EWFCMT.BAT");
ctx_log(GEN_LOG_TRACE, _T("ShellProcessA cmd
line: %
s"),
TSTR(command_line));
bstatus = ShellProcessA(command_line);
if (bstatus)
{
// update line 1 with time change message
status = kpdTextlineUpdate(KPD_LINE1, (char *) time_change_text);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate error - status = %d"),
status);
// update line 2 with restart system message
status = kpdTextlineUpdate(KPD_LINE2, (char *) restart_system);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate error - status = %d"),
status);

// get the Shutdown Delay from the registry
CConfigData::Instance()->Get_Shutdown_Delay (iShutdownDelay);

// send Shutdown command to Remote firmware
if (RemoteOutThread::Instance()-
postShutdownDisplay(iShutdownDelay,
KPD_LINE1, (char *)restart_system) != REMOUT_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("Unable to post Shutdown message to
remote."));

ctx_log(GEN_LOG_INFO, _T("Graceful RESTART has been requested!"));
// delay before the restart
Sleep(2000);
// perform graceful shutdown and restart
Shutdown_and_Restart();
}
else // shell process error
{
ctx_log(GEN_LOG_ERROR, _T("ShellProcessA error:
%
s"),
TSTR(command_line));
}
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),
(tzstat==TIME_ZONE_ID_STANDARD?_T("Standard"):_T ("Daylight")));
}
break;

case TIME_ZONE_ID_UNKNOWN:
if (tzstat != tzi_key)
{
// set "TZI (...)" to correct value
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
}
// daylight saving time is not used in the current time zone
ctx_log(GEN_LOG_INFO, _T("Daylight saving time is not used in the
current time zone."));
break;

default:
// error
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
break;
}
}

Done:
if (hKey)
RegCloseKey(hKey);

return true;
}

I'm looking For Sample Code For Daylight Savings
Adjustment using EWF - Detect, Commit and Reboot.
Doug
H -
I've looked everywhere for your old post that has sample
code but couldnt find it. Any ideas?

Thanks,
Tim



.


.
 
Tim:

Sure, you could use an ini file or create your own registry hive. To create
your own registry hive, which is not part of the default windows registry,
you can create a registry key(s) then export as a registry hive (I think...
its been awhile since I've done this). This is now your registry hive that
you can load, read, close via the Windows API functions RegLoadKey(),
RegOpenKeyEx(), RegCloseKey(). To manually load a registry hive, play with
"Load Hive" in regedit.

With EWF you will still need to commit and reboot atleast if your boot
partition is protected by EWF. The current date/time/time zone is stored in
the registry on the boot partition. My application simply uses the return
value of the GetTimeZoneInformation() API to detect that the current time
zone has changed. I let Windows do this since Windows already knows how to
do it. I just detect this change by comparing what GetTimeZoneInformation()
API returns with what is stored in my registry hive. WHen they are
different, the system just went into or out of daylight saving so I shell a
bat file to commit and reboot. Use the EWF dll API for this. I would of
instead of a bat file but the EWF dll QFE came out too late for me to
deploy.

HTH... Doug

Tim Houle said:
Doug, one more thing. You say you store it in a non-
protected hive in the registry. Can we separate registry
hives to another non-protected partition other than where
the OS exists?
-----Original Message-----
Tim:

const TCHAR* const CAE2_TIME_HIVE_KEY_NAME = _T ("CAE2_TIME_HIVE");
const TCHAR* const TZI_KEY = _T("TZI (0=none,1=Std,2=Daylight)");

CAE2_TIME_HIVE is the name of a registry hive that I use to store the TZI
key value. This registry hive is stored on a partition not protected by
EWF. In my master ghost image, TZI is preset to 99 which is the
uninitialized state. When my product is first built, TZI becomes 0, 1, or 2
depending on the current date and time zone.

HTH
.... Doug

Doug,

What are the keys: CAE2_TIME_HIVE_KEY_NAME and TZI_KEY?

Thanks,
Tim
-----Original Message-----
Tim:

I couldn't find it either. Maybe I was dreamin...

Here it is. You will have to ignore some stuff as this
won't compile for
you as is:

bool Verify_LocalTime(void)
{
TIME_ZONE_INFORMATION tzi;
DWORD tzstat = 0;
TCHAR message[512];
int status = 0;
HKEY hKey;
DWORD keyType = 0;
DWORD size = sizeof(DWORD);
DWORD tzi_key = 0;
char command_line[120];
BOOL bstatus = 0;
int iShutdownDelay = 30;

// determine the active time zone
tzstat = GetTimeZoneInformation(&tzi);

// open CAE2_TIME_HIVE
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
CAE2_TIME_HIVE_KEY_NAME, NULL,
KEY_READ | KEY_WRITE, &hKey);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// query the value at "TZI (...)"
status = RegQueryValueEx(hKey, TZI_KEY, NULL, &keyType,
(LPBYTE)&tzi_key,
&size);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

if (tzi_key == 99)
{
// Initial condition detected:
// set correct value based on active time zone which
is assumed to be
correct
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD,
(LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),

((tzstat==TIME_ZONE_ID_STANDARD)||
(tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Stand
ard"):_T("Daylight"));
}
}
else // 0, 1, or 2
{
// determine if we switched in/out of daylight savings
depending
// on the active time zone
switch (tzstat)
{
case TIME_ZONE_ID_STANDARD:
case TIME_ZONE_ID_DAYLIGHT:
// determine if we need to commit a time change
if (tzstat != tzi_key)
{
// a time change has occured... set "TZI (...)" to
adjusted value
status = RegSetValueEx(hKey, TZI_KEY, NULL,
REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// log this change
ctx_log(GEN_LOG_INFO, _T("Local time has changed
from %s to %s"),

(((tzi_key==TIME_ZONE_ID_STANDARD)||
(tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Sta
ndard"):_T("Daylight")),
(tzstat==TIME_ZONE_ID_STANDARD?_T("Standard"):_T
("Daylight")));

// blank the display
kpdDisplayBlank();
kpdClearLEDs();

// perform EWF commit and perform graceful restart
strcpy(command_line, "EWFCMT.BAT");
ctx_log(GEN_LOG_TRACE, _T("ShellProcessA cmd line: %
s"),
TSTR(command_line));
bstatus = ShellProcessA(command_line);
if (bstatus)
{
// update line 1 with time change message
status = kpdTextlineUpdate(KPD_LINE1, (char *)
time_change_text);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate
error - status = %d"),
status);
// update line 2 with restart system message
status = kpdTextlineUpdate(KPD_LINE2, (char *)
restart_system);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate
error - status = %d"),
status);

// get the Shutdown Delay from the registry
CConfigData::Instance()->Get_Shutdown_Delay
(iShutdownDelay);

// send Shutdown command to Remote firmware
if (RemoteOutThread::Instance()-
postShutdownDisplay(iShutdownDelay,
KPD_LINE1, (char *)restart_system) != REMOUT_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("Unable to post
Shutdown message to
remote."));

ctx_log(GEN_LOG_INFO, _T("Graceful RESTART has
been requested!"));
// delay before the restart
Sleep(2000);
// perform graceful shutdown and restart
Shutdown_and_Restart();
}
else // shell process error
{
ctx_log(GEN_LOG_ERROR, _T("ShellProcessA error: %
s"),
TSTR(command_line));
}
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),
(tzstat==TIME_ZONE_ID_STANDARD?_T("Standard"):_T
("Daylight")));
}
break;

case TIME_ZONE_ID_UNKNOWN:
if (tzstat != tzi_key)
{
// set "TZI (...)" to correct value
status = RegSetValueEx(hKey, TZI_KEY, NULL,
REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
}
// daylight saving time is not used in the current
time zone
ctx_log(GEN_LOG_INFO, _T("Daylight saving time is
not used in the
current time zone."));
break;

default:
// error
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
break;
}
}

Done:
if (hKey)
RegCloseKey(hKey);

return true;
}

I'm looking For Sample Code For Daylight Savings
Adjustment using EWF - Detect, Commit and Reboot. Doug
H -
I've looked everywhere for your old post that has
sample
code but couldnt find it. Any ideas?

Thanks,
Tim



.


.
 
Ti Tim,

There are powerful functions documented and undocumented functions for manipulating registry (mostly from drivers). So using driver
you could accomplish this, without driver there is only small possibility if you examine native API functions that there might be
functions that would allow you to do that.

Best regards,
Slobodan

Tim Houle said:
Doug, one more thing. You say you store it in a non-
protected hive in the registry. Can we separate registry
hives to another non-protected partition other than where
the OS exists?
-----Original Message-----
Tim:

const TCHAR* const CAE2_TIME_HIVE_KEY_NAME = _T ("CAE2_TIME_HIVE");
const TCHAR* const TZI_KEY = _T("TZI (0=none,1=Std,2=Daylight)");

CAE2_TIME_HIVE is the name of a registry hive that I use to store the TZI
key value. This registry hive is stored on a partition not protected by
EWF. In my master ghost image, TZI is preset to 99 which is the
uninitialized state. When my product is first built, TZI becomes 0, 1, or 2
depending on the current date and time zone.

HTH
.... Doug

Doug,

What are the keys: CAE2_TIME_HIVE_KEY_NAME and TZI_KEY?

Thanks,
Tim
-----Original Message-----
Tim:

I couldn't find it either. Maybe I was dreamin...

Here it is. You will have to ignore some stuff as this
won't compile for
you as is:

bool Verify_LocalTime(void)
{
TIME_ZONE_INFORMATION tzi;
DWORD tzstat = 0;
TCHAR message[512];
int status = 0;
HKEY hKey;
DWORD keyType = 0;
DWORD size = sizeof(DWORD);
DWORD tzi_key = 0;
char command_line[120];
BOOL bstatus = 0;
int iShutdownDelay = 30;

// determine the active time zone
tzstat = GetTimeZoneInformation(&tzi);

// open CAE2_TIME_HIVE
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
CAE2_TIME_HIVE_KEY_NAME, NULL,
KEY_READ | KEY_WRITE, &hKey);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// query the value at "TZI (...)"
status = RegQueryValueEx(hKey, TZI_KEY, NULL, &keyType,
(LPBYTE)&tzi_key,
&size);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

if (tzi_key == 99)
{
// Initial condition detected:
// set correct value based on active time zone which
is assumed to be
correct
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD,
(LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),

((tzstat==TIME_ZONE_ID_STANDARD)||
(tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Stand
ard"):_T("Daylight"));
}
}
else // 0, 1, or 2
{
// determine if we switched in/out of daylight savings
depending
// on the active time zone
switch (tzstat)
{
case TIME_ZONE_ID_STANDARD:
case TIME_ZONE_ID_DAYLIGHT:
// determine if we need to commit a time change
if (tzstat != tzi_key)
{
// a time change has occured... set "TZI (...)" to
adjusted value
status = RegSetValueEx(hKey, TZI_KEY, NULL,
REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// log this change
ctx_log(GEN_LOG_INFO, _T("Local time has changed
from %s to %s"),

(((tzi_key==TIME_ZONE_ID_STANDARD)||
(tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Sta
ndard"):_T("Daylight")),
(tzstat==TIME_ZONE_ID_STANDARD?_T("Standard"):_T
("Daylight")));

// blank the display
kpdDisplayBlank();
kpdClearLEDs();

// perform EWF commit and perform graceful restart
strcpy(command_line, "EWFCMT.BAT");
ctx_log(GEN_LOG_TRACE, _T("ShellProcessA cmd line: %
s"),
TSTR(command_line));
bstatus = ShellProcessA(command_line);
if (bstatus)
{
// update line 1 with time change message
status = kpdTextlineUpdate(KPD_LINE1, (char *)
time_change_text);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate
error - status = %d"),
status);
// update line 2 with restart system message
status = kpdTextlineUpdate(KPD_LINE2, (char *)
restart_system);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate
error - status = %d"),
status);

// get the Shutdown Delay from the registry
CConfigData::Instance()->Get_Shutdown_Delay
(iShutdownDelay);

// send Shutdown command to Remote firmware
if (RemoteOutThread::Instance()-
postShutdownDisplay(iShutdownDelay,
KPD_LINE1, (char *)restart_system) != REMOUT_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("Unable to post
Shutdown message to
remote."));

ctx_log(GEN_LOG_INFO, _T("Graceful RESTART has
been requested!"));
// delay before the restart
Sleep(2000);
// perform graceful shutdown and restart
Shutdown_and_Restart();
}
else // shell process error
{
ctx_log(GEN_LOG_ERROR, _T("ShellProcessA error: %
s"),
TSTR(command_line));
}
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),
(tzstat==TIME_ZONE_ID_STANDARD?_T("Standard"):_T
("Daylight")));
}
break;

case TIME_ZONE_ID_UNKNOWN:
if (tzstat != tzi_key)
{
// set "TZI (...)" to correct value
status = RegSetValueEx(hKey, TZI_KEY, NULL,
REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
}
// daylight saving time is not used in the current
time zone
ctx_log(GEN_LOG_INFO, _T("Daylight saving time is
not used in the
current time zone."));
break;

default:
// error
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
break;
}
}

Done:
if (hKey)
RegCloseKey(hKey);

return true;
}

I'm looking For Sample Code For Daylight Savings
Adjustment using EWF - Detect, Commit and Reboot. Doug
H -
I've looked everywhere for your old post that has
sample
code but couldnt find it. Any ideas?

Thanks,
Tim



.


.
 
Thanks Doug. I understand. I didnt know Win32 registry
I/O calls could perform on files.

Regards,
Tim
-----Original Message-----
Tim:

Sure, you could use an ini file or create your own registry hive. To create
your own registry hive, which is not part of the default windows registry,
you can create a registry key(s) then export as a registry hive (I think...
its been awhile since I've done this). This is now your registry hive that
you can load, read, close via the Windows API functions RegLoadKey(),
RegOpenKeyEx(), RegCloseKey(). To manually load a registry hive, play with
"Load Hive" in regedit.

With EWF you will still need to commit and reboot atleast if your boot
partition is protected by EWF. The current
date/time/time zone is stored in
the registry on the boot partition. My application simply uses the return
value of the GetTimeZoneInformation() API to detect that the current time
zone has changed. I let Windows do this since Windows already knows how to
do it. I just detect this change by comparing what GetTimeZoneInformation()
API returns with what is stored in my registry hive. WHen they are
different, the system just went into or out of daylight saving so I shell a
bat file to commit and reboot. Use the EWF dll API for this. I would of
instead of a bat file but the EWF dll QFE came out too late for me to
deploy.

HTH... Doug

Doug, one more thing. You say you store it in a non-
protected hive in the registry. Can we separate registry
hives to another non-protected partition other than where
the OS exists?
-----Original Message-----
Tim:

const TCHAR* const CAE2_TIME_HIVE_KEY_NAME = _T ("CAE2_TIME_HIVE");
const TCHAR* const TZI_KEY = _T("TZI (0=none,1=Std,2=Daylight)");

CAE2_TIME_HIVE is the name of a registry hive that I
use
to store the TZI
key value. This registry hive is stored on a
partition
not protected by
EWF. In my master ghost image, TZI is preset to 99 which is the
uninitialized state. When my product is first built, TZI becomes 0, 1, or 2
depending on the current date and time zone.

HTH
.... Doug

"Tim Houle" <[email protected]>
wrote
in message
Doug,

What are the keys: CAE2_TIME_HIVE_KEY_NAME and TZI_KEY?

Thanks,
Tim
-----Original Message-----
Tim:

I couldn't find it either. Maybe I was dreamin...

Here it is. You will have to ignore some stuff as this
won't compile for
you as is:

bool Verify_LocalTime(void)
{
TIME_ZONE_INFORMATION tzi;
DWORD tzstat = 0;
TCHAR message[512];
int status = 0;
HKEY hKey;
DWORD keyType = 0;
DWORD size = sizeof(DWORD);
DWORD tzi_key = 0;
char command_line[120];
BOOL bstatus = 0;
int iShutdownDelay = 30;

// determine the active time zone
tzstat = GetTimeZoneInformation(&tzi);

// open CAE2_TIME_HIVE
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
CAE2_TIME_HIVE_KEY_NAME, NULL,
KEY_READ | KEY_WRITE, &hKey);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// query the value at "TZI (...)"
status = RegQueryValueEx(hKey, TZI_KEY, NULL, &keyType,
(LPBYTE)&tzi_key,
&size);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

if (tzi_key == 99)
{
// Initial condition detected:
// set correct value based on active time zone which
is assumed to be
correct
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD,
(LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),

((tzstat==TIME_ZONE_ID_STANDARD)||
(tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Stand
ard"):_T("Daylight"));
}
}
else // 0, 1, or 2
{
// determine if we switched in/out of daylight savings
depending
// on the active time zone
switch (tzstat)
{
case TIME_ZONE_ID_STANDARD:
case TIME_ZONE_ID_DAYLIGHT:
// determine if we need to commit a time change
if (tzstat != tzi_key)
{
// a time change has occured... set "TZI
(...)"
to
adjusted value
status = RegSetValueEx(hKey, TZI_KEY, NULL,
REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// log this change
ctx_log(GEN_LOG_INFO, _T("Local time has changed
from %s to %s"),

(((tzi_key==TIME_ZONE_ID_STANDARD)||
(tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Sta
ndard"):_T("Daylight")),
(tzstat==TIME_ZONE_ID_STANDARD?_T ("Standard"):_T
("Daylight")));

// blank the display
kpdDisplayBlank();
kpdClearLEDs();

// perform EWF commit and perform graceful restart
strcpy(command_line, "EWFCMT.BAT");
ctx_log(GEN_LOG_TRACE, _T("ShellProcessA cmd line: %
s"),
TSTR(command_line));
bstatus = ShellProcessA(command_line);
if (bstatus)
{
// update line 1 with time change message
status = kpdTextlineUpdate(KPD_LINE1, (char *)
time_change_text);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate
error - status = %d"),
status);
// update line 2 with restart system message
status = kpdTextlineUpdate(KPD_LINE2, (char *)
restart_system);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate
error - status = %d"),
status);

// get the Shutdown Delay from the registry
CConfigData::Instance()->Get_Shutdown_Delay
(iShutdownDelay);

// send Shutdown command to Remote firmware
if (RemoteOutThread::Instance()-
postShutdownDisplay(iShutdownDelay,
KPD_LINE1, (char *)restart_system) != REMOUT_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("Unable to post
Shutdown message to
remote."));

ctx_log(GEN_LOG_INFO, _T("Graceful RESTART has
been requested!"));
// delay before the restart
Sleep(2000);
// perform graceful shutdown and restart
Shutdown_and_Restart();
}
else // shell process error
{
ctx_log(GEN_LOG_ERROR, _T("ShellProcessA
error:
%
s"),
TSTR(command_line));
}
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),
(tzstat==TIME_ZONE_ID_STANDARD?_T ("Standard"):_T
("Daylight")));
}
break;

case TIME_ZONE_ID_UNKNOWN:
if (tzstat != tzi_key)
{
// set "TZI (...)" to correct value
status = RegSetValueEx(hKey, TZI_KEY, NULL,
REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
}
// daylight saving time is not used in the current
time zone
ctx_log(GEN_LOG_INFO, _T("Daylight saving time is
not used in the
current time zone."));
break;

default:
// error
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
break;
}
}

Done:
if (hKey)
RegCloseKey(hKey);

return true;
}

I'm looking For Sample Code For Daylight Savings
Adjustment using EWF - Detect, Commit and Reboot. Doug
H -
I've looked everywhere for your old post that has
sample
code but couldnt find it. Any ideas?

Thanks,
Tim



.



.


.
 
Slobodan,

Thanks for the input.

Regards,
Tim
-----Original Message-----
Ti Tim,

There are powerful functions documented and undocumented
functions for manipulating registry (mostly from
drivers). So using driver
you could accomplish this, without driver there is only
small possibility if you examine native API functions
that there might be
functions that would allow you to do that.

Best regards,
Slobodan

"Tim Houle" <[email protected]> wrote
in message news:[email protected]...
Doug, one more thing. You say you store it in a non-
protected hive in the registry. Can we separate registry
hives to another non-protected partition other than where
the OS exists?
-----Original Message-----
Tim:

const TCHAR* const CAE2_TIME_HIVE_KEY_NAME = _T ("CAE2_TIME_HIVE");
const TCHAR* const TZI_KEY = _T("TZI (0=none,1=Std,2=Daylight)");

CAE2_TIME_HIVE is the name of a registry hive that I
use
to store the TZI
key value. This registry hive is stored on a
partition
not protected by
EWF. In my master ghost image, TZI is preset to 99 which is the
uninitialized state. When my product is first built, TZI becomes 0, 1, or 2
depending on the current date and time zone.

HTH
.... Doug

"Tim Houle" <[email protected]>
wrote
in message
Doug,

What are the keys: CAE2_TIME_HIVE_KEY_NAME and TZI_KEY?

Thanks,
Tim
-----Original Message-----
Tim:

I couldn't find it either. Maybe I was dreamin...

Here it is. You will have to ignore some stuff as this
won't compile for
you as is:

bool Verify_LocalTime(void)
{
TIME_ZONE_INFORMATION tzi;
DWORD tzstat = 0;
TCHAR message[512];
int status = 0;
HKEY hKey;
DWORD keyType = 0;
DWORD size = sizeof(DWORD);
DWORD tzi_key = 0;
char command_line[120];
BOOL bstatus = 0;
int iShutdownDelay = 30;

// determine the active time zone
tzstat = GetTimeZoneInformation(&tzi);

// open CAE2_TIME_HIVE
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
CAE2_TIME_HIVE_KEY_NAME, NULL,
KEY_READ | KEY_WRITE, &hKey);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// query the value at "TZI (...)"
status = RegQueryValueEx(hKey, TZI_KEY, NULL, &keyType,
(LPBYTE)&tzi_key,
&size);
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

if (tzi_key == 99)
{
// Initial condition detected:
// set correct value based on active time zone which
is assumed to be
correct
status = RegSetValueEx(hKey, TZI_KEY, NULL, REG_DWORD,
(LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),

((tzstat==TIME_ZONE_ID_STANDARD)||
(tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Stand
ard"):_T("Daylight"));
}
}
else // 0, 1, or 2
{
// determine if we switched in/out of daylight savings
depending
// on the active time zone
switch (tzstat)
{
case TIME_ZONE_ID_STANDARD:
case TIME_ZONE_ID_DAYLIGHT:
// determine if we need to commit a time change
if (tzstat != tzi_key)
{
// a time change has occured... set "TZI
(...)"
to
adjusted value
status = RegSetValueEx(hKey, TZI_KEY, NULL,
REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
goto Done;
}

// log this change
ctx_log(GEN_LOG_INFO, _T("Local time has changed
from %s to %s"),

(((tzi_key==TIME_ZONE_ID_STANDARD)||
(tzi_key==TIME_ZONE_ID_UNKNOWN))?_T("Sta
ndard"):_T("Daylight")),
(tzstat==TIME_ZONE_ID_STANDARD?_T ("Standard"):_T
("Daylight")));

// blank the display
kpdDisplayBlank();
kpdClearLEDs();

// perform EWF commit and perform graceful restart
strcpy(command_line, "EWFCMT.BAT");
ctx_log(GEN_LOG_TRACE, _T("ShellProcessA cmd line: %
s"),
TSTR(command_line));
bstatus = ShellProcessA(command_line);
if (bstatus)
{
// update line 1 with time change message
status = kpdTextlineUpdate(KPD_LINE1, (char *)
time_change_text);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate
error - status = %d"),
status);
// update line 2 with restart system message
status = kpdTextlineUpdate(KPD_LINE2, (char *)
restart_system);
if (status != KPD_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("kpdTextlineUpdate
error - status = %d"),
status);

// get the Shutdown Delay from the registry
CConfigData::Instance()->Get_Shutdown_Delay
(iShutdownDelay);

// send Shutdown command to Remote firmware
if (RemoteOutThread::Instance()-
postShutdownDisplay(iShutdownDelay,
KPD_LINE1, (char *)restart_system) != REMOUT_SUCCESS)
ctx_log(GEN_LOG_ERROR, _T("Unable to post
Shutdown message to
remote."));

ctx_log(GEN_LOG_INFO, _T("Graceful RESTART has
been requested!"));
// delay before the restart
Sleep(2000);
// perform graceful shutdown and restart
Shutdown_and_Restart();
}
else // shell process error
{
ctx_log(GEN_LOG_ERROR, _T("ShellProcessA
error:
%
s"),
TSTR(command_line));
}
}
else
{
ctx_log(GEN_LOG_INFO, _T("Local time: %s"),
(tzstat==TIME_ZONE_ID_STANDARD?_T ("Standard"):_T
("Daylight")));
}
break;

case TIME_ZONE_ID_UNKNOWN:
if (tzstat != tzi_key)
{
// set "TZI (...)" to correct value
status = RegSetValueEx(hKey, TZI_KEY, NULL,
REG_DWORD, (LPBYTE)&tzstat,
sizeof(DWORD));
if (status != ERROR_SUCCESS)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
}
}
// daylight saving time is not used in the current
time zone
ctx_log(GEN_LOG_INFO, _T("Daylight saving time is
not used in the
current time zone."));
break;

default:
// error
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&message[0],
sizeof(message), NULL);
ctx_log(GEN_LOG_ERROR, _T("%s"), message);
break;
}
}

Done:
if (hKey)
RegCloseKey(hKey);

return true;
}

I'm looking For Sample Code For Daylight Savings
Adjustment using EWF - Detect, Commit and Reboot. Doug
H -
I've looked everywhere for your old post that has
sample
code but couldnt find it. Any ideas?

Thanks,
Tim



.



.


.
 
Back
Top