Einzelnen Beitrag anzeigen

Astat

Registriert seit: 2. Dez 2009
Ort: München
320 Beiträge
 
Lazarus
 
#4

Re: Prüfen ob Treiber geladen wurde

  Alt 7. Mär 2010, 01:29
Hallo Codewalker, anbei Sample.

Delphi-Quellcode:

uses
  windows,
  SysUtils;

function EnumDeviceDrivers(lpImageBase: PPointer; cb: DWORD;
  var lpcbNeeded: DWORD): BOOL; stdcall; external 'psapi.dll'
    name 'EnumDeviceDrivers';

function GetDeviceDriverBaseName(ImageBase: Pointer; lpBaseName: PChar;
  nSize: DWORD): DWORD; stdcall; external 'psapi.dll'
    name 'GetDeviceDriverBaseNameA';

var
  lpcbNeeded: DWORD;
  ppArray: PPointerArray;
  szDriver: PChar;
  i: integer;
  count: integer;
begin
  if not EnumDevicedrivers(nil, 0, lpcbNeeded) then
    RaiseLastWin32Error;

  GetMem(ppArray, lpcbNeeded);
  try
    if EnumDevicedrivers(@ppArray[0], lpcbNeeded, lpcbNeeded) then begin
      count := lpcbNeeded div 4;
      GetMem(szDriver, MAX_PATH);
      try
        for i := 0 to count -1 do begin
          if GetDevicedriverBaseName(ppArray[i], szDriver, MAX_PATH) = 0 then
            RaiseLastWin32Error;
          writeln(inttohex(dword(ppArray[i]), 8) + ' - ' + szDriver);
        end;
      finally
        freemem(szDriver);
      end;
    end;
  finally
    freemem(ppArray);
  end;
  readln;
end.
lg. Astat
Lanthan Astat
06810110811210410503210511511603209711003210010110 9032084097103
03211611111604403209711003210010110903210010510103 2108101116122
11610103209010110510810103206711110010103210511003 2068101108112
10410503210310111509910411410510109810111003211910 5114100046
  Mit Zitat antworten Zitat