List Devices (LPT, COM ports, ...)
The following procedure will list all the devices on your computer. You can then extract the com ports and printer ports by looking for the 'COM' and 'LPT' characters in the list.
Add a Memo and a Button and place this code in the OnClick of a button...
~~~~~~~~~~~~~~~~~~~~~~~~~
procedure TForm1.Button1Click(Sender: TObject) ;
var
istr: string;
isize, j: dword;
begin
setlength(istr, 4000) ;
isize := QueryDosDevice(nil, @istr[1], 4000) ;
for j := 1 to isize do
if istr[j] = #0 then istr[j] := #10;
memo1.lines.CommaText := istr;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~
Delphi tips navigator:
» Get system info (free memory, etc)
« Get the Height/Width of a Character (for OwnerDrawing and printing)
Add a Memo and a Button and place this code in the OnClick of a button...
~~~~~~~~~~~~~~~~~~~~~~~~~
procedure TForm1.Button1Click(Sender: TObject) ;
var
istr: string;
isize, j: dword;
begin
setlength(istr, 4000) ;
isize := QueryDosDevice(nil, @istr[1], 4000) ;
for j := 1 to isize do
if istr[j] = #0 then istr[j] := #10;
memo1.lines.CommaText := istr;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~
Delphi tips navigator:
» Get system info (free memory, etc)
« Get the Height/Width of a Character (for OwnerDrawing and printing)
Source...