Dim hKey As Long, strValue As String
Dim lresult As Long, lType As Long, lBufferSize As Long, strBuff As String
Dim sType As String, sValue As Variant, lData As Long
Dim i As Integer
lMainKey = GetMainKey("HKEY_LOCAL_MACHINE")
RegOpenKey lMainKey, "HARDWARE\DEVICEMAP\SERIALCOMM", hKey
strValue = "\Device\Spccom1"
lresult = RegQueryValueEx(hKey, strValue, 0, lType, ByVal 0, lBufferSize)
If lresult = 0 Then
If lType = REG_SZ Then
'Create a buffer
strBuff = String(lBufferSize, Chr$(0))
'retrieve the key's content
lresult = RegQueryValueEx(hKey, strValue, 0, REG_SZ, ByVal strBuff, lBufferSize)
If lresult = 0 Then
'Remove the unnecessary chr$(0)'s
sValue = Left$(strBuff, InStr(1, strBuff, Chr$(0)) - 1)
End If
end if作者: andymark 时间: 2009-3-3 13:44
谢谢分享~~作者: rcylbx 时间: 2009-3-3 14:53
先学习了作者: chaojianan 时间: 2009-3-3 16:01
收藏了备用。
谢谢分享。作者: 没牙兔兔 时间: 2009-3-3 22:31