Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows API
  4. Problem about RegConnectRegistry [modified]

Problem about RegConnectRegistry [modified]

Scheduled Pinned Locked Moved Windows API
helpcsharpwindows-adminjson
8 Posts 2 Posters 20 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    Xie Jinghui
    wrote on last edited by
    #1

    I want to Establish a connection to a registry key on another computer, use windos API RegConnectRegistry; The program running on windows 2003 ,connect to remote windows xp, over ipv4, work well; The program running on Win7, connect to remote Windows XP, over ipv4, Failed. The program running on Win7, connect to remote Win7, over ipv6, Failed. before calling RegConnectRegistry, the WNetAddConnection2 succeeded; the Remote Registry service is running on the remote computer. the RegConnectRegistry Failed. the return value is 87(ERROR_INVALID_PARAMETERS); I don't know if RegConnectRegistry could work over ipv6, WNetAddConnection2 can. so I pass the parameter lpMachineName the IPv6 literal format string "\\\\2001-4898-9-3-c069-aa97-fe76-2449.ipv6-literal.net" just let it work, thanks for any idea.

    modified on Monday, March 28, 2011 10:42 AM

    L 1 Reply Last reply
    0
    • X Xie Jinghui

      I want to Establish a connection to a registry key on another computer, use windos API RegConnectRegistry; The program running on windows 2003 ,connect to remote windows xp, over ipv4, work well; The program running on Win7, connect to remote Windows XP, over ipv4, Failed. The program running on Win7, connect to remote Win7, over ipv6, Failed. before calling RegConnectRegistry, the WNetAddConnection2 succeeded; the Remote Registry service is running on the remote computer. the RegConnectRegistry Failed. the return value is 87(ERROR_INVALID_PARAMETERS); I don't know if RegConnectRegistry could work over ipv6, WNetAddConnection2 can. so I pass the parameter lpMachineName the IPv6 literal format string "\\\\2001-4898-9-3-c069-aa97-fe76-2449.ipv6-literal.net" just let it work, thanks for any idea.

      modified on Monday, March 28, 2011 10:42 AM

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I think you may need to use a different format for your machine name as described here[^]. [edit]Your name literal should be in the format "\\\\machinename"; note the four backslashes in the literal to ensure the generated constant has two backslashes at the beginning.[/edit]

      d@nish[^] has the answer.

      X 1 Reply Last reply
      0
      • L Lost User

        I think you may need to use a different format for your machine name as described here[^]. [edit]Your name literal should be in the format "\\\\machinename"; note the four backslashes in the literal to ensure the generated constant has two backslashes at the beginning.[/edit]

        d@nish[^] has the answer.

        X Offline
        X Offline
        Xie Jinghui
        wrote on last edited by
        #3

        thank you. ;P in fact , the literal has two backslashes at the beginning.

        L 1 Reply Last reply
        0
        • X Xie Jinghui

          thank you. ;P in fact , the literal has two backslashes at the beginning.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Xie Jinghui wrote:

          in fact , the literal has two backslashes at the beginning.

          Your original message has this: so I pass the parameter lpMachineName the IPv6 literal format string "\2001-4898-9-3-c069-aa97-fe76-2449.ipv6-literal.net", which means the generated litersl has no backslashes in it, and the address starts with some strange character ('\2' == 0x02).

          d@nish[^] has the answer.

          X 1 Reply Last reply
          0
          • L Lost User

            Xie Jinghui wrote:

            in fact , the literal has two backslashes at the beginning.

            Your original message has this: so I pass the parameter lpMachineName the IPv6 literal format string "\2001-4898-9-3-c069-aa97-fe76-2449.ipv6-literal.net", which means the generated litersl has no backslashes in it, and the address starts with some strange character ('\2' == 0x02).

            d@nish[^] has the answer.

            X Offline
            X Offline
            Xie Jinghui
            wrote on last edited by
            #5

            Sorry, i just copy the string from text not from code, i correct the message; I had try again. and I beleive the problem is not the string. thanks for your recommendation.

            L 1 Reply Last reply
            0
            • X Xie Jinghui

              Sorry, i just copy the string from text not from code, i correct the message; I had try again. and I beleive the problem is not the string. thanks for your recommendation.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Can you connect normally to this computer using the address in your question?

              d@nish[^] has the answer.

              X 1 Reply Last reply
              0
              • L Lost User

                Can you connect normally to this computer using the address in your question?

                d@nish[^] has the answer.

                X Offline
                X Offline
                Xie Jinghui
                wrote on last edited by
                #7

                NETRESOURCE nr;
                memset(&nr, 0, sizeof(NETRESOURCE));

                nr.dwScope	= RESOURCE\_GLOBALNET;
                nr.dwType	= RESOURCETYPE\_DISK;
                nr.dwDisplayType = RESOURCEDISPLAYTYPE\_SHARE;
                nr.dwUsage	= RESOURCEUSAGE\_CONNECTABLE;
                nr.lpLocalName = "";
                nr.lpRemoteName = szAdminSharePath;	//value is "\\\\\\\\1-f-0-0-0-0-0-1.ipv6-literal.net" 
                					//the IPv6 Address of remote computer is 1:f::1
                nr.lpProvider = NULL;
                
                DWORD dwResult;
                dwResult = WNetAddConnection2(&nr,
                	(LPSTR)(LPCTSTR)m\_strPassword,
                	(LPSTR)(LPCTSTR)m\_strUser,
                	CONNECT\_UPDATE\_PROFILE);	
                

                WNetAddConnection2 succeeded, the return value is NO_ERROR. then, try to connect to remote registry.

                HKEY hkRemoteComputer;
                lResult = ::RegConnectRegistry( 
                		strRmt, 		//value is "\\\\\\\\1-f-0-0-0-0-0-1.ipv6-literal.net"
                		HKEY\_LOCAL\_MACHINE, 	
                		&hkRemoteComputer ) ;
                

                RegConnectRegistry failed. return value is 87

                L 1 Reply Last reply
                0
                • X Xie Jinghui

                  NETRESOURCE nr;
                  memset(&nr, 0, sizeof(NETRESOURCE));

                  nr.dwScope	= RESOURCE\_GLOBALNET;
                  nr.dwType	= RESOURCETYPE\_DISK;
                  nr.dwDisplayType = RESOURCEDISPLAYTYPE\_SHARE;
                  nr.dwUsage	= RESOURCEUSAGE\_CONNECTABLE;
                  nr.lpLocalName = "";
                  nr.lpRemoteName = szAdminSharePath;	//value is "\\\\\\\\1-f-0-0-0-0-0-1.ipv6-literal.net" 
                  					//the IPv6 Address of remote computer is 1:f::1
                  nr.lpProvider = NULL;
                  
                  DWORD dwResult;
                  dwResult = WNetAddConnection2(&nr,
                  	(LPSTR)(LPCTSTR)m\_strPassword,
                  	(LPSTR)(LPCTSTR)m\_strUser,
                  	CONNECT\_UPDATE\_PROFILE);	
                  

                  WNetAddConnection2 succeeded, the return value is NO_ERROR. then, try to connect to remote registry.

                  HKEY hkRemoteComputer;
                  lResult = ::RegConnectRegistry( 
                  		strRmt, 		//value is "\\\\\\\\1-f-0-0-0-0-0-1.ipv6-literal.net"
                  		HKEY\_LOCAL\_MACHINE, 	
                  		&hkRemoteComputer ) ;
                  

                  RegConnectRegistry failed. return value is 87

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Error code 87 is ERROR_INVALID_PARAMETER 87 (0x57) : The parameter is incorrect. which suggests that your computer name is not valid for this function.

                  d@nish[^] has the answer.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups