vb 取得计算机名及目录
Public gCompName
'取得计算机名及Windows目录
Dim i%
Dim c$
Dim cSql As String
Dim cProduct As String
c = Space(256)
i = GetComputerName(c, 256)
gCompName = Trim(c)
gCompName = Left(gCompName, Len(gCompName) - 1)
'读取MAC地址
Dim NetCarts As SWbemObjectSet
Dim NetCart As SWbemObject
Set NetCarts = GetObject("winmgmts:{impersonationLevel=impersonate}") _
.InstancesOf("Win32_NetworkAdapter")
gNetMac = ""
For Each NetCart In NetCarts
If NetCart.MACAddress <> "" And InStr(1, NetCart.Name, "WAN") = 0 Then
gNetMac = gNetMac & NetCart.MACAddress & " "
End If
Next
gNetMac = Trim(gNetMac)
i = GetWindowsDirectory(c, 256)
gWindowsDir = Left(c, i)