谁能帮我调通以下程序,谢谢了 ( 积分: 50 )

  • 主题发起人 主题发起人 zz770813
  • 开始时间 开始时间
Z

zz770813

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;

interface

function RasCreatePhonebookEntryA(hwnd : THandle;lpszPhonebook:pchar):dword;stdcall;
function RasEditPhonebookEntryA(hwnd:THandle; lpszPhonebook:pchar;
lpszEntryName:pchar):DWORD;stdcall;

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

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }

public
{ Public declarations }

end;

var
Form1: TForm1;

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

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


procedure TForm1.Button2Click(Sender: TObject);
var
dwResult : DWORD;
strDialName : string;
begin
strDialName := '163';//拨号连接的名称设为163
//在当前窗口中指定修改拨号连接的属性
dwResult := RasEditPhonebookEntryA( handle, '', PChar( strDialName ) );
if dwResult = 0 then
memo1.lines.add('修改拨号连接' + strDialName + '成功!')
else
memo1.lines.add('修改拨号连接' + strDialName + '失败!')
end;


procedure TForm1.Button3Click(Sender: TObject);
var
registryTemp : TRegistry;
stringsTemp : TStringlist;
intIndex : integer;
begin
registryTemp := TRegistry.Create;
stringsTemp := TStringlist.Create;
with registryTemp do
begin
RootKey := HKEY_USERS;//根键设置为HKEY_USERS
//如果存在子键.Default/RemoteAccess/Addresses
if OpenKey('.Default/RemoteAccess/Addresses',false) then
GetValueNames( stringsTemp );//读出各项目的名称,即拨号连接名称
CloseKey;
end;
//当前系统中可用的拨号连接
memo1.lines.add( '******************当前系统中有'+ IntToStr( stringsTemp.count )
+'个可用的拨号连接如下****************');
for intIndex := 0 to stringsTemp.count - 1 do
memo1.lines.add( stringsTemp.strings[ intIndex ] );

//列出Internet Explorer中设置的默认连接名称
if registryTemp.OpenKey('.Default/RemoteAccess',false) then
memo1.lines.add( 'Internet Explorer中设置的默认连接名称为' +
registryTemp.ReadString('InternetProfile') );

//释放内存
registryTemp.free;
stringsTemp.free;
end;


procedure TForm1.Button4Click(Sender: TObject);
var
strDialName : string;
begin
strDialName := '163';//拨号连接的名称设为163
memo1.lines.add( '******************用拨号连接'+ strDialName
+'实现拨号上网****************');
winexec( PChar('rundll32.exe rnaui.dll,RnaDial ' + strDialName),SW_SHOWNORMAL);
end;


end.
 
unit Unit1;

interface

function RasCreatePhonebookEntryA(hwnd : THandle;lpszPhonebook:pchar):dword;stdcall;
function RasEditPhonebookEntryA(hwnd:THandle; lpszPhonebook:pchar;
lpszEntryName:pchar):DWORD;stdcall;

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

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }

public
{ Public declarations }

end;

var
Form1: TForm1;

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

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


procedure TForm1.Button2Click(Sender: TObject);
var
dwResult : DWORD;
strDialName : string;
begin
strDialName := '163';//拨号连接的名称设为163
//在当前窗口中指定修改拨号连接的属性
dwResult := RasEditPhonebookEntryA( handle, '', PChar( strDialName ) );
if dwResult = 0 then
memo1.lines.add('修改拨号连接' + strDialName + '成功!')
else
memo1.lines.add('修改拨号连接' + strDialName + '失败!')
end;


procedure TForm1.Button3Click(Sender: TObject);
var
registryTemp : TRegistry;
stringsTemp : TStringlist;
intIndex : integer;
begin
registryTemp := TRegistry.Create;
stringsTemp := TStringlist.Create;
with registryTemp do
begin
RootKey := HKEY_USERS;//根键设置为HKEY_USERS
//如果存在子键.Default/RemoteAccess/Addresses
if OpenKey('.Default/RemoteAccess/Addresses',false) then
GetValueNames( stringsTemp );//读出各项目的名称,即拨号连接名称
CloseKey;
end;
//当前系统中可用的拨号连接
memo1.lines.add( '******************当前系统中有'+ IntToStr( stringsTemp.count )
+'个可用的拨号连接如下****************');
for intIndex := 0 to stringsTemp.count - 1 do
memo1.lines.add( stringsTemp.strings[ intIndex ] );

//列出Internet Explorer中设置的默认连接名称
if registryTemp.OpenKey('.Default/RemoteAccess',false) then
memo1.lines.add( 'Internet Explorer中设置的默认连接名称为' +
registryTemp.ReadString('InternetProfile') );

//释放内存
registryTemp.free;
stringsTemp.free;
end;


procedure TForm1.Button4Click(Sender: TObject);
var
strDialName : string;
begin
strDialName := '163';//拨号连接的名称设为163
memo1.lines.add( '******************用拨号连接'+ strDialName
+'实现拨号上网****************');
winexec( PChar('rundll32.exe rnaui.dll,RnaDial ' + strDialName),SW_SHOWNORMAL);
end;


end.
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Registry;
function RasCreatePhonebookEntryA(hwnd: THandle; lpszPhonebook: pchar): dword;
stdcall;
function RasEditPhonebookEntryA(hwnd: THandle; lpszPhonebook: pchar;
lpszEntryName: pchar): DWORD; stdcall;

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }

public
{ Public declarations }

end;

var
Form1: TForm1;

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

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

procedure TForm1.Button2Click(Sender: TObject);
var
dwResult: DWORD;
strDialName: string;
begin
strDialName := '163'; //拨号连接的名称设为163
//在当前窗口中指定修改拨号连接的属性
dwResult := RasEditPhonebookEntryA(handle, '', PChar(strDialName));
if dwResult = 0 then
memo1.lines.add('修改拨号连接' + strDialName + '成功!')
else
memo1.lines.add('修改拨号连接' + strDialName + '失败!')
end;

procedure TForm1.Button3Click(Sender: TObject);
var
registryTemp: TRegistry;
stringsTemp: TStringlist;
intIndex: integer;
begin
registryTemp := TRegistry.Create;
stringsTemp := TStringlist.Create;
with registryTemp do
begin
RootKey := HKEY_USERS; //根键设置为HKEY_USERS
//如果存在子键.Default/RemoteAccess/Addresses
if OpenKey('.Default/RemoteAccess/Addresses', false) then
GetValueNames(stringsTemp); //读出各项目的名称,即拨号连接名称
CloseKey;
end;
//当前系统中可用的拨号连接
memo1.lines.add('******************当前系统中有' + IntToStr(stringsTemp.count)
+ '个可用的拨号连接如下****************');
for intIndex := 0 to stringsTemp.count - 1 do
memo1.lines.add(stringsTemp.strings[intIndex]);

//列出Internet Explorer中设置的默认连接名称
if registryTemp.OpenKey('.Default/RemoteAccess', false) then
memo1.lines.add('Internet Explorer中设置的默认连接名称为' +
registryTemp.ReadString('InternetProfile'));

//释放内存
registryTemp.free;
stringsTemp.free;
end;

procedure TForm1.Button4Click(Sender: TObject);
var
strDialName: string;
begin
strDialName := '163'; //拨号连接的名称设为163
memo1.lines.add('******************用拨号连接' + strDialName
+ '实现拨号上网****************');
winexec(PChar('rundll32.exe rnaui.dll,RnaDial ' + strDialName),
SW_SHOWNORMAL);
end;

end.
 
接受答案了.
 

Similar threads

I
回复
0
查看
665
import
I
I
回复
0
查看
537
import
I
I
回复
0
查看
583
import
I
I
回复
0
查看
637
import
I
后退
顶部