哪位知道如何获得和修改本机的ip地址,不用vb也行,能给多少给多少分!

iwindy 2002-06-06 09:57:53
哪位知道如何获得和修改本机的ip地址?
...全文
231 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
孙小雄 2002-06-06
  • 打赏
  • 举报
回复
我查了有关资料

首先你必须是 win2000 pk2


DWORD AddIPAddress(
IPAddr Address, // IP address to add
IPMask IpMask, // subnet mask for IP address
DWORD IfIndex, // index of adapter
PULONG NTEContext, // Net Table Entry context
PULONG NTEInstance // Net Table Entry Instance
);
Parameters
Address
[in] Specifies the IP address to add to the adapter.
IpMask
[in] Specifies the subnet mask for the IP address.
IfIndex
[in] Specifies the adapter to which to add the address.
NTEContext
[out] Pointer to a ULONG variable that points to the Net Table Entry (NTE) context for this IP address. The caller can later use this context in a call to DeleteIPAddress.
NTEInstance
[out] Pointer to a ULONG variable that points to the NTE instance for this IP address.






DWORD GetAdapterIndex(
LPWSTR AdapterName, // name of the adapter
PULONG IfIndex // index of the adapter
);
Parameters
AdapterName
[in] Pointer to a Unicode string that specifies the name of the adapter.
IfIndex
[out] Pointer to a ULONG variable that points to the index of the adapter.








DWORD DeleteIPAddress(
ULONG NTEContext // net table entry context
);
Parameters
NTEContext
[in] Specifies the Net Table Entry (NTE) context for the IP address. This context was returned by the previous call to AddIPAddress.



iwindy 2002-06-06
  • 打赏
  • 举报
回复
winsock控件的localip属性可以修改ip地址吗?
kwq_cn 2002-06-06
  • 打赏
  • 举报
回复
最简单的方法:用winsock控件的localip属性
iwindy 2002-06-06
  • 打赏
  • 举报
回复
真的没人会吗?不会吧!
acptvb 2002-06-06
  • 打赏
  • 举报
回复
感谢您使用微软产品。

您可以使用Windows Sockets的API函数GetHostByName通过本机的Host Name获得包含本机ip地址的Sockets信息,为了获得本机的标准Host Name,您还需要调用API函数GetHostName。

以下链接提供了详细的示例代码。
Q160215 HOWTO: Obtain the Host IP Address Using Windows Sockets
http://support.microsoft.com/support/kb/articles/q160/2/15.asp

您可以用wmi方式修改本机的IP地址,如下例:

Private Sub Command1_Click()

WQL = "Select * From Win32_NetworkAdapter Where AdapterType='Ethernet 802.3'"

Set NetworkAdapters = GetObject("winmgmts:").ExecQuery(WQL)

ipaddr = Array("202.60.115.7")
subnet = Array("255.255.255.0")

For Each Adapter In NetworkAdapters

Dim RetVal

WQL = "winmgmts:Win32_NetworkAdapterConfiguration=" & Adapter.DeviceID
Set NIC = GetObject(WQL)

RetVal = NIC.EnableStatic(ipaddr, subnet)

If RetVal = 0 Then
MsgBox "Static IP Enabled"
Else
MsgBox "Static IP Failed"
End If
Next
End Sub

详细信息请参考:
EnableStatic Method in Class Win32_NetworkAdapterConfiguration
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/enablestatic_method_in_class_win32_networkadapterconfiguration.asp

- 微软全球技术中心 VB技术支持

本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款
(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
为了为您创建更好的讨论环境,请参加我们的用户满意度调查
(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
代码下载地址: https://pan.quark.cn/s/8236006bf1f9 Word精灵插件:一款用于增强Microsoft Word功能的辅助软件,能够将多种复杂功能转化为插件形式,并在软件状态栏中进展示,涵盖诸如批注管理、表格处理、内容替换、文档拆、数学运算、字符提取、批量重命名等多项实用工具。在工作环境中应用该插件能够显著降低工作强度,提升操作效率。Word精灵插件兼容32位与64位的Microsoft Word版本,支持Word 2007、2010、2013以及Word 2016操作系统,但不适用于Word 2003版本。此外,该插件同样支持WPS办公软件。 功能概述: 1、表格自动调整宽度:自动优化文档内所有表格的显示宽度。 2、批量导出批注信息:将文档内所有批注集中导出到Excel工作簿中。 3、表格至Excel多表导出:在将表格导出到Excel时,每个Word表格将独立存放在一个工作表中,Word文档内的表格数量与Excel生成的工作表数量相等,并附有工作表目录。 4、表格至Excel单表导出:将文档内所有表格整合后导出到一个Excel工作表中,多个表格将按顺序排列于同一工作表内。 5、统一图片辨率:对指定文件夹内的所有图片进辨率标准化处理。 6、图片批量缩放:依据设定比例对图片进放大或缩小,支持按百比调整。 7、图片批量插入:将图片批量插入到当前文档,可选择图片名称的展示形式,并设定图片的高度。 8、图片格式统一转换:将指定文件夹内的所有图片转换为相同的文件格式。 9、内容批量替换:对文档内容、页眉及页脚执批量替换操作,例如将数字1替换为字母A,数字2替换为字母B,数字3替换为字母C等。 10、图片批量导出:将文档内所...

7,788

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧