function IsPortAvailable(APort: string): boolean;
var
h: integer;
begin
Result := False;
h := CreateFile(PChar(APort), // 'COM1:', 'COM2:', etc.
GENERIC_READ or GENERIC_WRITE,
0, // do not share
nil, // default security attributes
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
0);
if h <> INVALID_HANDLE_VALUE then begin
Result := True;
CloseHandle(h);
end;
end;
Gewoon voor COM1 t/m 64 en LPT1 t/m 8 of zo opvragen. Lijkt me ietsje safer dan checken in de registry.