Click here to Skip to main content
15,910,009 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to use GetTimeZoneInformation Pin
CodingLover1-Jan-08 18:54
CodingLover1-Jan-08 18:54 
AnswerRe: How to use GetTimeZoneInformation Pin
CodingLover1-Jan-08 22:42
CodingLover1-Jan-08 22:42 
GeneralRe: How to use GetTimeZoneInformation Pin
CodingLover2-Jan-08 0:05
CodingLover2-Jan-08 0:05 
QuestionRe: How to use GetTimeZoneInformation Pin
David Crow2-Jan-08 2:52
David Crow2-Jan-08 2:52 
GeneralRe: How to use GetTimeZoneInformation Pin
CodingLover2-Jan-08 18:38
CodingLover2-Jan-08 18:38 
GeneralRe: How to use GetTimeZoneInformation Pin
dan o3-Jan-08 5:59
dan o3-Jan-08 5:59 
GeneralRe: How to use GetTimeZoneInformation Pin
CodingLover3-Jan-08 14:23
CodingLover3-Jan-08 14:23 
GeneralRe: How to use GetTimeZoneInformation Pin
dan o3-Jan-08 21:36
dan o3-Jan-08 21:36 
i will use something like this:

i will store all zones into m_pszTimeZones
and after that it is easy to get information you want

.h
CStringArray m_pszTimeZones;

.cpp
void <myclassname>::TestTM
{
HKEY hKey, Key;
DWORD dwType = REG_SZ;
int iRet = 0;
CString strName, strValue, strPath, strKey;

strPath = _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones");

iRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, strPath, 0, KEY_READ, &amp;hKey);

if (iRet != ERROR_SUCCESS)
return;

TCHAR achKey[MAX_PATH];
TCHAR achClass[MAX_PATH] = _T("");
DWORD cchClassName = MAX_PATH;
DWORD cSubKeys;
DWORD cbMaxSubKey;
DWORD cchMaxClass;
DWORD cValues;
DWORD cchMaxValue;
DWORD cbMaxValueData;
DWORD cbSecurityDescriptor;
FILETIME ftLastWriteTime;

DWORD i;
DWORD retCode;

TCHAR buffer[MAX_PATH];
DWORD dwSize = sizeof(buffer);

// Get the class name and the value count.
RegQueryInfoKey(hKey, // key handle
achClass, // buffer for class name
&cchClassName, // length of class string
NULL, // reserved
&cSubKeys, // number of subkeys
&cbMaxSubKey, // longest subkey size
&cchMaxClass, // longest class string
&cValues, // number of values for this key
&cchMaxValue, // longest value name
&cbMaxValueData, // longest value data
&cbSecurityDescriptor, // security descriptor
&ftLastWriteTime); // last write time

// Enumerate the child keys, until RegEnumKeyEx fails. Then
// get the name of each child key and copy it into the list box.

for (i = 0, retCode = ERROR_SUCCESS;retCode == ERROR_SUCCESS; i++)
{
ZeroMemory(&amp;achKey, sizeof(achKey));
cbMaxSubKey = sizeof(achKey);
retCode = RegEnumKeyEx(hKey, i, achKey, &cbMaxSubKey, NULL, NULL, NULL, &ftLastWriteTime);
if (retCode == (DWORD)ERROR_SUCCESS)
{
strName.Format( _T("%s"), achKey);

strKey = strPath + "\\" + strName;
iRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, strKey, 0, KEY_READ, &Key);

if (iRet == ERROR_SUCCESS)
{
ZeroMemory(&buffer, sizeof(buffer));
dwSize = sizeof(buffer); //again
iRet = RegQueryValueEx(Key, _T("Display"), NULL, &dwType, (BYTE *)buffer, &dwSize);

if (iRet == ERROR_SUCCESS)
{
strValue.Format(_T("%s"), buffer);
m_pszTimeZones.Add( strValue );
}

RegCloseKey(Key);
}
}
}
RegCloseKey( hKey );
}
GeneralRe: How to use GetTimeZoneInformation Pin
CodingLover3-Jan-08 21:47
CodingLover3-Jan-08 21:47 
GeneralRe: How to use GetTimeZoneInformation Pin
dan o3-Jan-08 22:06
dan o3-Jan-08 22:06 
GeneralRe: How to use GetTimeZoneInformation Pin
CodingLover3-Jan-08 22:10
CodingLover3-Jan-08 22:10 
GeneralRe: How to use GetTimeZoneInformation Pin
CodingLover6-Jan-08 19:49
CodingLover6-Jan-08 19:49 
GeneralRe: How to use GetTimeZoneInformation Pin
dan o6-Jan-08 22:28
dan o6-Jan-08 22:28 
GeneralRe: How to use GetTimeZoneInformation Pin
CodingLover6-Jan-08 22:39
CodingLover6-Jan-08 22:39 
GeneralRe: How to use GetTimeZoneInformation Pin
dan o6-Jan-08 23:10
dan o6-Jan-08 23:10 
GeneralRe: How to use GetTimeZoneInformation Pin
CodingLover6-Jan-08 23:27
CodingLover6-Jan-08 23:27 
GeneralRe: How to use GetTimeZoneInformation Pin
dan o6-Jan-08 23:43
dan o6-Jan-08 23:43 
GeneralRe: How to use GetTimeZoneInformation Pin
CodingLover6-Jan-08 23:57
CodingLover6-Jan-08 23:57 
QuestionQuite similer application Pin
CodingLover7-Jan-08 18:33
CodingLover7-Jan-08 18:33 
GeneralRe: Quite similer application Pin
dan o8-Jan-08 1:05
dan o8-Jan-08 1:05 
GeneralSome API Pin
john56321-Jan-08 18:46
john56321-Jan-08 18:46 
GeneralRe: Some API Pin
Naveen1-Jan-08 18:52
Naveen1-Jan-08 18:52 
GeneralRe: Some API Pin
Nishad S1-Jan-08 19:01
Nishad S1-Jan-08 19:01 
Generalverifying file path Pin
neha.agarwal271-Jan-08 18:25
neha.agarwal271-Jan-08 18:25 
GeneralRe: verifying file path Pin
Nishad S1-Jan-08 18:48
Nishad S1-Jan-08 18:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.