Problem about RegConnectRegistry [modified]
-
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
-
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
-
thank you. ;P in fact , the literal has two backslashes at the beginning.
-
thank you. ;P in fact , the literal has two backslashes at the beginning.
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).
-
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).
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.
-
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.
-
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
-
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