function ComPortAvailable(Port: PChar) : boolean;
Var
DeviceName: Array[0..80] of Char;
ComFile: THandle;
begin
StrPCopy(DeviceName, Port);
ComFile := CreateFile(DeviceName, GENERIC_READ or GENERIC_WRITE, 0, Nil,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);
Result := ComFile <> INVALID_HANDLE_VALUE;
CloseHandle(ComFile);
end;