关于modem拨号问题!!!(急)(100分)

  • 主题发起人 主题发起人 xw1021
  • 开始时间 开始时间
X

xw1021

Unregistered / Unconfirmed
GUEST, unregistred user!
这是我第一次真正用delphi写代码
我的代码如下:
unit Unit1;

interface
{function RasCreatePhonebookEntryA( hwnd : THandle;lpszPhonebook: pchar ) : DWORD;stdcall;}
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Registry,
Dialogs, StdCtrls,WinTypes, WinProcs;

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
// function RasCreatePhonebookEntryA( hwnd : THandle;lpszPhonebook: pchar ) : DWORD;stdcall;
// function RasEditPhonebookEntryA( hwnd : THandle; lpszPhonebook: pchar;lpszEntryName: pchar ) : DWORD;stdcall;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;

implementation
{
function RasCreatePhonebookEntryA; external 'Rasapi32.dll' name 'RasCreatePhonebookEntryA';
}
//function RasEditPhonebookEntryA; external 'Rasapi32.dll' name 'RasEditPhonebookEntryA';
//{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
dwResult : DWORD;
strDialName : String;
begin
//在当前窗口中新建拨号连接
strDialName := '163';
dwResult := RasCreatePhonebookEntryA(handle,'');
if dwResult = 0 then
memo1.lines.add('新建拨号连接成功!')
else
memo1.lines.add('新建拨号连接失败!');

end;

end.


但是总是报这个错误:
[Error] Unit1.pas(38): Undeclared identifier: 'RasCreatePhonebookEntryA'

这是为什么?????请教各位高手!

 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,Registry,
Dialogs, StdCtrls,WinTypes, WinProcs;

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;

implementation

{$R *.dfm}

type
PFNRasEditPhoneBookEntry = ^TFNRasEditPhoneBookEntry;
TFNRasEditPhoneBookEntry = function(hWndParent : HWND;lpszPhonebook : PChar;lpszEntryName : PChar) : DWORD; stdcall;

const
rasapi32 = 'rasapi32.dll';
var
RASChecked : Boolean = False;
RasModule : HModule = 0;
RasEditPhonebookEntry : TFNRasEditPhonebookEntry = nil;

Function InitRas : Boolean;
begin
if not(RASChecked) then
begin
RASChecked:=True;
RASModule := 0;
RASModule := LoadLibrary(PChar(RASAPI32));
result:=RASModule<>0;
end else result:=RASModule<>0;
end;

function MyRasEditPhonebookEntry(hWndParent : HWND;lpszPhonebook : PChar;lpszEntryName : PChar) : DWORD;
begin
InitRAS;
if @RasEditPhonebookEntry = nil then @RasEditPhonebookEntry := GetProcAddress(RasModule, 'RasEditPhonebookEntryA');
if @RasEditPhonebookEntry <> nil then Result := RasEditPhonebookEntry(hWndParent,lpszPhonebook,lpszEntryName) else result:=200;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
dwResult : DWORD;
strDialName : String;
begin
//在当前窗口中新建拨号连接
strDialName := '163';
dwResult := MyRasEditPhonebookEntry(handle, nil, pchar(strDialName));
if dwResult = 0 then
memo1.lines.add('新建拨号连接成功!')
else
memo1.lines.add('新建拨号连接失败!');
end;

有关 RasEditPhonebookEntry 在MSDN中有详细的介绍.
 
请高手指点!!!!!很急呀!!!!!!各位帮帮忙!!!!!!!我可以加分
 
上面的代码没错的,你想干什么呀?如果你想拨号的话我有一些拨号控件.
 
但是上面的是更改电话属性的呀!则么创建那??
 
测试通过了

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,Registry,
Dialogs, StdCtrls,WinTypes, WinProcs;

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;

implementation

{$R *.dfm}

type
PFNRasEditPhoneBookEntry = ^TFNRasEditPhoneBookEntry;
TFNRasEditPhoneBookEntry = function(hWndParent : HWND;lpszPhonebook : PChar;lpszEntryName : PChar) : DWORD; stdcall;

PFNRasCreatePhonebookEntry = ^TFNRasCreatePhonebookEntry;
TFNRasCreatePhonebookEntry = function(hWndParent : HWND;lpszPhonebook : PChar) : DWORD; stdcall;

const
rasapi32 = 'rasapi32.dll';
var
RASChecked : Boolean = False;
RasModule : HModule = 0;
RasEditPhonebookEntry : TFNRasEditPhonebookEntry = nil;
RasCreatePhonebookEntry : TFNRasCreatePhonebookEntry = nil;

Function InitRas : Boolean;
begin
if not(RASChecked) then
begin
RASChecked:=True;
RASModule := 0;
RASModule := LoadLibrary(PChar(RASAPI32));
result:=RASModule<>0;
end else result:=RASModule<>0;
end;

function MyRasEditPhonebookEntry(hWndParent : HWND;lpszPhonebook : PChar;lpszEntryName : PChar) : DWORD;
begin
InitRAS;
if @RasEditPhonebookEntry = nil then @RasEditPhonebookEntry := GetProcAddress(RasModule, 'RasEditPhonebookEntryA');
if @RasEditPhonebookEntry <> nil then Result := RasEditPhonebookEntry(hWndParent,lpszPhonebook,lpszEntryName) else result:=200;
end;

function MyRasCreatePhonebookEntryA(hWndParent : HWND;lpszPhonebook : PChar) : DWORD;
begin
InitRAS;
if @RasCreatePhonebookEntry = nil then @RasCreatePhonebookEntry := GetProcAddress(RasModule, 'RasCreatePhonebookEntryA');
if @RasCreatePhonebookEntry <> nil then Result := RasCreatePhonebookEntry(hWndParent,lpszPhonebook) else result:=200;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
dwResult : DWORD;
strDialName : String;
begin
//在当前窗口中新建拨号连接
strDialName := '163';
dwResult := MyRasCreatePhonebookEntryA(handle, nil);
if dwResult = 0 then
memo1.lines.add('新建拨号连接成功!')
else
memo1.lines.add('新建拨号连接失败!');
end;
 
多谢,分给你了
 

Similar threads

I
回复
0
查看
651
import
I
I
回复
0
查看
541
import
I
I
回复
0
查看
562
import
I
I
回复
0
查看
568
import
I
后退
顶部