#include <Windows.h>
#pragma comment(linker, "/ENTRY:Entry")
#pragma comment(linker, "/subsystem:windows")
#include <commctrl.h>
#pragma comment(lib,"comctl32.lib")
#include <Setupapi.h>
#pragma comment(lib,"Setupapi.lib")
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HWND h_list;
HDEVINFO hDevInfo;
HWND h_Static;
switch (uMsg)
{
case WM_CREATE:
InitCommonControls();
h_list = CreateWindowEx(0,L"SysListView32",0,WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_SINGLESEL,0,0,994,600,hWnd,0,GetModuleHandle(0),0);
SendMessage(h_list,LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_FULLROWSELECT,LVS_EX_FULLROWSELECT);
LV_COLUMN lvc;
RtlZeroMemory(&lvc,sizeof(lvc));
lvc.mask = LVCF_TEXT+LVCF_WIDTH;
lvc.pszText = L"0";
lvc.cx = 100;
SendMessage(h_list, LVM_INSERTCOLUMN, 0, (LPARAM)&lvc);
for (int i = 1;i<SPDRP_MAXIMUM_PROPERTY;i++)
{
wchar_t temp[8] = {0};
wsprintf(temp,L"%d",i);
lvc.pszText = temp;
SendMessage(h_list,LVM_INSERTCOLUMN, i, (LPARAM)&lvc);
}
LV_ITEM lvi;
RtlZeroMemory(&lvi,sizeof(lvi));
hDevInfo = SetupDiGetClassDevs(0,0,0,DIGCF_ALLCLASSES | DIGCF_PRESENT);
SP_DEVINFO_DATA DeviceInfoData;
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
for (int x = 0;x<SPDRP_MAXIMUM_PROPERTY;x++)
{
for (DWORD i=0;SetupDiEnumDeviceInfo(hDevInfo,i, &DeviceInfoData);i++)
{
DWORD DataT;
LPTSTR buffer = NULL;
DWORD buffersize = 0;
while (!SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData,x, &DataT, (PBYTE)buffer, buffersize, &buffersize))
{
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
if (buffer) HeapFree(GetProcessHeap(),0,buffer);
buffer = (LPTSTR)HeapAlloc(GetProcessHeap(),0,buffersize);
}
else
{
break;
}
}
lvi.iItem = i;
if (x == SPDRP_ADDRESS || x == SPDRP_BUSNUMBER || x == SPDRP_BUSTYPEGUID || x == SPDRP_CAPABILITIES || x == SPDRP_CHARACTERISTICS
|| x == SPDRP_CONFIGFLAGS || x == SPDRP_DEVICE_POWER_DATA || x == SPDRP_DEVTYPE || x == SPDRP_EXCLUSIVE || x == SPDRP_INSTALL_STATE
|| x == SPDRP_LEGACYBUSTYPE || x == SPDRP_REMOVAL_POLICY || x == SPDRP_REMOVAL_POLICY_HW_DEFAULT || x == SPDRP_REMOVAL_POLICY_OVERRIDE
|| x == SPDRP_SECURITY || x == SPDRP_UI_NUMBER )//数字
{
wchar_t temp[260] = {0};
wsprintf(temp,L"0x%08x",buffer);
lvi.pszText = temp;
}
else //默认字符串。
{
lvi.pszText = buffer;
}
lvi.mask = LVIF_TEXT;
lvi.iSubItem = x;
if (x == 0)
{
SendMessage(h_list,LVM_INSERTITEM,0,(LPARAM)&lvi);
}
else
{
SendMessage(h_list,LVM_SETITEM,0,(LPARAM)&lvi);
}
if (buffer) HeapFree(GetProcessHeap(),0,buffer);
}
}
SetupDiDestroyDeviceInfoList(hDevInfo);
h_Static = CreateWindowEx(WS_EX_CLIENTEDGE,L"Static",0,WS_CHILD | WS_VISIBLE | SS_LEFT | WS_GROUP,0,600,994,150,hWnd,0,GetModuleHandle(0),0);
SendMessage(h_Static,WM_SETTEXT,0,(LPARAM)L"email:leguanyuan at 126 dot com\n\
homepage:http://correy.webs.com\n\
不足之处,敬请指导 \n\
每列(也就是数字)代表的含义,请查看相关的资料\n\
这个精简版,非完美,完整的版本,敬请原谅。");//注意上面的格式,不可以添加空格和注释。
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return(DefWindowProc(hWnd, uMsg, wParam, lParam));
}
return(0);
}
void Entry()
{
WNDCLASSEX sWndClassEx = {48,3,WindowProc,0,0,GetModuleHandle(0),0,LoadCursor(0,IDC_ARROW),(HBRUSH)6,0,L"correy",0};
ATOM a = RegisterClassEx(&sWndClassEx);
ShowWindow(CreateWindowEx(0,L"correy",L"made by correy",0x0Ca0000,CW_USEDEFAULT,CW_USEDEFAULT,999,768,0,0, GetModuleHandle(0),0),1);
MSG sMsg;
while (GetMessage(&sMsg, 0, 0, 0))
{
DispatchMessage(&sMsg);
}
ExitProcess(0);
}
//made at 2011.11.20
没有评论:
发表评论