PDA

View Full Version : Video Card Drivers



civerson
03-11-2003, 03:35 PM
I hope this is an easy question. I need to get the mfgr, driver version and resolution for the Video Card installed.
Is there a way to do this in Delphi or DelphiX? If so, how.
I have Delphi 6 and the latest DelphiX installed.

Alimonster
03-11-2003, 10:16 PM
The TDirectDraw.IDraw[/4/7].GetDeviceIdentifier method (in dxdraws.pas and DirectX.pas of the DelphiX source) looks promising, though there may be a simpler way (I've not had time to check). You should know the resolution if using fullscreen mode (you set it!), else you can use the GetDeviceCaps API function (with HORZRES and VERTRES if memory serves).

civerson
04-11-2003, 03:52 PM
How do I implenet the GetDeviceIdentifier method? Do you have some sample code?

Alimonster
04-11-2003, 04:05 PM
I've never actually use DelphiX myself, ;) but I'll try to post some example code soon (in a couple of hours since I'm still at work :(). The example might not compile exactly but it'll be close enough to get you started.

I'll throw two pages at MSDN your way to begin with so you can read about them. Keep in mind that the docs are C++ based...

IDirectDraw7.GetDeviceIdentifier (http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/ddraw7/directdraw7/ddref_0hfb.asp)
DeviceIdentifier2 structure (http://msdn.microsoft.com/archive/en-us/ddraw7/directdraw7/ddref_4fg7.asp)

But yeah, the example should be coming sometime after about 5:30 UK time. ;)

Alimonster
04-11-2003, 06:34 PM
The following _should_ do the trick (based solely on looking at the DelphiX source and trying a non-DelphiX test...)

You want to declare a variable of type TDDDeviceIdentifier. You then call the appropriate function...

var
ID: TDDDeviceIdentifier;
begin
DirectDraw1.IDraw7.GetDeviceIdentifier(ID, 0);
// todo: use stuff in ID record however you want
end;

That's it, as far as I can see. ;) I'm not sure where the TDirectDraw-based component comes from (what I called DirectDraw1) since I've not used DelphiX. I'd be surprised if it wasn't a visual thing, easily available, though! You can also use IDraw4 instead of IDraw7 I think.

I'll quote from the relevant header so you know what ID will contain after calling the above function. Lots of info for you...


TDDDeviceIdentifier = record
//
// These elements are for presentation to the user only. They should not be used to identify particular
// drivers, since this is unreliable and many different strings may be associated with the same
// device, and the same driver from different vendors.
//
szDriver: array[0..MAX_DDDEVICEID_STRING-1] of Char;
szDescription: array[0..MAX_DDDEVICEID_STRING-1] of Char;

//
// This element is the version of the DirectDraw/3D driver. It is legal to do <, > comparisons
// on the whole 64 bits. Caution should be exercised if you use this element to identify problematic
// drivers. It is recommended that guidDeviceIdentifier is used for this purpose.
//
// This version has the form:
// wProduct = HIWORD(liDriverVersion.HighPart)
// wVersion = LOWORD(liDriverVersion.HighPart)
// wSubVersion = HIWORD(liDriverVersion.LowPart)
// wBuild = LOWORD(liDriverVersion.LowPart)
//
liDriverVersion: TLargeInteger; // Defined for applications and other 32 bit components

//
// These elements can be used to identify particular chipsets. Use with extreme caution.
// dwVendorId Identifies the manufacturer. May be zero if unknown.
// dwDeviceId Identifies the type of chipset. May be zero if unknown.
// dwSubSysId Identifies the subsystem, typically this means the particular board. May be zero if unknown.
// dwRevision Identifies the revision level of the chipset. May be zero if unknown.
//
dwVendorId: DWORD;
dwDeviceId: DWORD;
dwSubSysId: DWORD;
dwRevision: DWORD;

//
// This element can be used to check changes in driver/chipset. This GUID is a unique identifier for the
// driver/chipset pair. Use this element if you wish to track changes to the driver/chipset in order to
// reprofile the graphics subsystem.
// This element can also be used to identify particular problematic drivers.
//
guidDeviceIdentifier: TGUID;
end;

civerson
04-11-2003, 06:51 PM
How do I define DirectDraw1. I tried this:
var
DD : TDirectDraw;

But I think I have to initialize it with a value, or create it. Doing this:

dd.Create(GUID);

Needs a GUID and I don't know what it is.

Alimonster
04-11-2003, 06:55 PM
There should already be one, and it will be created automatically (I'd assume). Check the TDXDraw component, actually -- it looks like it has a DDraw property, meaning the previous example would be something like this:

DXDraw1.DDraw.IDraw7.GetDeviceIdentifier(ID, 0);

(I think!)

civerson
04-11-2003, 06:56 PM
Maybe it would be better to use the DirectX SDK from Microsoft. Have you ever used it?

Alimonster
04-11-2003, 07:05 PM
Maybe it would be better to use the DirectX SDK from Microsoft. Have you ever used it?
Yep (http://www.alistairkeys.co.uk/ddraw1.shtml) :P

The problem I'm having helping you is simply that I've never used DelphiX, have no idea of what classes it contains and have no way to compile any test code using it. Aside from that, it's been a cinch so far! But seriously, did the last thing I suggested not work? I can't think why it wouldn't have (you should have a TDXDraw object, and all the properties tally up from the source code).

cairnswm
05-11-2003, 04:59 AM
I've got a feeling this isn;t what you want but I thought I'd post if anyway:


procedure TForm1.ShowDrivers;
Var
S &#58; String;
I &#58; Integer;
begin
For I &#58;= 0 to DXDraw1.DDraw.Drivers.Count - 1 do
S &#58;= S + IntToStr&#40;I&#41; +'&#58; '+ DXDraw1.DDraw.Drivers&#91;I&#93;.Description+ #10#13;
ShowMessage&#40;S&#41;;
// todo&#58; use stuff in ID record however you want
end;

civerson
05-11-2003, 01:52 PM
I got it to work, kinda.
I can populate the ID structure but it doesn't have all the info I need.
I can get the card name but no version numbers for the driver.
Looking at the .pas file section from above the code completion doesn't show all the fields that are in your example.
I am going to try the files from http://clootie.narod.ru/delphi/DX90/ because I have DirectX9 and I think the DelphiX stuff I have is for DirectX7.
Thanks for your help so far.

civerson
05-11-2003, 01:59 PM
This is what I have so far.


procedure TForm1.Button1Click(Sender: TObject);
var
DD : TDirectDraw;
DXDriver : TDirectXDriver;
ID: TDDDeviceIdentifier;

begin
DXDriver := dxdraw1.Drivers[0];
dd := TDirectDraw.Create(DXDriver.GUID);
dd.IDraw7.GetDeviceIdentifier(id, 1);

ListBox1.Items.Add('Description: ' + id.szDescription);
ListBox1.Items.Add('Driver Name: ' + DXDriver.DriverName);
ListBox1.Items.Add('Driver Version: ' + id.szDriver);
ListBox1.Items.Add('Device ID: ' + IntToStr(id.dwDeviceId));
ListBox1.Items.Add(IntToStr(id.dwRevision));
ListBox1.Items.Add(IntToStr(id.dwSubSysId));
ListBox1.Items.Add(IntToStr(id.liDriverVersion));
end;

civerson
05-11-2003, 10:34 PM
The code above is kinda working. The id.liDriverVersion does not get a value. In VB it uses a low and hi. This is just an int64.

Ideas?

Alimonster
05-11-2003, 11:31 PM
Right, I've finally found a Delphi 7 compatible version of DelphiX and I've installed it (from Maxx's Delphi site (http://maxxdelphisite.free.fr/delphix.htm), got from an old Turbo post I remembered).

Note that if you have a TDXDraw component (you should!) then you can get access to the DDraw of it. I tried using IDraw7 and it raised an exception for some reason, but it works with IDraw4 -- I guess there's a property or {$DEFINE} somewhere that controls what version of DirectDraw DelphiX will target, but I don't know it since this is my first time looking at it.

Bad news and good news. I tried the liDriverVersion field but for me, it gives 0 (no info :(). The good news is that you _should_ be able to typecast it to a _LARGE_INTEGER structure to retrieve the relevant parts. The following code shows all the info. If you get 0 results then that probably means that you're out of luck getting info for that particular graphics card.

procedure TForm1.BitBtn1Click(Sender: TObject);
var
id: TDDDeviceIdentifier;
Temp: _LARGE_INTEGER;
begin
dxdraw1.DDraw.IDraw4.GetDeviceIdentifier(id, 0);
Showmessage(inttostr(id.liDriverVersion));

Temp := _LARGE_INTEGER(id.liDriverVersion);
ShowMessage(IntToStr(HIWORD(Temp.HighPart)));
ShowMessage(IntToStr(LOWORD(Temp.HighPart)));
ShowMessage(IntToStr(HIWORD(Temp.LowPart)));
ShowMessage(IntToStr(LOWORD(Temp.LowPart)));
ShowMessage(id.szDriver);
ShowMessage(id.szDescription);
ShowMessage(IntToStr(id.dwVendorId));
ShowMessage(IntToStr(id.dwDeviceId));
ShowMessage(IntToStr(id.dwSubSysId));
ShowMessage(IntToStr(id.dwRevision));
end;