windows installiert?

Hier ne kleine Routine, die das Installationsdatum aus der Registry ausliest und formatiert ausgibt (nur unter XP getestet):
Code:
UCHAR* WinInstallationDate()
{
	UCHAR regPath[MAX_PATH];
	UCHAR regToQuery[MAX_PATH];
	DWORD valueType;

	OSVERSIONINFO os;
	os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	GetVersionEx(&os);

	if (os.dwPlatformId == VER_PLATFORM_WIN32_NT)
	{
		strcpy((char*)regPath, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
		strcpy((char*)regToQuery, "InstallDate");
		valueType = REG_DWORD;
	}
	else
	{
		strcpy((char*)regPath, "Software\\Microsoft\\Windows\\CurrentVersion");
		strcpy((char*)regToQuery, "FirstInstallDateTime");
		valueType = REG_BINARY;
	}

	HKEY regKey;
	UCHAR data[MAX_PATH] = "";
	DWORD lengthData = sizeof(data);
	UCHAR installDate[MAX_PATH] = "";

	RegOpenKeyEx(
		HKEY_LOCAL_MACHINE,
		(LPCSTR)regPath,
		0,
		KEY_READ,
		&regKey);

	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);
}
 
Zuletzt bearbeitet:
Zurück