Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating/Reading Registry Entries on Remote Machines

Status
Not open for further replies.

MikeLacey

MIS
Nov 9, 1998
13,212
GB
I have an application that maintains NT Registry entries on NT machines - works fine etc.<br>
<br>
Problem is we have quite a few NT machines that need maintaining and I would like to do it all from one machine.<br>
<br>
It is technically possible to get at the registry on another machine (look at perfmon for instance) but I've never seen it done.<br>
<br>
So - how is it done? I can't see a Win32 Api call that looks as if it would do the job - but there has ot be something out there.....<br>
<br>
Mike<br>
<p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Mike,<br>
<br>
I can't help you but maybe you can help me!<br>
<br>
What is the tool that you use for maintaining Win/NT registry? I used RegClean but that works on Win/95 only. Please let me know where I can get the tool you're using.<br>
<br>
Thanks!
 
Hi,<br>
<br>
The tool I'm talking about above is an in-house app written in VB that maintains registry entries for in-house applications.<br>
<br>
Are you having a specific problem that makes you think your registry needs cleaning?<br>
<br>
There is a tool that fixes a specific VB generated reigistry error. This is from Microsoft and is called vbc. I suggest that as this modifies your registry you get a guaranteed version from <A HREF=" TARGET="_new"> just to be safe.<br>
<br>
Regards<br>
<br>
Mike<br>
<p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Hi,<br>
<br>
The tool I'm talking about above is an in-house app written in VB that maintains registry entries for in-house applications.<br>
<br>
Are you having a specific problem that makes you think your registry needs cleaning?<br>
<br>
There is a tool that fixes a specific VB generated reigistry error. This is from Microsoft and is called vbc. I suggest that as this modifies your registry you get a guaranteed version from <A HREF=" TARGET="_new"> just to be safe.<br>
<br>
Regards<br>
<br>
Mike<br>
<p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
I thought I posted this before, but I'll try again.<br>
If you get this to work, I'd like an email on how to use it<br>
<br>
RegistryConnectRegistry <br>
Submitted on: 6/10/97<br>
By: VB Qaid <br>
<br>
<br>
<br>
Connects to either the Handle or Handle key on a remote computer, returning the handle to the opened key. <br>
<br>
<br>
Windows API/Global Declarations:<br>
<br>
<br>
'***************************************************************<br>
'Windows API/Global Declarations for :RegistryConnectRegistry<br>
'***************************************************************<br>
<br>
<br>
Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long<br>
<br>
<br>
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<br>
<br>
<br>
Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long<br>
<br>
<br>
Declare Function RegQueryValueEx Lib "advapi32" 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<br>
<br>
<br>
Declare Function RegSetValueEx Lib "advapi32" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long<br>
<br>
<br>
Declare Function RegFlushKey Lib "advapi32" (ByVal hKey As Long) As Long<br>
<br>
<br>
Declare Function RegConnectRegistry Lib "advapi32.dll" Alias "RegConnectRegistryA" (ByVal lpMachineName As String, ByVal hKey As Long, phkResult As Long) As Long<br>
<br>
<br>
Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long<br>
<br>
<br>
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<br>
<br>
<br>
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<br>
<br>
<br>
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<br>
<br>
<br>
'Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetV<br>
' alueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal <br>
' Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbDa<br>
' ta As Long) As Long<br>
'Security Mask constants<br>
Public Const READ_CONTROL = &H20000<br>
Public Const SYNCHRONIZE = &H100000<br>
Public Const STANDARD_RIGHTS_ALL = &H1F0000<br>
Public Const STANDARD_RIGHTS_READ = READ_CONTROL<br>
Public Const STANDARD_RIGHTS_WRITE = READ_CONTROL<br>
Public Const KEY_QUERY_VALUE = &H1<br>
Public Const KEY_SET_VALUE = &H2<br>
Public Const KEY_CREATE_SUB_KEY = &H4<br>
Public Const KEY_ENUMERATE_SUB_KEYS = &H8<br>
Public Const KEY_NOTIFY = &H10<br>
Public Const KEY_CREATE_LINK = &H20<br>
Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))<br>
Public Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))<br>
Public Const KEY_EXECUTE = ((KEY_READ) And (Not SYNCHRONIZE))<br>
Public Const KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))<br>
'Predefined Registry Keys used in hKey Argument<br>
Public Const HKEY_CLASSES_ROOT = &H80000000<br>
Public Const HKEY_CURRENT_USER = &H80000001<br>
Public Const HKEY_LOCAL_MACHINE = &H80000002<br>
Public Const HKEY_USERS = &H80000003<br>
Public Const HKEY_PERFORMANCE_DATA = &H80000004<br>
' Return codes from Registration functions.<br>
Public Const ERROR_SUCCESS = 0&<br>
Public Const ERROR_BADDB = 1009&<br>
Public Const ERROR_BADKEY = 1010&<br>
Public Const ERROR_CANTOPEN = 1011&<br>
Public Const ERROR_CANTREAD = 1012&<br>
Public Const ERROR_CANTWRITE = 1013&<br>
Public Const ERROR_OUTOFMEMORY = 14&<br>
Public Const ERROR_INVALID_PARAMETER = 87&<br>
Public Const ERROR_ACCESS_DENIED = 5&<br>
'Data type Public Constants<br>
Public Const REG_NONE = 0<br>
Public Const REG_SZ = 1<br>
Public Const REG_EXPAND_SZ = 2<br>
Public Const REG_BINARY = 3<br>
Public Const REG_DWORD = 4<br>
Public Const REG_DWORD_LITTLE_ENDIAN = 4<br>
Public Const REG_DWORD_BIG_ENDIAN = 5<br>
Public Const REG_LINK = 6<br>
Public Const REG_MULTI_SZ = 7<br>
Public Const REG_RESOURCE_LIST = 8<br>
Public Const REG_FULL_RESOURCE_DESCRIPTOR = 9<br>
Public Const REG_RESOURCE_REQUIREMENTS_LIST = 10<br>
'Options<br>
Public Const REG_OPTION_NON_VOLATILE = 0&<br>
Public Const REG_OPTION_VOLATILE = &H1<br>
<br>
<br>
Type SECURITY_ATTRIBUTES<br>
nLength As Long<br>
lpSecurityDescriptor As Variant<br>
bInheritHandle As Long<br>
End Type<br>
<br>
<br>
Public Sub gAPIDisplayError(Code&)<br>
<br>
<br>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
''''''''''''''''''''''<br>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
''''''''''''''''''''''<br>
''' '''<br>
''' The subroutine gAPIDisplayError processes Code&. Code& is ret<br>
' urned by a '''<br>
''' function calling one of the Win32 API Registry functions, and<br>
' describes '''<br>
''' the end result of the function call. The value returned by Wi<br>
' n32 API'''<br>
''' Registry functions are constants defined in Registry32.declar<br>
' ations. If the '''<br>
''' function call was executed sucessfully, it will return ERROR_<br>
' SUCCESS, which '''<br>
''' requires no follow up action. If the function call was execut<br>
' ed '''<br>
''' unsuccessfully, it will return one of the below values. The o<br>
' nly follow up '''<br>
''' action performed by this subroutine is to issue an error mess<br>
' age to the '''<br>
''' screen, halting execution until the OK button is pressed.'''<br>
''' '''<br>
''' The passed parameters are: '''<br>
''' Code& - returned by a function calling one of the Win32 API R<br>
' egistry'''<br>
''' functions, describing the end result of the function call. ''<br>
'<br>
''' '''<br>
''' The function performs the following tasks in corresponding or<br>
' der:'''<br>
''' 1) Perform a Select routine on Code&, and issue the respectiv<br>
' e error'''<br>
''' message to the screen. '''<br>
''' '''<br>
''' Since this module uses the Win32 API, it is only functional o<br>
' n Win95 and WinNT '''<br>
''' systems.'''<br>
''' '''<br>
''' '''<br>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
''''''''''''''''''''''<br>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
''''''''''''''''''''''<br>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
''''''''''''''<br>
'' Perform a Select routine on Code&, and issue the respective er<br>
' ror message ''<br>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
''''''''''''''<br>
<br>
<br>
Select Case Code&<br>
Case ERROR_SUCCESS<br>
'Don't return an error message<br>
Case ERROR_BADDB<br>
MsgBox "Corrupt Registry Database!"<br>
Case ERROR_BADKEY<br>
MsgBox "Key name is bad"<br>
Case ERROR_CANTOPEN<br>
MsgBox "Cannot Open Key"<br>
Case ERROR_CANTREAD<br>
MsgBox "Cannot Read Key"<br>
Case ERROR_CANTWRITE<br>
MsgBox "Cannot Write Key"<br>
Case ERROR_ACCESS_DENIED<br>
MsgBox "Access to Registry Denied"<br>
Case ERROR_OUTOFMEMORY<br>
MsgBox "Out of memory"<br>
Case ERROR_INVALID_PARAMETER<br>
MsgBox "Invalid Parameter"<br>
Case Else<br>
MsgBox "Undefined key Error code!"<br>
End Select<br>
<br>
End Sub<br>
<br>
<br>
<br>
Public Function BinaryInStringToHexInString(ConvertThis$) As String<br>
<br>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
''''''''''''''''''''''<br>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
''''''''''''''''''''''<br>
''' '''<br>
''' The function BinaryInStringToHexInString converts unreadable <br>
' binary data in a'''<br>
''' string variable, and returns readable hexadecimal format. Not<br>
' e that the '''<br>
''' returned string isn't headed with the standard &H notation. '<br>
''<br>
''' '''<br>
''' The passed parameters are: '''<br>
''' ConvertThis$ - the string of unreadable binary data to be con<br>
' verted to '''<br>
''' hexedecimal format. '''<br>
''' '''<br>
''' The function performs the following tasks in corresponding or<br>
' der:'''<br>
''' 1) Initiate a For loop that iterates once for each character <br>
' in the string. '''<br>
''' A character is a byte of binary data represented by two hexad<br>
' ecimal '''<br>
''' digits. '''<br>
''' 2) Translate the loop counter's character/byte into hexadecim<br>
' al.'''<br>
''' 3) If the hexadecimal translation is one character long, add <br>
' a "0" leader. '''<br>
''' 4) Append the two hexadecimal characters to the buffer. '''<br>
''' 5) Return the completed buffer to the calling procedure.'''<br>
''' '''<br>
''' '''<br>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
''''''''''''''''''''''<br>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
''''''''''''''''''''''<br>
Dim i% 'Loop counter<br>
Dim Buffer$ 'Storage String For the hexadecimal translation<br>
Dim HexPacket$ 'The two character hexadecimal translation For the Byte of binary data<br>
'''''''''''''''''''''''''<br>
'' Initiate a For loop ''<br>
'''''''''''''''''''''''''<br>
<br>
<br>
For i = 1 To Len(ConvertThis$) Step 1<br>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
'<br>
'' Translate the loop counter's character/byte into hexadecimal '<br>
'<br>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
'<br>
HexPacket$ = Hex$(Asc(Mid$(ConvertThis$, i, 1)))<br>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
'''''''''''<br>
'' If the hexadecimal translation is one character long, add a "0<br>
' " leader ''<br>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
'''''''''''<br>
<br>
<br>
If Len(HexPacket$) = 1 Then<br>
HexPacket$ = "0" & HexPacket$<br>
End If<br>
<br>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
'' Append the two hexadecimal characters to the buffer ''<br>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
Buffer$ = Buffer$ + HexPacket$<br>
Next i<br>
<br>
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
'' Return the completed buffer to the calling procedure ''<br>
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br>
BinaryInStringToHexInString = Buffer$<br>
End Function<br>
<br>
<br>
<br>
'***************************************************************<br>
' Name: RegistryConnectRegistry<br>
' Description:Connects to either the Handle or Handle key on a re<br>
' mote computer, returning the handle to the opened key.<br>
' By: VB Qaid<br>
'<br>
'<br>
' Inputs:The passed parameters are: <br>
ConnectToThisComputer$ - the name of the computer to connect to. <br>
AlreadyOpenedKey& - the remote root key to connect to. It can be either the <br>
Handle or Handle key (constant).<br>
<br>
The Function declaration For RegConnectRegistry was taken from the (Jan96) MSDN <br>
and from WIN32API.TXT. It is declared in Registry32.declarations.<br>
The parameters used With RegConnectRegistry are defined in the (Jan96) MSDN in <br>
\Product Documentation\SDKs\Win32 SDK\Win32 Programmer's Reference\ <br>
\Reference\Functions\ReadEventLog to RemoveMenu\RegConnectRegistry. <br>
ConnectToThisComputer$ - the name of the computer to connect to. <br>
AlreadyOpenedKey& - the remote root key to connect to. It can be either the <br>
Handle or Handle key (constant).<br>
ConnectedRegistryKey& - placeholder For the handle (long number) obtained<br>
by RegConnectRegistry. <br>
lReturn - a constant returned describing the success/failure of the <br>
<br>
<br>
function. The constants are defined in Registry32.declarations and <br>
<br>
<br>
processed by Registry32.gAPIDisplayError.<br>
'<br>
' Returns:None<br>
'<br>
'Assumes:The function performs the following tasks in correspondi<br>
' ng order:<br>
1) Open the key AlreadyOpenedKey& On the computer ConnectToThisComputer$,<br>
and store the handle in ConnectedRegistryKey&. <br>
2) Process lReturn. For details, see the documentation for <br>
Registry32.gAPIDisplayError.<br>
3) Return the handle to the newly opened key to the calling procedure. <br>
<br>
Since this module uses the Win32 API, it is only functional on Win95 and WinNT <br>
systems.<br>
<br>
<br>
<br>
'***************************************************************<br>
<br>
<br>
<br>
Public Function RegistryConnectRegistry(ConnectToThisComputer$, AlreadyOpenedKey&) As Long<br>
<br>
Dim ConnectedRegistryKey&'The handle to the key opened by RegConnectRegistry<br>
Dim lReturn As Long 'the Error value returned by the registry Function<br>
''<br>
'' Open the key AlreadyOpenedKey& on the computer ConnectToThisCo<br>
' mputer$, and store ''<br>
'' the handle in ConnectedRegistryKey& ''<br>
''<br>
lReturn = RegConnectRegistry(ConnectToThisComputer$, AlreadyOpenedKey&, ConnectedRegistryKey&)<br>
'' Process lReturn ''<br>
Call Registry32.gAPIDisplayError(lReturn)<br>
'' Return the handle to the newly opened key to the calling proce<br>
' dure ''<br>
RegistryConnectRegistry = ConnectedRegistryKey&<br>
End Function<br>
<br>
<br>
<br>

 
Cas21 - thanks - that looks very promising.<br>
<br>
I'll try it out - the RegConnectRegistry call seems to be the one I'm after.<br>
<br>
Hairy stuff this &lt;grin&gt; I'll let you know.<br>
<br>
-ml <p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top