According to Microsoft, WMI is the only way to do it....well rather than an API call
http://www.microsoft.com/r
Main Topics
Browse All TopicsHi,
I'm using the VBS Regread function to retrieve a registry value. All is fine except that it does not return the valuedata type (REG_SZ or REG_EXPAND_SZ or REG_BINARY etc). Does VBS have a function to retrieve that info, or do I need to use API. Thanks...
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
According to Microsoft, WMI is the only way to do it....well rather than an API call
http://www.microsoft.com/r
I use this, check with QueryValueEx function, it will return the type
You have to slightly modify for your purpose, this just give you an idea
Option Explicit
''''''''''''''''''''''''''
' Registry constants
Public Const STANDARD_RIGHTS_ALL = &H1F0000
Public Const SYNCHRONIZE = &H100000
Public Const KEY_QUERY_VALUE = &H1
Public Const KEY_SET_VALUE = &H2
Public Const KEY_CREATE_SUB_KEY = &H4
Public Const KEY_ENUMERATE_SUB_KEYS = &H8
Public Const KEY_NOTIFY = &H10
Public Const KEY_CREATE_LINK = &H20
Public Const REG_EXPAND_SZ = 2
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_CONFIG = &H80000005
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_DYN_DATA = &H80000006
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_PERFORMANCE_DATA = &H80000004
Public Const HKEY_USERS = &H80000003
Public Const REG_SZ = 1
Public Const REG_DWORD = 4
Public Const ERROR_SUCCESS = 0&
Public Const ERROR_NONE = 0
Public Const ERROR_BADDB = 1
Public Const ERROR_BADKEY = 2
Public Const ERROR_CANTOPEN = 3
Public Const ERROR_CANTREAD = 4
Public Const ERROR_CANTWRITE = 5
Public Const ERROR_OUTOFMEMORY = 6
Public Const ERROR_INVALID_PARAMETER = 7
Public Const ERROR_ACCESS_DENIED = 8
Public Const ERROR_INVALID_PARAMETERS = 87
Public Const ERROR_NO_MORE_ITEMS = 259
Public Const REG_CREATED_NEW_KEY = &H1
Public Const REG_OPENED_EXISTING_KEY = &H2
Public Const KEY_ALL_ACCESS = &H3F
Public Const REG_OPTION_NON_VOLATILE = 0
Public Const KEY_VAL = "SOFTWARE\keycode"
Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Boolean
End Type
''''''''''''''''''''''''''
' Functions Declaration
Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public Declare Function RegCreateKeyEx Lib "advapi32.dll" 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
Public 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
Public 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
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As Long, lpcbData As Long) As Long
Public Declare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Public Declare Function RegQueryValueExLong Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Long, lpcbData As Long) As Long
Public Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long
Public 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
Public Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
''''''''''''''''''''''''''
' Get registry setting
Public Function RegistryGetSetting(ByVal StringVal As String) As String
Dim LReturn As Long
Dim HWndSoftware As Long
Dim Value
Dim DefaultVal
On Error Resume Next
DefaultVal = ""
LReturn = RegOpenKeyEx(HKEY_LOCAL_MA
If LReturn <> ERROR_SUCCESS Then
RegistryGetSetting = DefaultVal
Else
LReturn = QueryValueEx(HWndSoftware,
RegistryGetSetting = IIf(LReturn = ERROR_SUCCESS, Value, DefaultVal)
End If
RegCloseKey (HWndSoftware)
End Function
''''''''''''''''''''''''''
' Class private function
Private Function QueryValueEx(ByVal lhKey As Long, ByVal szValueName As String, vValue As Variant) As Long
Dim cch As Long
Dim Lrc As Long
Dim LType As Long
Dim LValue As Long
Dim SValue As String
On Error GoTo QueryValueExError
Lrc = RegQueryValueExNULL(lhKey,
If Lrc <> ERROR_NONE Then Error 5
Lrc = -1
Select Case LType
Case REG_SZ:
SValue = String(cch, 0)
Lrc = RegQueryValueExString(lhKe
vValue = IIf(Lrc = ERROR_NONE, Left$(SValue, cch), Empty)
If Asc(Right(vValue, 1)) = 0 Then vValue = Mid(vValue, 1, Len(vValue) - 1)
Case REG_DWORD:
Lrc = RegQueryValueExLong(lhKey,
If Lrc = ERROR_NONE Then vValue = LValue
End Select
QueryValueExExit:
QueryValueEx = Lrc
Exit Function
QueryValueExError:
Resume QueryValueExExit
End Function
Business Accounts
Answer for Membership
by: g0rathPosted on 2004-12-15 at 10:31:26ID: 12833039
An example that uses WMI m/activmon itor/windo wsmanageme nt/ adminsc ripts/regi stry/#Enum RegVals.ht m
http://www.activexperts.co