[英]How to read QWORD (64-bit) from the registry in C++?
How do I read a REG_QWORD from the registry?如何从注册表中读取 REG_QWORD? Most specifically the HardwareInformation.qwMemorySize.
最具体的是 HardwareInformation.qwMemorySize。 I found that with it divided by 1024 then once again divided by 1024 you can get the Video memory in megabytes.
我发现将其除以 1024,然后再次除以 1024,您可以获得以兆字节为单位的视频 memory。 How can I read the QWORD first?
我怎样才能先读取QWORD? I can only find how to read DWORDs.
我只能找到如何读取 DWORD。
You read a QWORD
the exact same way you read a DWORD
, using RegQueryValueEx()
, just with a 64-bit integer variable instead of a 32-bit integer variable, eg:您读取
QWORD
的方式与读取DWORD
的方式完全相同,使用RegQueryValueEx()
,只是使用 64 位 integer 变量而不是 32 位 integer 变量,例如:
HKEY hKey;
if (RegOpenKeyEx(..., KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) {
QWORD value = 0; // or UINT64, ULONGLONG, ULONG64, ULARGE_INTEGER, etc...
DWORD dwType, dwSize = sizeof(value);
if (RegQueryValueEx(hKey, _T("HardwareInformation.qwMemorySize"), NULL, &dwType, reinterpret_cast<LPBYTE>(&value), &dwSize) == ERROR_SUCCESS) {
if (dwType == REG_QWORD || dwType == REG_BINARY) {
// use value as needed...
}
}
RegCloseKey(hKey);
}
Or, using RegGetValue()
instead:或者,改用
RegGetValue()
:
QWORD value = 0; // see above...
DWORD dwSize = sizeof(value);
if (RegGetValue(hkey, NULL, _T("HardwareInformation.qwMemorySize"), RRF_RT_QWORD, NULL, &value, &dwSize) == ERROR_SUCCESS) {
// use value as needed...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.