首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

在delphi里如何用函数DhcpNotifyConfigChange

2012-03-04 
在delphi里怎么用函数DhcpNotifyConfigChange?我需要修改本地DHCP配置和IP地址,然后使其生效,不知道在delp

在delphi里怎么用函数DhcpNotifyConfigChange?
我需要修改本地DHCP配置和IP地址,然后使其生效,不知道在delphi里怎么用函数DhcpNotifyConfigChange?   或者怎么实现重启网卡?

[解决办法]
var
DhcpDll:THandle;
DHCPD:TDHCPNOTIFYPROC;

begin
try
DhcpDll:=LoadLibrary( 'dhcpcsvc.dll ');
if DhcpDll <> 0 then
begin
@DHCPD:=GetProcAddress(DhcpDll, PChar( 'DhcpNotifyConfigChange '));
if @DHCPD <> nil then
DHCPD(nil,pchar( '{01082454-E36A-48C4-A59F-35D6CEF88484} '),True,0,inet_addr(( '192.168.0.240 ')),inet_addr(( '255.255.255.0 ')),0);
end;
Finally
FreeLibrary(DhcpDll);
end;
end;
[解决办法]
帮月亮补充一下,,TDHCPNOTIFYPROC的函数类型的定义 :)

unit Unit1;

interface

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

type
TForm1 = class(TForm)
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TDHCPNOTIFYPROC = function(JQName,NetName:pchar;ZXing:boolean;nIndex,NetIP,NetMask:dword;Ss:integer):Boolean;

var
Form1: TForm1;

implementation

热点排行