// 안녕하세요 김영대( http://www.howto.pe.kr ) 입니다
// 아래는 잔에 제가 찾아놓은 팁인데요 예제로 안만들고 그냥 올렸네요
// 제 홈페이지의 Delphi 팁&트릭에서 "IP" 로 검색해 보시면
// 몇가지 다른 정보도 참고가 되실겁니다
The IP-address and the IP-Mask are on my computer located in the registry at
HKEY_LOCAL_MACHINESystemCurrentControlSetServicesClassNetTrans 002
If you want an automatic IP-address/mask, you should run the procedure below
as SetTCPIP('0.0.0.0', '0.0.0.0')
otherwise you should run it like SetTCPIP('255.254.253.255',
'255.255.255.255')
Good luck,
G. Jacobs
procedure SetTCPIP(IpAddress, IPMask:pchar);
var KeyHandle, SubKeyHandle:THandle;
SubKeyName, NetworkDesc:array[0..255] of char;
ValType, NetworkDescLength, SubKeyNameLength, index:dword;
LastWriteTime:PFileTime;
begin
index:=0;
SubKeyNameLength:=255;
RegOpenKeyEx(HKEY_LOCAL_MACHINE,
'SystemCurrentControlSetServicesClassNetTrans', 0, KEY_ALL_ACCESS,
KeyHandle);
while (RegEnumKeyEx(KeyHandle, index, SubKeyName, SubKeyNameLength, nil,
nil, nil, LastWriteTime)<>ERROR_NO_MORE_ITEMS) do
begin
RegOpenKeyEx(KeyHandle, SubKeyName, 0, KEY_ALL_ACCESS, SubKeyHandle);
NetWorkDescLength:=255;
RegQueryValueEx(SubKeyHandle, 'DriverDesc', nil, @ValType, @NetworkDesc,
@NetworkDescLength);
if (NetworkDesc='TCP/IP') then break;
inc(index);
SubKeyNameLength:=255;
end;
if (NetworkDesc<>'TCP/IP') then
begin
messagebox(0,'TCP/IP protocol is not installed on your computer','',0);
exit;
end;
NetWorkDescLength:=255;
RegSetValueEx(SubKeyHandle, 'IPAddress', 0, REG_SZ, IPAddress, 15);
RegSetValueEx(SubKeyHandle, 'IPMask', 0, REG_SZ, IPMask, 15);
end;
// 아래는 잔에 제가 찾아놓은 팁인데요 예제로 안만들고 그냥 올렸네요
// 제 홈페이지의 Delphi 팁&트릭에서 "IP" 로 검색해 보시면
// 몇가지 다른 정보도 참고가 되실겁니다
The IP-address and the IP-Mask are on my computer located in the registry at
HKEY_LOCAL_MACHINESystemCurrentControlSetServicesClassNetTrans 002
If you want an automatic IP-address/mask, you should run the procedure below
as SetTCPIP('0.0.0.0', '0.0.0.0')
otherwise you should run it like SetTCPIP('255.254.253.255',
'255.255.255.255')
Good luck,
G. Jacobs
procedure SetTCPIP(IpAddress, IPMask:pchar);
var KeyHandle, SubKeyHandle:THandle;
SubKeyName, NetworkDesc:array[0..255] of char;
ValType, NetworkDescLength, SubKeyNameLength, index:dword;
LastWriteTime:PFileTime;
begin
index:=0;
SubKeyNameLength:=255;
RegOpenKeyEx(HKEY_LOCAL_MACHINE,
'SystemCurrentControlSetServicesClassNetTrans', 0, KEY_ALL_ACCESS,
KeyHandle);
while (RegEnumKeyEx(KeyHandle, index, SubKeyName, SubKeyNameLength, nil,
nil, nil, LastWriteTime)<>ERROR_NO_MORE_ITEMS) do
begin
RegOpenKeyEx(KeyHandle, SubKeyName, 0, KEY_ALL_ACCESS, SubKeyHandle);
NetWorkDescLength:=255;
RegQueryValueEx(SubKeyHandle, 'DriverDesc', nil, @ValType, @NetworkDesc,
@NetworkDescLength);
if (NetworkDesc='TCP/IP') then break;
inc(index);
SubKeyNameLength:=255;
end;
if (NetworkDesc<>'TCP/IP') then
begin
messagebox(0,'TCP/IP protocol is not installed on your computer','',0);
exit;
end;
NetWorkDescLength:=255;
RegSetValueEx(SubKeyHandle, 'IPAddress', 0, REG_SZ, IPAddress, 15);
RegSetValueEx(SubKeyHandle, 'IPMask', 0, REG_SZ, IPMask, 15);
end;