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

iwindy 2002-06-06 09:57:53
哪位知道如何获得和修改本机的ip地址?
...全文
180 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))。
随着通信电子技术的迅速发展,信息技术给家居业产生了深远的影响,家居环境的智能化监控已经成为智能家居的一个重要的发展方向。人们逐渐对自己的生活提出一种更高的要求,他们需要一种智能化、可交互,并且融合现代创新科技的产品来改善他们的生活环境,使他们生活更加安全、舒适、便捷、智能。本文根据智能家居的发展背景和研究现状,并且从实用性和可性角度出发,研究设计了一种基于STM32单片机的智能家居系统。该系统由一个多功能综合的技术系统组成,各个多功能子系统间具有协同配合能力。基于STM32单片机实现的功能子系统包括:智能温度检测,智能湿度检测,智能烟雾/火灾检测智能检测,无线传输,人机交互机构,风扇调节,报警模块。 整个系统为前端51单片机采集板和后端STM32单片机接收板。 采集板使用DHT11温湿度传感器、MQ烟雾传感器完成室内家居环境的采集。然后通过nRFL24L01将采集到的数据发送给后端。接收板使用LCD1602完成数据显示、使用蜂鸣器模块报警,使用风扇驱动模块调节室内家居环境。本文完成了智能家居控制系统前端、后端软硬件的设计,使用Altium designer绘制了电路原理图,使用Keil C完成了51单片机和STM32单片机的编程与调试。 最后,对本文设计的基于STM32的智能家居控制系统进部署调试。试验结果表明,该系统可成功应用在智能家居环境检测调节和火灾安全防护的领域,可提高家居生活智能化水平。

7,787

社区成员

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

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