用vbscript写的代码怎么才能在vb里使用?(关于WMI)
const HKEY_LOCAL_MACHINE = &H80000001
strComputer = ". "
Set StdOut = WScript.StdOut
Set oReg=GetObject( "winmgmts:{impersonationLevel=impersonate}!\\ " &_
strComputer & "\root\default:StdRegProv ")
strKeyPath = "SOFTWARE\Husen2K\config "
strValueName = "text "
strValue = "text1 "
oReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
这是代码,怎么才能在vb里用呢
[解决办法]
Dim oReg As SWbemObject
Dim strKeyPath As String, strValueName As String, strValue As String
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = ". "
'Set StdOut = WScript.StdOut
Set oReg = GetObject( "winmgmts:{impersonationLevel=impersonate}!\\ " & strComputer & "\root\default:StdRegProv ")
strKeyPath = "SOFTWARE\ "
strValueName = "123456 "
strValue = "123456 "
oReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue