1.Vb如何获取系统卷标磁盘名字各是什么? 急求,谢啦

2.vb.net 怎么获取客户端ip地址?

3.vb获取网卡mac的完整代码

4.vb如何读取系统已安装软件并获取软件版本号

5.VB连接本地SQL数据库,如何自动获取计算机名 详细的高分追加。

6.请问怎么用VB修改WIN7系统IP地址、子网掩码、网关、DNS服务器地址

vb怎么获取本地电脑系统信息,vb获取当前目录

如何在区域网内显示出计算机的中文名字

每台计算机新增计算机描述即可

方法:我的电脑-右键-计算机名-计算机描述(相应中文名)-应用-确定

ok

如何同步区域网内计算机显示时间

保持时钟同步,是一个网路稳定、可靠执行的前提,比如SDH(同步数字体系)网路中必须要精确的做到时钟同步,才有可能保证网间资料的准确传输,但是这些执行在网路底层的规范对一般使用者来说太遥远了,对于区域网使用者来说,最常用的时间同步操作就是“自动与Inter时间伺服器同步”

那么我们在区域网中设定时间同步有什么意义呢?又是如何实现的呢?内外网中时间伺服器的设定又有何区别?下面我们结合实际区域网中设定例项来详细说明一下。

一、区域网内由于时间不同步造成的问题

作为网路管理员,既要保证网路装置的稳定执行,又要及时处理网路中随时出现的故障,而如果无法实现时间同步,就会增加处理故障的难度,比如:

(一)有时候需要设定CISCO交换机装置定时重启,但每次执行该操作前都要先对时,这样才能保证执行reload命令时的准确性,更要命的是重启后以后,交换机的时间又变回预设的1994年了。

(二)局域内有几十台交换机,虽然大多可以实现远端网管,但由于时间不一致,造成无法准备网路故障发生的确切时间。

(三)最近单位实现指纹机考勤了,同事们也习惯于看电脑上的时间去按指纹,但微机上的时间老不准,结果往往赞成不是去早了就是去晚了,还有在进行档案传输时,不准确的时间资讯也影响了检索结果,甚至会引起不必要的误会。

那么如何在区域网内实现时间同步呢?

二、时间同步的方法

(一)外网(办公区域网)时间同步的方法

外网,也就是办公区域网,这个区域网的网路装置都可以接入网际网路,一个简化的网路拓扑

外网使用了一台CISCO3550交换机作为核心交换机,下面级联了若干台CISCO的29系列交换机,区域网内还有多台微机。

在这种网路模式中,我们不能保证每台网络装置都可以快速的与网际网路上时间伺服器进行时间同步(比如由于网速或是时间伺服器本身的问题),能够保证的是区域网内有一个比较稳定可靠的网路质量,这样的话,我们就选定了CISCO3550作为区域网内的时间伺服器,CISCO3550交换机肩负著两个作用,一、它要与网际网路上的时间伺服器进行同步(保证自身时钟准确),二、它要将时钟资讯在局域内广播出去,从而使得区域网内的网路装置(交换机、PC机)都可以与它进行时钟同步,从而保证全网内的时钟同步,下面我分别说明一下实现步骤。

1、设定CISCO3550交换机与网际网路上的时间伺服器进行同步

3550#conf t

Enter configuration mands, one per line. End with CNTL/Z.

3550(config)#ntp peer 210.72.145.44 (peer的含义为本装置既可以接受时钟同步,也可以给远端装置提供时钟,双向 210.72.145.44是中科院国家授时中心的IP地址 )

clock timezone gmt 8 (即设定为北京时区)

是的,只需在CISCO3550交换机中敲这么简单的两条命令,过一段时间(前提是CISCO3550交换机可以访问网际网路),就可以实现与与网际网路上的时间伺服器同步了,用直观的感受可以用show clock命令看出来,如下所示:

3550#show clock

22:18:45.667 gmt Sat May 23 2009

也就是说明本机的时间已经与网际网路上的时间伺服器同步了。

小提示

为了更好的理解以上的两步设定,还是有一些知识是需要了解的

(1) 如何得到网际网路上的时间伺服器的地址

很多方法可以得到,一是XP自身就带了两个时间伺服器:time.windows.和time.nist.gov,我们只需要DOS模式下执行一下ping操作,就可以得到它们对应的IP地址,分别为207.46.232.182和192.43.244.18,二是中科院有一个标准的授时伺服器,地址为210.72.145.44,三可以从网上查,可以得到更为丰富的资讯,比如我们访问ntp.这个的网站,就可以找到一堆时间伺服器的地址,如表1所示:

Area:HostName:

Worldwidepool.ntp.

Asiaasia.pool.ntp.

Europeeurope.pool.ntp.

North Americanorth-america.pool.ntp.

Oceaniaoceania.pool.ntp.

South Americasouth-america.pool.ntp.

表1 网际网路上的时间伺服器列表

这些伺服器都是可用的,而且对其进行连线速度也很快,其中重点推荐pool.ntp.,正象它的网址名字所表达的,这实际是一个地址池,里面根据实际情况来实时调整可用的伺服器地址。

2) 在交换机上如何直接写域名

在交换机上可以直接写时间伺服器的域名,前提是已经在交换机上设定了DNS伺服器,如下所示:

ip name-server 218.56.57.58

ip name-server 219.146.0.130

在交换机上设定了DNS伺服器资讯以后,我们再在交换机上执行ping网址的操作,就会看到交换机自动在执行域名到IP地址的转换,如下所示:

3550#ping pool.ntp.

Translating "pool.ntp."...domain server (218.56.57.58) [OK]

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 61.129.66.79, timeout is 2 seconds:

!!!!!

Suess rate is 100 percent (5/5), round-trip min/avg/max = 144/145/148 ms

这时已经看到交换机具备了域名至IP自动转换的能力,我们也就可以直接写时间伺服器的域名了,如下所示:

3550(config)#ntp peer pool.ntp.

(3) 如何检视NTP的资讯

利用show clock命令可以了解到交换机当前的时间资讯,另外还有一个更专业的命令,那就是“show ntp status”,它可以列出更加详细的本机的ntp资讯,如下所示:

3550#show ntp status

Clock is synchronized, stratum 3, reference is 61.129.66.79

nominal freq is 250.0000 Hz, actual freq is 249.9983 Hz, precision is 2**18

reference time is CDC28871.0C1D8818 (22:36:33.047 gmt Sat May 23 2009)

clock offset is 109.9952 msec, root delay is 328.66 msec

root dispersion is 16010.33 msec, peer dispersion is 15875.03 msec

从显示的资讯中,我们可以了解到:目前交换机是否已经与时间伺服器同步了(Clock is synchronized),是与哪台时间伺服器进行同步的(reference is 61.129.66.79)等等很多有用的资讯。

2、如何将CISCO3550交换机做成区域网内的一台时间伺服器

现在CISCO3550交换机自身的时钟是准确了,那么如何将时间资讯在区域网内广播出去呢?执行如下的操作即可:

3550(config)#ntp source vlan 7

3550(config)#inter vlan 7

3550(config-if)#ntp broadcast version 2

由于我单位CISCO3550交换机规划了多个VLAN,我是选择了一个与PIX防火墙防火墙连线的VLAN上进行了NTP资讯的广播,实际上由于在交换机上启用了VLAN之间的路由(使用ip routing命令来实现),别的VLAN中的交换机PC也是可以接受该广播资讯的。

3、CISCO29系列交换机如何与CISOC3550进行时间同步

CISCO29系列交换机,作为终端与时间伺服器进行时间同步的设定很容易,只需指定NTP伺服器的地址即可,如下所示:

172switch(config)#ntp server 172.19.96.1 (ntp server表示本装置通过远端时钟源,来更新自身的时间,单向)

172switch(config)#ntp server 192.168.201.2

VB如何获取区域网内所有计算机的名字

你看看这3个API ,应该对你有帮助.

WNetGetConnection

VB宣告

Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" (ByVal lpszLocalName As String, ByVal lpszRemoteName As String, cbRemoteName As Long) As Long

说明

获取本地或已连线的一个资源的网路名称

返回值

Long,零表示成功。会设定GetLastError。如GetLastError是ERROR_EXTENDED_ERROR,则可用WNetGetLastError取得额外的错误资讯

引数表

引数 型别及说明

lpszLocalName String,本地装置的名字

lpszRemoteName String,指定一个字串缓冲区,用于装载装置的资源名称

cbRemoteName Long,lpszRemoteName缓冲区的字元数量。如缓冲区不够大,则设为需要的缓冲区长度

WNetGetUniversalName

VB宣告

Declare Function WNetGetUniversalName Lib "mpr" Alias "WNetGetUniversalNameA" (ByVal lpLocalPath As String, ByVal dwInfoLevel As Long, lpBuffer As Any, lpBufferSize As Long) As Long

说明

获取网路中一个档案的远端名称以及/或者UNC(统一命名规范)名称。例如,假设一个已连线的远端驱动器是\\othersystem\CDrive,它对应的本地驱动器是F:,而且在它的子目录temp中包含了档案.doc。那么运算结果如下:LocalPath .doc 或 f:\temp\.doc(或者档案的任何相对路径名)

UNC 名称: \\othersystem\CDrive\temp\.doc

连线名称: \\othersystem\CDrive

剩余名称: \temp\.doc

它们分别对应于由这个函式装载的REMOTE_NAME_INFO结构的栏位,对该结构的定义如下:

Type REMOTE_NAME_INFO

pUniversalName As Long

pConnectionName As Long

pRemainingPath As Long

End Type

返回值

Long,零表示成功。会设定GetLastError。如GetLastError是ERROR_EXTENDED_ERROR,则可用WNetGetLastError取得额外的错误资讯

引数表

引数 型别及说明

lpLocalPath String,磁碟档案的名字

dwInfoLevel Long,下述常数之一:

UNIVERSAL_NAME_INFO_LEVEL 只设置pUniversalName栏位

REMOTE_NAME_INFO_LEVEL 设定REMOTE_NAME_INFO结构中的所有三个栏位

lpBuffer Any,指定用于装载UNC资讯的一个缓冲区。缓冲区起点与一个REMOTE_NAME_INFO结构对应

lpBufferSize Long,以位元组为单位指定lpBuffer缓冲区的长度。如缓冲区不够大,则设为需要的缓冲区长度

WNetGetUser

VB宣告

Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA" (ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As Long

说明

获取一个网路资源用以连线的名字

返回值

Long,零表示成功。会设定GetLastError。如GetLastError是ERROR_EXTENDED_ERROR,则可用WNetGetLastError取得额外的错误资讯

引数表

引数 型别及说明

lpName String,指定已连线资源的远端名称或本地名称。用vbNullString获取当前使用者的名字

lpUserName String,用于装载使用者名称的一个字串缓冲区

lpnLength Long,lpUserName缓冲区的长度。如缓冲区不够大,则自动设为需要的缓冲区长度

更改计算机名字后区域网内显示多个名字

不需要重灌,旧名字虽然显示,但你点选它是无效的。

过段时间那个旧名字会自动消失,这是一个网路中名字的关于有效期限的问题。这就如同贴在城墙上的公告,撤销这个公告时,需要别人过去撕公告一样,需要时间,你看到的只是撤销前的状态而已。

如何在区域网内指定计算机共享inter上网

两个人交换机共享帐号上网的设定:

猫接入交换机

先是一台机进行PPOE拔号,共享拔号

点拔号右键属性--高阶--允许其他网路使用者通过此计算机的inter连线来连线勾上

然后设好你的本地连线的IP举个例子

你拔号的机子IP设定为

IP 地址: 192.168.1.26

子网掩码: 255.255.255.0

预设闸道器: 192.168.1.1

DNS 伺服器: 202.96.134.133, 202.103.100.100

哪么你另一台机的IP要设定为

IP 地址: 192.168.1.12(这里的IP你可以随便设主要是跟拔号同一IP段就行)

子网掩码: 255.255.255.0

预设闸道器: 192.168.1.26(这个必须是拔号机子的IP)

DNS 伺服器: 202.96.134.133, 202.103.100.100

其他电脑也像第二台电脑那样设定,IP地址不同第二台电脑,其他都一样设定

如何在区域网内用其他计算机的印表机

开始->执行

输入 \\对方计算机IP地址 例如 \\192.168.1.10 回车

开启后就能看到对方共享的印表机,直接双击印表机,就安装到你的机器里面

这种方法最快捷方便。

如何在区域网内,提高我的计算机网速?

如果是硬体问题或是网路问题,那就没什么好办法了,但是如果是系统的问题,你可以用这个方法试下:点选“开始”—“执行”,输入“GPEDIT.MSC”,开启组策略,然后在“计算机配置”里点选“管理模板”—“网路”—“QoS资料包排程程式”,然后在右边视窗双击“限制可保留频宽””,在其属性对话方块中的“设定”选项卡中将“限制可保留频宽”设定为“已启用”,然后在下方“频宽限制”栏将“频宽限制”设定为0就行了。 这样可以提高20%的频宽。

如何在区域网内,两台计算机传送大档案

这个方法比较多,就看你的网路和硬体装置环境了。由于具体内容较多,可以分项百度,按照自己的实际情况来。

1、网线直传。

2、通过新增网路上的芳邻的方法。

3、通过蓝芽/无线互传。

4、拆硬碟挂在另一台机器上直接拷贝。

5、通过磁碟、U盘、光碟互相拷贝。

6、如果联接网际网路的的话,那就更方便了,QQ什么的都可以传。

区域网内的计算机如何上网

把网线接在你的用路由器上,在路由器上调好IP,让路由器给你们区域网内的计算机自动分配IP地址不就可以了。 好好想想,动动脑子啊。

如何在区域网中隐藏计算机

在桌面的网路上的芳邻上点右键选择“属性”,(如果你的系统是WindowsXP那么就用滑鼠右击“本地连线”,选择属性)在弹出的对话方块中把“Microsoft网路的档案和印表机共享”和“QoS资料包计划程式”前面的勾去掉,重新启动计算机,一切就OK了。这样别人无法看到你的电脑,自然也就无法共享你的电脑里的内容了。如果你不想这样,那么就将这两个选项前面的勾选中就行了

Vb如何获取系统卷标磁盘名字各是什么? 急求,谢啦

VB6.0可使用Winsock控件读取它的LocalIP属性来获取当前本机的IP地址。

Winsock 控件,它提供了访问 TCP 和 UDP 网络服务的方便途径。Microsoft Access、Visual Basic、Visual C++ 或 Visual

FoxPro 的开发人员都可使用它。为编写客户或服务器应用程序,不必了解 TCP 的细节或调用低级的 Winsock

APIs。通过设置控件的属性并调用其方法就可轻易连接到一台远程机器上去,并且还可双向交换数据。

LocalIP 属性

返回本地机器的 IP 地址,格式是 IP 地址加点字符串 (xxx.xxx.xxx.xxx)。在设计时是只读的,而且是不可用的。

语法

object.LocalIP

object 所在处代表一个对象表达式,其值是“应用于”列表中的对象。

代码示例:

Private?Sub?Form_Load()

Label1.Caption?=?Winsock1.LocalIP

End?Sub

vb.net 怎么获取客户端ip地址?

添加对应DriveListBox控件

代码如下:

n?=?Drive1.ListCount

For?i?=?0?To?n?-?1

Drive1.ListIndex?=?i

DrvName?=?Left(Drive1.Drive,?2)'这是盘符名

DrvLabel?=?Mid(Drive1.Drive,?3,?Len(Drive1.Drive)?-?2)?'这是卷标名

'需要说明的是:卷标名如果为默认名称,读到是空的,可加个if显示为“本地磁盘”

Print?DrvName,?DrvLabel

Next?i 需要帮忙,向我求助好了~ ?两页一答!

vb获取网卡mac的完整代码

你最好可以换台电脑访问网址看获取IP地址状况。

如果你测试访问的时候,使用的是 localhost 进行访问的,那么服务器端获得的也就是127.0.0.1,因为localhost是一个环路地址,特殊的.如果你是通过你的ip地址进行访问的,那么获得的IP地址就会是正确的了. 要通过自己本地的IP进行访问,在控制面板的网络连接里找到本地连接,查看它的属性,并找到"详细信息"按钮,点击后弹出的对话框中IPV4地址就是本地地址.或打开命令行,输入 ipconfig /all 即可找到本地地址.在浏览器中通过这个IP地址访问,就不会是127.0.0.1了.

vb如何读取系统已安装软件并获取软件版本号

VB获取网卡MAC地址源代码

具体代码:(其中GetMACAddress() 函数为楼主所需函数)

Option Explicit

Public CheckCode As Long

Private Const NCBASTAT As Long = &H33

Private Const NCBNAMSZ As Integer = 16

Private Const HEAP_ZERO_MEMORY As Long = &H8

Private Const HEAP_GENERATE_EXCEPTIONS As Long = &H4

Private Const NCBRESET As Long = &H32

Private Type NCB

ncb_command As Byte

ncb_retcode As Byte

ncb_lsn As Byte

ncb_num As Byte

ncb_buffer As Long

ncb_length As Integer

ncb_callname As String * NCBNAMSZ

ncb_name As String * NCBNAMSZ

ncb_rto As Byte

ncb_sto As Byte

ncb_post As Long

ncb_lana_num As Byte

ncb_cmd_cplt As Byte

ncb_reserve(9) As Byte

ncb_event As Long

End Type

Private Type ADAPTER_STATUS

adapter_address(5) As Byte

rev_major As Byte

reserved0 As Byte

adapter_type As Byte

rev_minor As Byte

duration As Integer

frmr_recv As Integer

frmr_xmit As Integer

iframe_recv_err As Integer

xmit_aborts As Integer

xmit_success As Long

recv_success As Long

iframe_xmit_err As Integer

recv_buff_unavail As Integer

t1_timeouts As Integer

ti_timeouts As Integer

Reserved1 As Long

free_ncbs As Integer

max_cfg_ncbs As Integer

max_ncbs As Integer

xmit_buf_unavail As Integer

max_dgram_size As Integer

pending_sess As Integer

max_cfg_sess As Integer

max_sess As Integer

max_sess_pkt_size As Integer

name_count As Integer

End Type

Private Type NAME_BUFFER

name As String * NCBNAMSZ

name_num As Integer

name_flags As Integer

End Type

Private Type ASTAT

adapt As ADAPTER_STATUS

NameBuff(30) As NAME_BUFFER

End Type

Private Declare Function Netbios Lib "netapi32.dll" (pncb As NCB) As Byte

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, _

ByVal hpvSource As Long, _

ByVal cbCopy As Long)

Private Declare Function GetProcessHeap Lib "kernel32" () As Long

Private Declare Function HeapAlloc Lib "kernel32" (ByVal hHeap As Long, _

ByVal dwFlags As Long, _

ByVal dwBytes As Long) As Long

Private Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, _

ByVal dwFlags As Long, _

lpMem As Any) As Long

Public Function GetMAC() As Integer

Dim bRet As Byte

Dim myNcb As NCB

Dim myASTAT As ASTAT

Dim pASTAT As Long

Dim intMAC As Integer

myNcb.ncb_command = NCBRESET

bRet = Netbios(myNcb)

With myNcb

.ncb_command = NCBASTAT

.ncb_lana_num = 0

.ncb_callname = "* "

.ncb_length = Len(myASTAT)

pASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS Or HEAP_ZERO_MEMORY, .ncb_length)

End With

If pASTAT = 0 Then

Exit Function

End If

myNcb.ncb_buffer = pASTAT

bRet = Netbios(myNcb)

CopyMemory myASTAT, myNcb.ncb_buffer, Len(myASTAT)

intMAC = myASTAT.adapt.adapter_address(0)

intMAC = intMAC + myASTAT.adapt.adapter_address(1)

intMAC = intMAC + myASTAT.adapt.adapter_address(2)

intMAC = intMAC + myASTAT.adapt.adapter_address(3)

intMAC = intMAC + myASTAT.adapt.adapter_address(4)

intMAC = intMAC + myASTAT.adapt.adapter_address(5)

GetMAC = intMAC

Call HeapFree(GetProcessHeap(), 0, pASTAT)

End Function

Public Function GetMACAddress() As String

Dim bRet As Byte

Dim myNcb As NCB

Dim myASTAT As ASTAT

Dim pASTAT As Long

myNcb.ncb_command = NCBRESET

bRet = Netbios(myNcb)

With myNcb

.ncb_command = NCBASTAT

.ncb_lana_num = 0

.ncb_callname = "* "

.ncb_length = Len(myASTAT)

pASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS Or HEAP_ZERO_MEMORY, .ncb_length)

End With

If pASTAT = 0 Then

Exit Function

End If

myNcb.ncb_buffer = pASTAT

bRet = Netbios(myNcb)

CopyMemory myASTAT, myNcb.ncb_buffer, Len(myASTAT)

GetMACAddress = HexEx(myASTAT.adapt.adapter_address(0)) & "-" & HexEx(myASTAT.adapt.adapter_address(1)) & "-" & HexEx(myASTAT.adapt.adapter_address(2)) & "-" & HexEx(myASTAT.adapt.adapter_address(3)) & "-" & HexEx(myASTAT.adapt.adapter_address(4)) & "-" & HexEx(myASTAT.adapt.adapter_address(5))

Call HeapFree(GetProcessHeap(), 0, pASTAT)

End Function

Private Function HexEx(ByVal B As Long) As String

Dim aa As String

aa = Hex$(B)

If Len(aa) < 2 Then

aa = "0" & aa

End If

HexEx = aa

End Function

VB连接本地SQL数据库,如何自动获取计算机名 详细的高分追加。

布置这类作业我估计是你们老师接到这类赚钱活儿了。

VB可以用GetSetting来读取注册表,但只能在VB区域的注册表里读出。如果希望读取系统里的数据必须从系统区域里读出注册表内容。VB里并未自带这类方法,因此必须借助Win API函数。使用起来比较复杂我倒是可以给你一些例子的,后面我可以附上。

如果只是为了做作业是不是应该用更简单的方法呢?VB里的Dir函数可以列出文件夹,通常来说额外安装的程序都会在C:\Program Files\里有相应文件夹,你只要把那里的文件夹名读出来不就可以了?代码如下:

MyPath = "c:\Program Files\" ' 指定路径。

MyName = Dir(MyPath, vbDirectory) ' 找寻第一项。

Do While MyName <> "" ' 开始循环。

' 跳过当前的目录及上层目录。

If MyName <> "." And MyName <> ".." Then

' 使用位比较来确定 MyName 代表一目录。

If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then

Debug.Print MyName ' 如果它是一个目录,将其名称显示出来。

End If

End If

MyName = Dir ' 查找下一个目录。

Loop

如果想通过Win API函数实现也行,给你些有关的API声明

Option Explicit

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _

(dest As Any, source As Any, ByVal numBytes As Long)

Private Declare Function ExpandEnvironmentStrings Lib "kernel32" Alias "ExpandEnvironmentStringsA" _

(ByVal lpSrc As String, ByVal lpDst As String, ByVal nSize As Long) As Long

''''//注册表 API 函数声明

Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" _

(ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, _

ByVal samDesired As Long, phkResult As Long) As Long

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias _

"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, _

ByVal lpReserved As Long, lpType As Long, lpData As Any, _

lpcbData As Long) As Long

Private Declare Function RegSetValueEx Lib "advapi32" Alias "RegSetValueExA" _

(ByVal hKey As Long, ByVal lpValueName As String, _

ByVal Reserved As Long, ByVal dwType As Long, _

ByVal lpbData As Any, ByVal cbData As Long) As Long

Private Declare Function RegCreateKeyEx Lib "advapi32" Alias "RegCreateKeyExA" _

(ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, _

ByVal lpClass As String, ByVal dwOptions As Long, _

ByVal samDesired As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, _

phkResult As Long, lpdwDisposition As Long) As Long

Private Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" _

(ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, _

lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As String, _

lpcbClass As Long, lpftLastWriteTime As FILETIME) As Long

Private Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" _

(ByVal hKey As Long, ByVal dwIndex As Long, _

ByVal lpValueName As String, lpcbValueName As Long, ByVal lpReserved As Long, _

lpType As Long, ByVal lpData As String, lpcbData As Long) As Long

Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" _

(ByVal hKey As Long, ByVal lpSubKey As String) As Long

Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" _

(ByVal hKey As Long, ByVal lpValueName As String) As Long

Private Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" _

(ByVal hKey As Long, ByVal ipValueName As String, _

ByVal Reserved As Long, ByVal dwType As Long, _

ByVal lpValue As String, ByVal cbData As Long) As Long

Private Declare Function RegSetValueExLong Lib "advapi32.dll" Alias "RegSetValueExA" _

(ByVal hKey As Long, ByVal lpValueName As String, _

ByVal Reserved As Long, ByVal dwType As Long, _

lpValue As Long, ByVal cbData As Long) As Long

Private Declare Function RegSetValueExByte Lib "advapi32.dll" Alias "RegSetValueExA" _

(ByVal hKey As Long, ByVal lpValueName As String, _

ByVal Reserved As Long, ByVal dwType As Long, _

lpValue As Byte, ByVal cbData As Long) As Long

Private Declare Function RegQueryInfoKey Lib "advapi32.dll" Alias "RegQueryInfoKeyA" _

(ByVal hKey As Long, ByVal lpClass As String, lpcbClass As Long, _

ByVal lpReserved As Long, lpcSubKeys As Long, _

lpcbMaxSubKeyLen As Long, lpcbMaxClassLen As Long, lpcValues As Long, _

lpcbMaxValueNameLen As Long, lpcbMaxValueLen As Long, _

lpcbSecurityDescriptor As Long, lpftLastWriteTime As FILETIME) As Long

Private Declare Function RegEnumValueInt Lib "advapi32.dll" Alias "RegEnumValueA" _

(ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, _

lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, _

lpData As Byte, lpcbData As Long) As Long

Private Declare Function RegEnumValueStr Lib "advapi32.dll" Alias "RegEnumValueA" _

(ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, _

lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, _

lpData As Byte, lpcbData As Long) As Long

Private Declare Function RegEnumValueByte Lib "advapi32.dll" Alias "RegEnumValueA" _

(ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, _

lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, _

lpData As Byte, lpcbData As Long) As Long

''''//注册表结构

Private Type SECURITY_ATTRIBUTES

nLength As Long

lpSecurityDescriptor As Long

bInheritHandle As Boolean

End Type

Private Type FILETIME

dwLowDateTime As Long

dwHighDateTime As Long

End Type

''''//注册表访问权

Const KEY_QUERY_VALUE = &H1

Const KEY_SET_VALUE = &H2

Const KEY_CREATE_SUB_KEY = &H4

Const KEY_ENUMERATE_SUB_KEYS = &H8

Const KEY_NOTIFY = &H10

Const KEY_CREATE_LINK = &H20

Const KEY_ALL_ACCESS = &H3F

''''//打开/建立选项

Const REG_OPTION_NON_VOLATILE = 0&

Const REG_OPTION_VOLATILE = &H1

''''//Key 创建/打开

Const REG_CREATED_NEW_KEY = &H1

Const REG_OPENED_EXISTING_KEY = &H2

''''//预定义存取类型

Const STANDARD_RIGHTS_ALL = &H1F0000

Const SPECIFIC_RIGHTS_ALL = &HFFFF

''''//严格代码定义

Const ERROR_SUCCESS = 0&

Const ERROR_ACCESS_DENIED = 5

Const ERROR_NO_MORE_ITEMS = 259

Const ERROR_MORE_DATA = 234 ''''// 错误

''''//注册表值类型列举

Private Enum RegDataTypeEnum

'''' REG_NONE = (0) ''''// No value type

REG_SZ = (1) ''''// Unicode nul terminated string

REG_EXPAND_SZ = (2) ''''// Unicode nul terminated string w/enviornment var

REG_BINARY = (3) ''''// Free form binary

REG_DWORD = (4) ''''// 32-bit number

REG_DWORD_LITTLE_ENDIAN = (4) ''''// 32-bit number (same as REG_DWORD)

REG_DWORD_BIG_ENDIAN = (5) ''''// 32-bit number

'''' REG_LINK = (6) ''''// Symbolic Link (unicode)

REG_MULTI_SZ = (7) ''''// Multiple, null-delimited, double-null-terminated Unicode strings

'''' REG_RESOURCE_LIST = (8) ''''// Resource list in the resource map

'''' REG_FULL_RESOURCE_DESCRIPTOR = (9) ''''// Resource list in the hardware description

'''' REG_RESOURCE_REQUIREMENTS_LIST = (10)

End Enum

''''//注册表基本键值列表

Public Enum RootKeyEnum

HKEY_CLASSES_ROOT = &H80000000

HKEY_CURRENT_USER = &H80000001

HKEY_LOCAL_MACHINE = &H80000002

HKEY_USERS = &H80000003

HKEY_PERFORMANCE_DATA_WIN2K_ONLY = &H80000004 ''''//仅Win2k

HKEY_CURRENT_CONFIG = &H80000005

HKEY_DYN_DATA = &H80000006

End Enum

''''// for specifying the type of data to save

Public Enum RegValueTypes

eInteger = vbInteger

eLong = vbLong

eString = vbString

eByteArray = vbArray + vbByte

End Enum

''''//保存时指定类型

Public Enum RegFlags

IsExpandableString = 1

IsMultiString = 2

''''IsBigEndian = 3 ''''// 无指针同样不要设置大Endian值

End Enum

Private Const ERR_NONE = 0

Function SetRegistryValue(ByVal hKey As RootKeyEnum, ByVal KeyName As String, _

ByVal ValueName As String, ByVal Value As Variant, valueType As RegValueTypes, _

Optional Flag As RegFlags = 0) As Boolean

Dim handle As Long

Dim lngValue As Long

Dim strValue As String

Dim binValue() As Byte

Dim length As Long

Dim retVal As Long

Dim SecAttr As SECURITY_ATTRIBUTES ''''//键的安全设置

''''//设置新键值的名称和默认安全设置

SecAttr.nLength = Len(SecAttr) ''''//结构大小

SecAttr.lpSecurityDescriptor = 0 ''''//默认安全权限

SecAttr.bInheritHandle = True ''''//设置的默认值

''''// 打开或创建键

''''If RegOpenKeyEx(hKey, KeyName, 0, KEY_ALL_ACCESS, handle) Then Exit Function

retVal = RegCreateKeyEx(hKey, KeyName, 0, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, SecAttr, handle, retVal)

If retVal Then Exit Function

''''//3种数据类型

Select Case VarType(Value)

Case vbByte, vbInteger, vbLong ''''// 若是字节, Integer值或Long值...

lngValue = Value

retVal = RegSetValueExLong(handle, ValueName, 0, REG_DWORD, lngValue, Len(lngValue))

Case vbString ''''// 字符串, 扩展环境字符串或多段字符串...

strValue = Value

Select Case Flag

Case IsExpandableString

retVal = RegSetValueEx(handle, ValueName, 0, REG_EXPAND_SZ, ByVal strValue, 255)

Case IsMultiString

retVal = RegSetValueEx(handle, ValueName, 0, REG_MULTI_SZ, ByVal strValue, 255)

Case Else ''''// 正常 REG_SZ 字符串

retVal = RegSetValueEx(handle, ValueName, 0, REG_SZ, ByVal strValue, 255)

End Select

Case vbArray + vbByte ''''// 如果是字节数组...

binValue = Value

length = UBound(binValue) - LBound(binValue) + 1

retVal = RegSetValueExByte(handle, ValueName, 0, REG_BINARY, binValue(0), length)

Case Else ''''// 如果其它类型

RegCloseKey handle

''''Err.Raise 1001, , "不支持的值类型"

End Select

''''// 返回关闭结果

RegCloseKey handle

''''// 返回写入成功结果

SetRegistryValue = (retVal = 0)

End Function

Function GetRegistryValue(ByVal hKey As RootKeyEnum, ByVal KeyName As String, _

ByVal ValueName As String, Optional DefaultValue As Variant) As Variant

Dim handle As Long

Dim resLong As Long

Dim resString As String

Dim resBinary() As Byte

Dim length As Long

Dim retVal As Long

Dim valueType As Long

Const KEY_READ = &H20019

''''// 默认结果

GetRegistryValue = IIf(IsMissing(DefaultValue), Empty, DefaultValue)

''''// 打开键, 不存在则退出

If RegOpenKeyEx(hKey, KeyName, 0, KEY_READ, handle) Then Exit Function

''''// 准备 1K resBinary 用于接收

length = 1024

ReDim resBinary(0 To length - 1) As Byte

''''// 读注册表值

retVal = RegQueryValueEx(handle, ValueName, 0, valueType, resBinary(0), length)

''''// 若resBinary 太小则重读

If retVal = ERROR_MORE_DATA Then

''''// resBinary放大,且重新读取

ReDim resBinary(0 To length - 1) As Byte

retVal = RegQueryValueEx(handle, ValueName, 0, valueType, resBinary(0), _

length)

End If

''''// 返回相应值类型

Select Case valueType

Case REG_DWORD, REG_DWORD_LITTLE_ENDIAN

''''// REG_DWORD 和 REG_DWORD_LITTLE_ENDIAN 相同

CopyMemory resLong, resBinary(0), 4

GetRegistryValue = resLong

Case REG_DWORD_BIG_ENDIAN

''''// Big Endian''''s 用在非-Windows环境, 如Unix系统, 本地计算机远程访问

CopyMemory resLong, resBinary(0), 4

GetRegistryValue = SwapEndian(resLong)

Case REG_SZ, REG_EXPAND_SZ

resString = Space$(length - 1)

CopyMemory ByVal resString, resBinary(0), length - 1

If valueType = REG_EXPAND_SZ Then

''''// 查询对应的环境变量

GetRegistryValue = ExpandEnvStr(resString)

Else

GetRegistryValue = resString

End If

Case REG_MULTI_SZ

''''// 复制时需指定2个空格符

resString = Space$(length - 2)

CopyMemory ByVal resString, resBinary(0), length - 2

GetRegistryValue = resString

Case Else '''' 包含 REG_BINARY

''''// resBinary 调整

If length <> UBound(resBinary) + 1 Then

ReDim Preserve resBinary(0 To length - 1) As Byte

End If

GetRegistryValue = resBinary()

End Select

''''// 关闭

RegCloseKey handle

End Function

Public Function DeleteRegistryValueOrKey(ByVal hKey As RootKeyEnum, RegKeyName As String, _

ValueName As String) As Boolean

''''//删除注册表值和键,如果成功返回True

Dim lRetval As Long ''''//打开和输出注册表键的返回值

Dim lRegHWND As Long ''''//打开注册表键的句柄

Dim sREGSZData As String ''''//把获取值放入缓冲区

Dim lSLength As Long ''''//缓冲区大小. 改变缓冲区大小要在调用之后

''''//打开键

lRetval = RegOpenKeyEx(hKey, RegKeyName, 0, KEY_ALL_ACCESS, lRegHWND)

''''//成功打开

If lRetval = ERR_NONE Then

''''//删除指定值

lRetval = RegDeleteValue(lRegHWND, ValueName) ''''//如果已存在则先删除

''''//如出现错误则删除值并返回False

If lRetval <> ERR_NONE Then Exit Function

''''//注意: 如果成功打开仅关闭注册表键

lRetval = RegCloseKey(lRegHWND)

''''//如成功关闭则返回 True 或者其它错误

If lRetval = ERR_NONE Then DeleteRegistryValueOrKey = True

End If

End Function

Private Function ExpandEnvStr(sData As String) As String

''''// 查询环境变量和返回定义值

''''// 如: %PATH% 则返回 "c:\;c:\windows;"

Dim c As Long, s As String

s = "" ''''// 不支持Windows 95

''''// get the length

c = ExpandEnvironmentStrings(sData, s, c)

''''// 展开字符串

s = String$(c - 1, 0)

c = ExpandEnvironmentStrings(sData, s, c)

''''// 返回环境变量

ExpandEnvStr = s

End Function

Private Function SwapEndian(ByVal dw As Long) As Long

''''// 转换大DWord 到小 DWord

CopyMemory ByVal VarPtr(SwapEndian) + 3, dw, 1

CopyMemory ByVal VarPtr(SwapEndian) + 2, ByVal VarPtr(dw) + 1, 1

CopyMemory ByVal VarPtr(SwapEndian) + 1, ByVal VarPtr(dw) + 2, 1

CopyMemory SwapEndian, ByVal VarPtr(dw) + 3, 1

End Function

请问怎么用VB修改WIN7系统IP地址、子网掩码、网关、DNS服务器地址

首先定义一个公共变量a

public a As Object

a = CreateObject("Wscript.Network")

然后将

myStr = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=日报表原始数据;Data Source=小李飞刀;Initial File Name=D:\日报\库\日报表原始数据2009_Data.MDF"

改成

myStr = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=日报表原始数据;Data Source="+a.ComputerName+";Initial File Name=D:\日报\库\日报表原始数据2009_Data.MDF"

如电脑使用Win7系统,可按以下方法设置DNS:您右键点击电脑桌面的“网络”图标 ,选择“属性” >选择“控制面板” >在“网络和共享中心”中可看到当前的网络状况,点击左边的“更改适配器设置” >右键单击“本地连接”,选择“属性” >选择“internet协议版本4(TCP/IPv4)”,点击“属性” >选择“使用下列DNS服务器地址”,输入“首选”及“备用”DNS地址,最后点击“确认”即可。

温馨提示:每个地市的DNS地址参数不同,建议您可联系人工客服或前往营业厅进行咨询了解。