home *** CD-ROM | disk | FTP | other *** search
- library Comm;
-
- uses wObjects, winTypes, winProcs, Strings;
-
- var
- DCB: TDCB;
- CID:Integer;
-
- function Dial(Comport, Dialtype, Number:PChar): integer; export;
-
- var
- P, Config, Num: PChar;
- Struc: string;
- i: integer;
- begin
- Struc := #0;
- GetMem(Config, 20);
- GetMem(P, 255);
- Strcopy(@Struc[1], Number);
- Struc[0] := Char(StrLen(Number));
- Struc := Struc+#0;
- { Strip Routine }
- i := 1;
- while i <= length(Struc) do
- begin
- if (((Struc[i] < #48) or (Struc[i] > #57)) and ((Struc[i] <> ','))) then
- begin
- Delete(Struc, i, 1);
- Dec(i);
- end;
- i := i+1;
- end;
- StrCopy(Config, Comport);
- Config := StrCat(Config, ':12,n,8,1');
- StrLCopy(P, Dialtype, 20);
- P := StrCat(P, @Struc[1]);
- P := StrCat(P, #13#10);
- BuildCommDCB(Config, DCB);
- if CID <= 0 then
- begin
- Cid := OpenComm(Comport, 1024, 1024);
- if not(CID<0) then
- begin
- DCB.ID := CID;
- SetCommState(DCB);
- if WriteComm(CID, p, StrLen(P)) <= 0 then
- begin
- MessageBox(getfocus, 'Dial Error', 'Error', Mb_Ok);
- Dial := 1; {return error}
- end
- else
- Dial := 0; {return no error}
- end;
- end;
- FreeMem(P, 255);
- FreeMem(Config, 20);
- end;
-
- function Hangup : bool; export;
- begin
- if not(CID < 0) then
- begin
- WriteComm(CID, 'ATH'#13#10, 5);
- If CloseComm(Cid) < 0 then
- begin
- MessageBox(GetFocus, 'Hangup Error', 'Error', Mb_Ok);
- Hangup := bool(0);
- end
- else
- begin
- Cid := 0;
- Hangup := bool(1);
- end;
- end;
- end;
-
- Exports Dial index 1;
- Exports Hangup index 2;
-
- begin
- end.