1000分求能实现以下功能的程序源码。(0分)

  • 主题发起人 主题发起人 大傻子
  • 开始时间 开始时间

大傻子

Unregistered / Unconfirmed
GUEST, unregistred user!
不论是XP还是Vista都能得到本机和设置IP、子网、网关、DNS、MAC地址,并能保存到一个数据库中,适合1~N个网卡
---------------------
这里没有给分,我会另开贴子给分的。谢谢。
 
这个功能Windows本身就有啦~还要这么费劲吗?直接调用就行啦~
 
我知道调ip和主机名字的函数,献给楼上的吧
sIpAndName:=GetLocalIPAndName;
IF sIpAndName.count=2 then
begin
sIp:=sIpAndName.strings[0];
sHostname:=sIpAndName.strings[1];
end;
 
我要用程序实现,也就是编程个程序
 
告诉你方法可以
想要程序拿RMB来~
 
这个问题还要钱,
留下email我发给你
 
直接在baidu搜索啊
一大把的源代码
 
真的是大把代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, inifiles,Graphics, Controls, Forms,
winsock,dialogs, StdCtrls, WinSkinForm, WinSkinData,shellapi;
type
Tmain = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
SkinData1: TSkinData;
WinSkinForm1: TWinSkinForm;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
procedure FormCreate(Sender: TObject);
procedure Label10Click(Sender: TObject);
private
procedure readini;
public
{ Public declarations }
end;

var
main: Tmain;
gatemac:string;
implementation
{$R *.dfm}
function SendARP(const DestIP: DWord;const SrcIP: DWord;const pMacAddr: Pointer;const PhyAddrLen: PULONG): DWord;
stdcall;
external 'IPHLPAPI.DLL' name 'SendARP';
function inet_addr(const cp: PChar): DWord;
stdcall;
external 'WS2_32.DLL' name 'inet_addr';
function LocalIP : string;
type
TaPInAddr = array [0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
phe : PHostEnt;
pptr : PaPInAddr;
Buffer : array [0..63] of char;
I : Integer;
GInitData : TWSADATA;
begin
WSAStartup($101, GInitData);
Result := '127.0.0.1';
GetHostName(Buffer, SizeOf(Buffer));
phe :=GetHostByName(buffer);
if phe = nil then
begin
wsacleanup;
Exit;
end;
pptr := PaPInAddr(Phe^.h_addr_list);
I := 0;
while pptr^ <> nildo
begin
result:=StrPas(inet_ntoa(pptr^^));
Inc(I);
end;
WSACleanup;
end;

function IPMACAD(TMp:STRING):string;
var
dwResult: DWord;
ulIPAddr: DWord;
ulMACAddr: array[0..5] of Byte;
ulAddrLen: ULONG;
begin
ulIPAddr := inet_addr(PChar(TMp));
result:= IntToHex(ulIPAddr, 8);
//ShowMessage(IntToHex(ulIPAddr, 8));
if ulIPAddr = $FFFFFFFF then
begin
result:='';
Exit;
end;
ulAddrLen := 6;
dwResult := SendARP(ulIPAddr, 0, @ulMACAddr, @ulAddrLen);
if dwResult <> 0 then
begin
result:='';
Exit;
end;

result:=IntToHex(ulMACAddr[0],2)+'-'+IntToHex(ulMACAddr[1],2)+'-'+IntToHex(ulMACAddr[2],2)+'-'+IntToHex(ulMACAddr[3],2)+'-'+
IntToHex(ulMACAddr[4],2)+'-'+IntToHex(ulMACAddr[5],2);
end;

function WinExecAndWait32(FileName:String;
Visibility:integer):integer;
var
zAppName: array[0..512] of char;
zCurDir: array[0..255] of char;
WorkDir: String;
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
lpExitCode: longword;
begin
StrPCopy(zAppName,FileName);
GetDir(0,WorkDir);
StrPCopy(zCurDir,WorkDir);
FillChar(StartupInfo,Sizeof(StartupInfo),#0);
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := Visibility;
if not CreateProcess(nil,zAppName,{ pointer to command line string }
nil, { pointer to process security attributes }
nil, { pointer to thread security attributes }
false, { handle inheritance flag }
CREATE_NEW_CONSOLE or { creation flags }
NORMAL_PRIORITY_CLASS,
nil, { pointer to new environment block }
nil, { pointer to current directory name }
StartupInfo, { pointer to STARTUPINFO }
ProcessInfo) then
Result:=-1 { pointer to PROCESS_INF }
else
begin
WaitforSingleObject(ProcessInfo.hProcess,INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess,lpExitCode);
end;
end;

procedure tmain.readini;
var
f:tinifile;
begin
try
f:=TIniFile.Create(ExtractFilePath(ParamStr(0))+'Mac_Ip.ini');
label8.Caption:=f.Readstring('GateWay','IP','');
gatemac:=f.Readstring('GateWay','MAC','');
except
//
end;
f.Free;
end;

procedure Tmain.FormCreate(Sender: TObject);
begin
readini;
if LocalIP='127.0.0.1' then
label2.Caption:='网络未连接'
else
begin
label2.Caption:=LocalIP;
label4.Caption:=IPMACAD(localip);
WinExecAndWait32('arp -s '+label2.Caption+' '+label4.Caption,0);
if label8.Caption<>'' then
WinExecAndWait32('arp -s '+label8.Caption+' '+gatemac,0);
label6.Caption:='是';
end;
end;

procedure Tmain.Label10Click(Sender: TObject);
begin
shellexecute(handle,nil,pchar('http://www.xnzy.net/'),nil,nil,sw_shownormal);
end;

end.
 
如果想利用其他的方面做,就不调用ARP那东西,直接netsh 做是一样的!上面的代码用了2个东西,WinSkinForm, WinSkinData,如果没有这个皮肤控件单元,就直接删除编译吧,给分吧!不要让我失望!
 
var
Error,BufLen:DWORD;
AdapterInfo,NetCard : PIP_ADAPTER_INFO;
Descr,sLocalIP,GateWayIP,DHCPIP,AdName:String ;
i:Integer;
Size:Cardinal;
begin
GetMem(AdapterInfo,size);
Error:=GetAdaptersInfo(AdapterInfo,size);
if Error=no_error then
begin
NetCard:=AdapterInfo;
i:=0;
repeat
with NetCard^do
begin
sLocalIP:=IpAddressList.IpAddress.S;
sLocalIP:=trim(sLocalIP);
MacAddr:=Format('%16s',[macaddrtostr(address,addresslength)]);
inc(i);
end;
NetCard:=NetCard^.Next;
until (NetCard=nil)
end;
FreeMem(AdapterInfo);
你自己再修改修改就可以用了
 
浪人情哥,请给我发过来谢谢。liubingji@163.com
也谢谢以上的几位,ccxxzz的程序不能用,也谢谢znj_326
 
浪人情哥!可以的话也给我发个!先谢过!jmahqh@163.com!
 
ccxxzz,都沒看懂別人的意思就亂發.BS一下.
我有源代碼.要加MSN:longeremaq@hotmail.com
 
对不起,我没有MSN,能发到我邮箱里吗?谢谢了。
 
以上需要的各位,程序已发,请注意查收,没收到的说
 
俺也想要chenlx10@163.com谢谢!![8D]
 
请给我发一份 878625@163.com 谢谢!!!
 
uses nb30, .......
里面贴子太多!
 
一千分哦
 

Similar threads

后退
顶部