Hi
I try to get from my Windows the install date
And have found this c++ source, why can i not get the date with masm32?
.data
sKey db "SOFTWARE\Microsoft\Windows NT\CurrentVersion",0
sValueName db "InstallDate",0
szFormat db "%d",0
rtype DWORD REG_DWORD
ftLength DWORD sizeof FILETIME
.data?
buff db 255 dup(?)
hKey DWORD ?
ft FILETIME <?>
.code
Invoke RegOpenKeyEx,HKEY_LOCAL_MACHINE, ADDR sKey, NULL, KEY_READ,ADDR hKey
.If (eax== ERROR_SUCCESS )
.If (hKey != NULL)
invoke RegQueryValueEx, hKey, ADDR sValueName, NULL, ADDR rtype,ADDR ft,ADDR ftLength
.If (EAX == ERROR_SUCCESS)
invoke crt_strftime, ADDR buff, SIZEOF buff, CTEXT ("%c"),ADDR ft
invoke MessageBox, NULL,addr buff, ADDR buff, MB_OK
.EndIf
invoke RegCloseKey, hKey
.EndIf
.EndIf
; struct tm* p = localtime((const time_t*)data);
; strftime((char*)installDate, MAX_PATH, "%c", p);
HKEY regKey;
UCHAR data[MAX_PATH] = "";
DWORD lengthData = sizeof(data);
UCHAR installDate[MAX_PATH] = "";
RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
(LPCSTR)regPath,
0,
KEY_READ,
®Key);
RegQueryValueEx(
regKey,
(LPCSTR)regToQuery,
NULL,
&valueType,
(LPBYTE)data,
&lengthData);
RegCloseKey(regKey);
struct tm* p = localtime((const time_t*)data);
strftime((char*)installDate, MAX_PATH, "%c", p);
return (UCHAR*)strdup((char*)installDate);
}
Please help me
Thanks,
give this a try...
Thanks it works
Why can i not use crt_strftime? then is the code small
you may use any code you like to display it :U
what your code is missing....
the dword time retrieved from the registry is in "time_t" format
it represents the number of seconds elapsed since midnight on January 1, 1970
so - first, you want to convert it to 64-bit "file time" format
to do that, (FileTime) = 10000000 * (time_t) + 116444736000000000
then, convert it to "system time" format to get all the pieces by using the FileTimeToSystemTime API function
also, your registry-read code had a few little problems
but - once you have the SYSTEMTIME structure filled, you may use any method you like to display the information