请问各位前辈,如何用DELPHI得到显卡的型号(217分)

  • 主题发起人 主题发起人 SuKiDelphi
  • 开始时间 开始时间
S

SuKiDelphi

Unregistered / Unconfirmed
GUEST, unregistred user!
请问各位前辈,如何用汇编或API(除读注册表的API)得到显卡的型号
 
用 EnumDisplayDevices
 
这个API只是得到显卡的驱动吧???先多谢了!!!(可能没有一个API可以得到显卡的型号吧)
 
驱动?请教有什么区别吗?你试了没有?
 
得到显卡的驱动和得到显卡的型号,基本是相同的;
但上面的兄弟说的EnumDisplayDevices函数好象没有?
 
你试试这个:
procedure TForm1.Button1Click(Sender: TObject);
var
lpDisplayDevice: TDisplayDevice;
dwFlags: DWORD;
cc: DWORD;
begin
memo1.Clear;
lpDisplayDevice.cb := sizeof(lpDisplayDevice);
dwFlags := 0;
cc:= 0;
while EnumDisplayDevices(nil, cc, lpDisplayDevice , dwFlags) do
begin
Inc(cc);
memo1.lines.add(lpDisplayDevice.DeviceString);
end;
end;
 
kaida,可以谢谢
 
帮顶!

╭=========================================╮

80G海量源代码,控件,书籍全免费狂下不停!

http://www.source520.com

╰=========================================╯
 
我以前试过了,得到的是显卡的驱动,还有,在不同系统是得到的结果可能不同(如 XP会得到二个驱动,因时间过了很长,记不起以前是如何解决这个问题的)

得到显卡的驱动和得到显卡的型号,基本是相同的???不会吧????
 
你再试试这个:
unit Main;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ImgList, ExtCtrls;

const
DIGCF_PRESENT = $00000002;
DIGCF_ALLCLASSES = $00000004;

SPDRP_DEVICEDESC = $00000000;
SPDRP_FRIENDLYNAME = $0000000C;

LINE_LEN = 256;

type
PSP_DEVINFO_DATA = ^SP_DEVINFO_DATA;
SP_DEVINFO_DATA = record
cbSize: DWORD;
ClassGuid: TGUID;
DevInst: DWORD;
Reserved: LongInt;
end;

type
TForm1 = class(TForm)
btn1: TButton;
Memo1: TMemo;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

function SetupDiGetClassDevs(const ClassGuid: PGUID; Enumerator: PChar;
hwndParent: HWND; Flags: DWORD): Cardinal; stdcall;
external 'Setupapi.dll' name 'SetupDiGetClassDevsA';

function SetupDiEnumDeviceInfo(DeviceInfoSet: Cardinal; MemberIndex: DWORD;
DeviceInfoData: PSP_DEVINFO_DATA): BOOL; stdcall;
external 'Setupapi.dll' name 'SetupDiEnumDeviceInfo';

function SetupDiGetDeviceRegistryProperty(DeviceInfoSet: Cardinal;
DeviceInfoData: PSP_DEVINFO_DATA; Propertys: DWORD;
PropertyRegDataType: PWORD; PropertyBuffer: PByte;
PropertyBufferSize: DWORD; RequiredSize: PDWORD): BOOL; stdcall;
external 'Setupapi.dll' name 'SetupDiGetDeviceRegistryPropertyA';

function SetupDiDestroyDeviceInfoList(DeviceInfoSet: Cardinal): BOOL; stdcall;
external 'Setupapi.dll' name 'SetupDiDestroyDeviceInfoList';

function SetupDiClassNameFromGuid(ClassGuid: PGUID; ClassName: PChar;
ClassNameSize: DWORD; RequiredSize: PDWORD): BOOL; stdcall;
external 'Setupapi.dll' name 'SetupDiClassNameFromGuidA';

function DeviceClassName(Guid: TGUID): string;
var
ClassName: PChar;
ClassNameSzie: Cardinal;
begin
ClassNameSzie := 0;
GetMem(ClassName, ClassNameSzie);
while not SetupDiClassNameFromGuid(@Guid, ClassName,
ClassNameSzie, @ClassNameSzie) do
begin
if (GetLastError() = ERROR_INSUFFICIENT_BUFFER) then
begin
if ClassName <> nil then FreeMem(ClassName);
GetMem(ClassName, ClassNameSzie);
end else
Break;
end;
Result := StrPas(ClassName);
if ClassName <> nil then FreeMem(ClassName);
end;

function DeviceFirendName(DeviceInfoSet: Cardinal;
DeviceInfoData: PSP_DEVINFO_DATA; var Name: string): Boolean;
var
DataT, buffersize: DWORD;
buffer: PChar;
begin
buffersize := 256;
buffer := AllocMem(buffersize);
if not SetupDiGetDeviceRegistryProperty(DeviceInfoSet, DeviceInfoData,
SPDRP_FRIENDLYNAME, @DataT, PByte(buffer), buffersize, @buffersize) then
begin
Result := SetupDiGetDeviceRegistryProperty(DeviceInfoSet, DeviceInfoData,
SPDRP_DEVICEDESC, @DataT, PByte(buffer), buffersize, @buffersize)
end
else
Result := True;
if Result then
Name := StrPas(buffer)
else
Name := 'Unknow';
FreeMem(buffer);
end;


procedure TForm1.btn1Click(Sender: TObject);
var
hDevInfo: Cardinal;
DeviceInfoData: SP_DEVINFO_DATA;
i : DWORD;
Name: string;
begin
Memo1.Lines.Clear;
hDevInfo := SetupDiGetClassDevs(nil, 0, 0, DIGCF_PRESENT or DIGCF_ALLCLASSES);
if (hDevInfo = INVALID_HANDLE_VALUE) then Exit;
DeviceInfoData.cbSize := SizeOf(SP_DEVINFO_DATA);
i := 0;
while SetupDiEnumDeviceInfo(hDevInfo, i, @DeviceInfoData) do
begin
if DeviceClassName(DeviceInfoData.ClassGuid)='Display' then begin
DeviceFirendName(hDevInfo, @DeviceInfoData, Name);
Memo1.Lines.Add(Name);
end ;
Inc(i);
end;
SetupDiDestroyDeviceInfoList(hDevInfo);
end;

end.
 
先多谢你多次热心的回答,其实你两次用的 API 和读注册表差不多吧[:)]
 
帮顶!

╭=========================================╮

80G海量源代码,控件,书籍全免费狂下不停!

http://www.source520.com

个人网站站长开发推广同盟,让所有人知道你的世界!

http://www.source520.com/search/search.asp

╰=========================================╯
 
有心了!!!但不要再顶了[:)]
 
发给你了(珍藏的)
 
???????????????
算了
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
913
SUNSTONE的Delphi笔记
S
后退
顶部