VC++如何获取操作系统类型及显卡信息?小弟找了一下午了,还没解决

e251396 2008-12-05 04:17:50
我是个donet程序员,但一个项目中需要用到VC来获取相关信息,但我一点也不懂VC,所以请高手能帮忙一下。谢谢各位了。
...全文
716 点赞 收藏 19
写回复
19 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
看看!!!!!!!!!!!!
回复
adbc_6677 2011-04-03
顶!!!
回复
taianmonkey 2008-12-06
OSVERSIONINFO OSVersionInfo;
OSVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&OSVersionInfo);
if (OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT
&& OSVersionInfo.dwMajorVersion == 5
&& OSVersionInfo.dwMinorVersion == 0)
{
AfxMessageBox("Windows 2000 OS!");
}
else if(OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT
&& OSVersionInfo.dwMajorVersion == 5
&& OSVersionInfo.dwMinorVersion == 1)
{
AfxMessageBox("Windows XP OS !");
}
else if(OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS
&& OSVersionInfo.dwMajorVersion == 4
&& OSVersionInfo.dwMinorVersion == 0)
{
AfxMessageBox("Windows 98 OS!");
}
回复
taianmonkey 2008-12-06
CString strRet = _T("显卡:");
CString strMemSize = _T("");
HRESULT hres = E_FAIL;

IEnumWbemClassObject* pEnumerator = NULL;
hres = m_pSvc->ExecQuery(
bstr_t("WQL"),
bstr_t("SELECT * FROM Win32_VideoController"),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);

if (FAILED(hres))
{
cout << "Query for operating system name failed."
<< " Error code = 0x"
<< hex << hres << endl;
m_pSvc->Release();
CoUninitialize();
return FALSE; // Program has failed.
}

// Step 7: -------------------------------------------------
// Get the data from the query in step 6 -------------------

IWbemClassObject *pclsObj;
ULONG uReturn = 0;

LONGLONG llTotal = 0;

while (pEnumerator)
{
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1,
&pclsObj, &uReturn);

if(0 == uReturn)
{
break;
}

VARIANT vtProp;

// Get the value of the Name property
hr = pclsObj->Get(L"Description", 0, &vtProp, 0, 0);

strRet += vtProp.bstrVal;

// VariantClear(&vtProp);

// hr = pclsObj->Get(L"AdapterRAM", 0, &vtProp, 0, 0);

//strMemSize = vtProp.llVal;

// llTotal += (LONGLONG)&vtProp ;
// strMemSize.Format( _T("(%I64dM)") , ( llTotal / (1024*1024) ) );

// strRet += strMemSize;

VariantClear(&vtProp);
}

return strRet;
回复
Thinkfeng 2008-12-05
我知道java中能获取系统信息 没用过.net
应该有吧
回复
dbhme 2008-12-05
ding
回复
android2008 2008-12-05
ding
回复
dbhme 2008-12-05
up
回复
android2008 2008-12-05
up
回复
scq2099yt 2008-12-05
up 6 floor
回复
lzg0001 2008-12-05
收藏
回复
oyljerry 2008-12-05
把上面的guidScsiRaid 换成{4d36e96c-e325-11ce-bfc1-08002be10318} ,上面的代码基本上就差不多了
回复
e251396 2008-12-05
能给出具体的代码吗?我没写过这样的代码.
回复
oyljerry 2008-12-05
Display Adapters
Class = Display
ClassGuid = {4d36e968-e325-11ce-bfc1-08002be10318}

Multimedia
Class = Media
ClassGuid = {4d36e96c-e325-11ce-bfc1-08002be10318}

#include "stdafx.h"
#include <stdlib.h>
#include <windows.h>
#include <setupapi.h>

int main(int argc, char* argv[])
{
DWORD dwIdx = 0;
SP_DEVINFO_DATA adapterData;
DWORD dwType = 0;
DWORD dwBuflen = 0;
PUCHAR pBuf = NULL;
HDEVINFO hScsi = INVALID_HANDLE_VALUE;
GUID guidScsiRaid = {
0x4D36E97B,
0xE325,
0x11CE,
{0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18}
};

BOOL bret = FALSE;

hScsi = SetupDiGetClassDevs(&guidScsiRaid
, NULL, NULL, DIGCF_PRESENT);

adapterData.cbSize = sizeof(SP_DEVINFO_DATA);

for(dwIdx = 0; SetupDiEnumDeviceInfo(hScsi, dwIdx, &adapterData); dwIdx++)
{
SetupDiGetDeviceRegistryProperty(
hScsi,
&adapterData,
SPDRP_DEVICEDESC,
&dwType,
NULL,
0,
&dwBuflen
);

if(ERROR_INSUFFICIENT_BUFFER == GetLastError())
{
pBuf = (PUCHAR)malloc(dwBuflen);
if(SetupDiGetDeviceRegistryProperty(
hScsi,
&adapterData,
SPDRP_DEVICEDESC,
&dwType,
pBuf,
dwBuflen,
NULL
))
{
printf("%s\n", pBuf);
}

free(pBuf);
pBuf = NULL;
}
}

SetupDiDestroyDeviceInfoList(hScsi);

return 0;
}
回复
GetSystemInfo()好像得不到这么多信息
试试
Win32_DisplayConfiguration
回复
oyljerry 2008-12-05
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class
下面依此读取所有的项,直到找到Class键的值为Display(显卡)或MEDIA(声卡),
找到后读取下面的键值

也可以通过WMI来读取。。。

如果在没有装驱动的情况下读取信息,估计需要通过读取主板bios,显卡bios等来得到。。
回复
e251396 2008-12-05
芯片型号,显存及驱动程序的版本之类的啊
回复
获取操作系统版本:GetVersionEx,例子 http://msdn.microsoft.com/en-us/library/ms724429(VS.85).aspx

//显卡信息:要得到哪些信息?
回复
e251396 2008-12-05
没人知道吗?
回复
相关推荐
发帖
硬件/系统
创建于2007-09-28

2594

社区成员

VC/MFC 硬件/系统
申请成为版主
帖子事件
创建了帖子
2008-12-05 04:17
社区公告
暂无公告