Solved

RegConnectRegistry failure

Posted on 1998-12-02
2
738 Views
Last Modified: 2013-11-20
I'm trying to change a registry key in a remote machine's HKEY_LOCAL_MACHINE branch using RegConnectRegistry(). Everything's set up okay - both machines are NT4 servers (SP3) and Administrator account is set up so that it has full control over both machine A and machine B and full access to both registries.

Here's my code:

LPTSTR lpMachineName;      // address of name of remote computer
      lpMachineName = "\\SEURD01WEB002";

      HKEY hKey; // predefined registry handle
      hKey = HKEY_LOCAL_MACHINE;

      PHKEY phkResult; // address of buffer for remote registry handle
      
      LONG diditwork;
      diditwork = 0;
      
      diditwork = RegConnectRegistry(
                              lpMachineName,
                              hKey,
                              phkResult
                                          );                                          

      if (diditwork != ERROR_SUCCESS)
      
            MessageBox ("Remote connection failed");


Can you guys see anything wrong with this code ? I've performed the connection manually using regedt32 and connecting to the machine name and the branch - it works fine...

...so please, save me from going crazy and tell me what I'm doing wrong ! Thanks a lot,

Derek
0
Comment
Question by:der_bell
2 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 170 total points
ID: 1325616
You aren't providing a place for the resultant HKEY to be stored, so you're passing the function an invalid pointer.
Try is this way:

LPTSTR lpMachineName; // address of name of remote computer
lpMachineName = "\\SEURD01WEB002";

HKEY hKey; // predefined registry handle
hKey = HKEY_LOCAL_MACHINE;

HKEY hkResult; // buffer for remote registry handle

LONG diditwork;
diditwork = 0;

diditwork = RegConnectRegistry(
lpMachineName,
hKey,
&hkResult
);
0
 

Author Comment

by:der_bell
ID: 1325617

Thanks a lot - it works fine when I make the amendment you suggest. I'm an idiot - I was looking in the wrong place for the error !

Derek
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
notReplace  challenge 53 128
dog bark java program 15 95
Sed question 2 85
Not needed 13 112
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question