1
소스입니다. 꼭좀 도움을....
unit autocom;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
OoMisc, AdPort, StdCtrls, comobj, Comserv, commctrl, commdlg, vclcom,
comctrls, comstrs, AdSelCom, AdDial, AdGetNum, AdPBEdit, AdIniDB, AdPBook, AdModem, AdModDB,
AdProtcl, AdPStat, AdStatLt, AdExcept, AdxBP, FileCtrl,
AdFax, AdFStat, AdFaxPrn, AdFPStat, AdFaxCvt, AdTapi, AdTStat, AdXPort,
ShellApi;
type
TForm1 = class(TForm)
Button1: TButton;
ComPort1: TApdComPort;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
ComFrm : TComselectform;
ValidPortNo : array[1..8] of boolean;
vp, I, next : integer;
com : string;
Frm : TComPortOptions;
begin
Frm := TComPortOptions.Create(Self);
if Frm.Execute then
begin
if (Frm.ComPort <> nil) then
begin
{close and open ports}
ComPort1.Assign(Frm.ComPort);
end;
end;
next:=1;
while next<=3 do
begin
comport1.comnumber:=next;
try
ComPort1.Open := True;
Application.ProcessMessages;
next:=next+1;
{ Break;}
except
on EOpenComm do
begin
ComFrm := TComSelectForm.Create(Self);
Application.ProcessMessages;
{for I := 1 to 8 do
begin
if not ComFrm.ValidComPort(I) then
ValidPortNo[I] := False
else
ValidPortNo[I] := True;
end;
If VP = 0 then
begin
if (ComFrm.ShowModal = mrOK) then
begin
Com := ComFrm.SelectedCom;
ComPort1.ComNumber := Ord(Com[4]) - Ord('1') + 1;
WritePortOptions;
end
else
Halt;
end;
Application.ProcessMessages;
If ValidPortNo[VP] then
begin
Comport1.ComNumber := VP;
Com := 'COM' + IntToStr(VP);
WritePortOptions;
Dec(VP);
end
else
Dec(VP);}
ComFrm.Free;
end
else
raise;
next:=next+1;
end;
end;
Frm.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
h :boolean;
begin
h:=IsPortAvailable(1);
end;
end.
|