bill_proctor
asked on
Comm port addresses
How can you find the comport addresses using delphi?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
nope......
Sorry, reject my answer for now others will come up with an answer, or I will be back at it later.
;O)
brUINTje
Sorry, reject my answer for now others will come up with an answer, or I will be back at it later.
;O)
brUINTje
Hi Bill,
I've looked into a few things but the best I can come with is how to step through all the com ports available on a machine, and checking their properties like baudrate etc.
I don't know if it's what you need, but you can exchange information with a com port by calling it by its name and then checking the properties if its able to handle the request.
Could post some code if you think its worth a try.
Hope this helps
:O)
brUINTje.
I've looked into a few things but the best I can come with is how to step through all the com ports available on a machine, and checking their properties like baudrate etc.
I don't know if it's what you need, but you can exchange information with a com port by calling it by its name and then checking the properties if its able to handle the request.
Could post some code if you think its worth a try.
Hope this helps
:O)
brUINTje.
ASKER
I need to find the physical address to pass as a parameter. your answer has helped find the name of the assigned comports and will be useful. If you have any ideals on how to get the address it would also be helpful. I'll accept you answer either way after your response to this comment. thanks for you help
Hi Bill,
Don't know why the other guys don't look into this question but anyway........
After your last comment I got the message, this is the real base adress your looking for, after seeing all the of the web :O) I can say that this is a curiousity, most implementations of delphi use the ComPort name (Com1 etc.). But I found maybe some things to get you on your way,
http://www.geocities.com/~franzglaser/tpsrc/terminpas.txt
Here you will find a set of TP7.0 routines and one of them will get you the portbase adress where you're after.
It's in assembler so think it's portabl to Delphi! with the ComPort name as a byte you will get the portbase.
I haven't tried it yet,
Should questions arise just ask them.
:O)
brUINTje.
Don't know why the other guys don't look into this question but anyway........
After your last comment I got the message, this is the real base adress your looking for, after seeing all the of the web :O) I can say that this is a curiousity, most implementations of delphi use the ComPort name (Com1 etc.). But I found maybe some things to get you on your way,
http://www.geocities.com/~franzglaser/tpsrc/terminpas.txt
Here you will find a set of TP7.0 routines and one of them will get you the portbase adress where you're after.
It's in assembler so think it's portabl to Delphi! with the ComPort name as a byte you will get the portbase.
I haven't tried it yet,
Should questions arise just ask them.
:O)
brUINTje.
hi, bill.
this is DosText.exe, subpart of SysInfo from Jörg Braun he provides along with SysInfo. i dunno if he's the author, but as he provides it i assume it's for free:
PROGRAM DOSTest;
{$IFDEF DPMI} ERROR: Falscher Modus {$ENDIF}
{$IFDEF Windows} ERROR: Falscher Modus {$ENDIF}
USES
DOS;
FUNCTION Hex(i: WORD) : STRING;
TYPE
lrSplit = RECORD
Lo : BYTE;
Hi : BYTE;
END;
CONST
h : ARRAY[0..$F] OF CHAR = '0123456789ABCDEF';(* Hex *)
VAR
v : lrSplit ABSOLUTE i; (* direkte Zuweisung *)
s : STRING[9]; (* Rckgabewert *)
BEGIN
s := 'xxxx';
s[1] := h[v.Hi DIV $10]; (* 1. Stelle *)
s[2] := h[v.Hi MOD $10]; (* 2. Stelle *)
s[3] := h[v.Lo DIV $10]; (* 3. Stelle *)
s[4] := h[v.Lo MOD $10]; (* 4. Stelle *)
Hex := s;
END;
VAR
f : Text;
Ver : WORD;
BEGIN
Assign(f, 'C:\SYSINFO.DAT');
Rewrite(f);
(* Ermitteln der DOS-Version *)
Ver := DOSVersion;
WriteLn(f, 'Dos-Version=', Lo(Ver), '.', Hi(Ver));
(* Lesen der Schnittstellen-Adressen *)
WriteLn(f, 'COM1-Portadresse=', Hex(Word(Ptr(Seg0040,
$0000)^)));
WriteLn(f, 'COM2-Portadresse=', Hex(Word(Ptr(Seg0040,
$0002)^)));
WriteLn(f, 'COM3-Portadresse=', Hex(Word(Ptr(Seg0040,
$0004)^)));
WriteLn(f, 'COM4-Portadresse=', Hex(Word(Ptr(Seg0040,
$0006)^)));
WriteLn(f, 'LPT1-Portadresse=', Hex(Word(Ptr(Seg0040,
$0008)^)));
WriteLn(f, 'LPT2-Portadresse=', Hex(Word(Ptr(Seg0040,
$000A)^)));
WriteLn(f, 'LPT3-Portadresse=', Hex(Word(Ptr(Seg0040,
$000C)^)));
(* ..... *)
(* Lesen des BIOS-Datum *)
WriteLn(f, 'BIOS-Datum=', Chr(Byte(Ptr($F000, $FFF5)^)),
Chr(Byte(Ptr($F000, $FFF6)^)),
Chr(Byte(Ptr($F000, $FFF7)^)),
Chr(Byte(Ptr($F000, $FFF8)^)),
Chr(Byte(Ptr($F000, $FFF9)^)),
Chr(Byte(Ptr($F000, $FFFA)^)),
Chr(Byte(Ptr($F000, $FFFB)^)),
Chr(Byte(Ptr($F000, $FFFC)^)));
(* ..... *)
Close(f);
Assign(f, 'C:\~DONE~.DAT');
Rewrite(f);
(* es drfen keine Daten in die Datei *)
(* geschrieben werden! *)
Close(f);
END.
as you can see, the result can be found in c:\sysinfo.dat.
regards,
Black Death.
this is DosText.exe, subpart of SysInfo from Jörg Braun he provides along with SysInfo. i dunno if he's the author, but as he provides it i assume it's for free:
PROGRAM DOSTest;
{$IFDEF DPMI} ERROR: Falscher Modus {$ENDIF}
{$IFDEF Windows} ERROR: Falscher Modus {$ENDIF}
USES
DOS;
FUNCTION Hex(i: WORD) : STRING;
TYPE
lrSplit = RECORD
Lo : BYTE;
Hi : BYTE;
END;
CONST
h : ARRAY[0..$F] OF CHAR = '0123456789ABCDEF';(* Hex *)
VAR
v : lrSplit ABSOLUTE i; (* direkte Zuweisung *)
s : STRING[9]; (* Rckgabewert *)
BEGIN
s := 'xxxx';
s[1] := h[v.Hi DIV $10]; (* 1. Stelle *)
s[2] := h[v.Hi MOD $10]; (* 2. Stelle *)
s[3] := h[v.Lo DIV $10]; (* 3. Stelle *)
s[4] := h[v.Lo MOD $10]; (* 4. Stelle *)
Hex := s;
END;
VAR
f : Text;
Ver : WORD;
BEGIN
Assign(f, 'C:\SYSINFO.DAT');
Rewrite(f);
(* Ermitteln der DOS-Version *)
Ver := DOSVersion;
WriteLn(f, 'Dos-Version=', Lo(Ver), '.', Hi(Ver));
(* Lesen der Schnittstellen-Adressen *)
WriteLn(f, 'COM1-Portadresse=', Hex(Word(Ptr(Seg0040,
$0000)^)));
WriteLn(f, 'COM2-Portadresse=', Hex(Word(Ptr(Seg0040,
$0002)^)));
WriteLn(f, 'COM3-Portadresse=', Hex(Word(Ptr(Seg0040,
$0004)^)));
WriteLn(f, 'COM4-Portadresse=', Hex(Word(Ptr(Seg0040,
$0006)^)));
WriteLn(f, 'LPT1-Portadresse=', Hex(Word(Ptr(Seg0040,
$0008)^)));
WriteLn(f, 'LPT2-Portadresse=', Hex(Word(Ptr(Seg0040,
$000A)^)));
WriteLn(f, 'LPT3-Portadresse=', Hex(Word(Ptr(Seg0040,
$000C)^)));
(* ..... *)
(* Lesen des BIOS-Datum *)
WriteLn(f, 'BIOS-Datum=', Chr(Byte(Ptr($F000, $FFF5)^)),
Chr(Byte(Ptr($F000, $FFF6)^)),
Chr(Byte(Ptr($F000, $FFF7)^)),
Chr(Byte(Ptr($F000, $FFF8)^)),
Chr(Byte(Ptr($F000, $FFF9)^)),
Chr(Byte(Ptr($F000, $FFFA)^)),
Chr(Byte(Ptr($F000, $FFFB)^)),
Chr(Byte(Ptr($F000, $FFFC)^)));
(* ..... *)
Close(f);
Assign(f, 'C:\~DONE~.DAT');
Rewrite(f);
(* es drfen keine Daten in die Datei *)
(* geschrieben werden! *)
Close(f);
END.
as you can see, the result can be found in c:\sysinfo.dat.
regards,
Black Death.
so you wanted the names, not the addresses!
Black Death.
Black Death.
oops, sorry - just took a look at http://www.geocities.com/~franzglaser/tpsrc/terminpas.txt.
ok, ok.
have a nice day,
Black Death.
ok, ok.
have a nice day,
Black Death.
ASKER