Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Система";
Текущий архив: 2002.08.22;
Скачать: [xml.tar.bz2];

Вниз

Ошибка при попытке позвонить через модем   Найти похожие ветки 

 
Lelik17   (2002-06-07 12:49) [0]

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
hCommFile : THandle;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var PhoneNumber : string;
CommPort : string;
NumberWritten: LongInt;
begin
CloseHandle(hCommFile);
PhoneNumber := "ATDP 7-812-943-98-10" + #13 + #10;
CommPort := "COM1";
{Open the comm port}
hCommFile := CreateFile(PChar(CommPort),
GENERIC_WRITE,
0,
nil,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
if hCommFile=INVALID_HANDLE_VALUE then
begin
ShowMessage("Unable to open "+ CommPort);
exit;
end;

{Dial the phone}
NumberWritten:=0;
if WriteFile(hCommFile,
PChar(PhoneNumber)^,
Length(PhoneNumber),
NumberWritten, - тут ругается!
nil) = false then begin
ShowMessage("Unable to write to " + CommPort);
end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
CloseHandle(hCommFile);
end;

end.

Говорит, что ошибочка вышла по поводу NumberWritten. В чём дело?
Зарание спасибо?


 
Song   (2002-06-07 13:23) [1]

Посмотрите в FAQ как там сделано.


 
МИФИст   (2002-06-07 15:15) [2]

Может быть нужно воспользоваться:
SetCommState, SetCommTimeouts.
Про это подробно написано в статье
http://delphi.vitpc.com/mastering/ports5.htm

На счёт NumberWritten:

nNumberOfBytesToWrite

[in] Number of bytes to write to the file.
A value of zero specifies a null write operation. A null write operation does not write any bytes but does cause the time stamp to change. WriteFile does not truncate or extend the file. To truncate or extend a file, use the SetEndOfFile function.
Попробуй NumberWritten:=Length(PhoneNumber).




Страницы: 1 вся ветка

Форум: "Система";
Текущий архив: 2002.08.22;
Скачать: [xml.tar.bz2];

Наверх




Память: 0.45 MB
Время: 0.008 c
3-71027
Сергей.
2002-07-31 14:02
2002.08.22
Доступ к полям таблицы


1-71234
V.Turecky
2002-08-11 17:41
2002.08.22
Диалог выбора значка...


3-70989
diww
2002-07-31 13:07
2002.08.22
как сделать запрос?


4-71437
аак
2002-06-19 14:08
2002.08.22
Как скопировать папку со всем ее содержимым?


14-71321
jessis
2002-07-26 15:22
2002.08.22
Компиляция





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский