Q&A

  • [답변]드라이버목록 구하는 루틴입니다...
김영대님의 팁란에 찾아보니까 있네요....루틴을 첨부합니다...

unit Unit1;



interface



uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls;



type

TForm1 = class(TForm)

Button1: TButton;

Memo1: TMemo;

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;



var

Form1: TForm1;



implementation

{$R *.DFM}



// 플로피 디스크의 인치

function FloppyDriveSize(Drive: Char): String;

type

PDIOC_REG = ^TDIOC_Registers;

TDIOC_Registers = record

Reg_EBX, Reg_EDX, Reg_ECX, Reg_EAX,

Reg_EDI, Reg_ESI, Reg_Flags : DWORD

end;

const

VWIN32_DIOC_DOS_INT13 = 4;

var

H : THandle;

R : TDIOC_Registers;

C : DWORD;

begin

Result := 'unknown';

H := CreateFile('.VWIN32', 0, 0, nil, 0, 0, 0);

if H <> INVALID_HANDLE_VALUE then

try

R.Reg_EAX := $800;

R.Reg_EDX := ord(upcase(Drive)) - Ord('A');

if DeviceIOControl(H, VWIN32_DIOC_DOS_INT13, @R,

SizeOf (R), @R, SizeOf (R), C, nil) and

(R.Reg_Flags and 1 = 0) then

if R.Reg_EBX and $FF < 3 then

Result := '5.25'

else

Result := '3.5';

finally

CloseHandle(H);

end

end;



procedure ListDrives(Strings: TStrings);

const

BufSize = 256;

var

Buffer: PChar;

P: PChar;

DrivePchar: array[0..5] of Char;

iDriveType: Integer;

begin

GetMem(Buffer, BufSize);

try

Strings.BeginUpdate;

try

Strings.Clear;

// 시스템에 설치된 드라이브 목록 구하기(형태 c:d:)

if GetLogicalDriveStrings(BufSize, Buffer) <> 0 then

begin

P := Buffer;

while P^ <> #0 do

begin

iDriveType := GetDriveType(P);

case iDriveType of

DRIVE_REMOVABLE:

begin

Strings.Add(P+' - Floppy drive ('+

FloppyDriveSize(P[0])+')'); // 인치 구분

end;

DRIVE_FIXED:

Strings.Add(P+' - Hard drive');

DRIVE_REMOTE:

Strings.Add(P+' - Network drive');

DRIVE_CDROM:

Strings.Add(P+' - CD-ROM drive');

DRIVE_RAMDISK:

Strings.Add(P+' - RAM drive');

end;

Inc(P, StrLen(P) + 1);

end;

end;

finally

Strings.EndUpdate;

end;

finally

FreeMem(Buffer, BufSize);

end;

end;



procedure TForm1.Button1Click(Sender: TObject);

begin

ListDrives(Memo1.Lines);

end;



end.



0  COMMENTS