![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
модем [D7, WinXP]
Sicilla © (2005-01-17 20:19:00)Подскажите, как мне включить/выключить динамик модема?
dimaxx (2005-01-19 23:27:00) [1]Команда atm0 правильная. Может, в конце нулевой символ поставить, а не перевод строки? То есть 'atm0'+#0
Sicilla (2005-01-18 23:04:00) [2]Я это понял, спасибо. Но теперь не могу вызвать правильную команду. Помоги, если не трудно.
dimaxx (2005-01-18 22:40:00) [3]А мой код посмотреть лень? У меня все заработало.
NumberWritten должен быть типа cardinal (он же longword), а не longint. Вот оттуда и ошибка. Она означает, что типы передаваемого и объявленного параметров должны быть идентичными.
Sicilla (2005-01-18 17:02:00) [4]В строке
WriteFile(hCommFile,PChar(PhoneCommand)^,Length(PhoneCommand),NumberWritten,nil)
у меня вылетает ошибка Types of actual and formal var parameters must be identical. Не могу понять в чем дело. Помогите!?
dimaxx (2005-01-17 23:52:00) [5]var
phoneCommand: string;
CommPort: string;
NumberWritten: cardinal;
hCommFile: THandle;
begin
PhoneCommand:='atm0'+#13#10;
CommPort:='COM3';
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;
if not WriteFile(hCommFile,PChar(PhoneCommand)^,Length(PhoneCommand),NumberWritten,nil) then
begin
ShowMessage('Unable to write to '+CommPort);
end;
CloseHandle(hCommFile);
end;
Sicilla (2005-01-17 20:57:00) [6]Я нашел такой код:
procedure TForm1.Button1Click(Sender: TObject);
var
phoneCommand: string;
CommPort: string;
NumberWritten: LongInt;
begin
PhoneCommand := 'atm0' + #13 + #10;
CommPort := 'COM3';
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;
NumberWritten := 0;
if WriteFile(hCommFile,PChar(PhoneCommand)^,Length(PhoneCommand),NumberWritten,nil) = false then //здесь ошибка.
begin
ShowMessage('Unable to write to ' + CommPort);
end;
CloseHandle(hCommFile);
end;
Помогите, кто может