I am making a dll that is a plugin to coldfusion application server (cfx) - it is supposed to permit access to windows registry on a remote computer, and most of it works just fine. All if, actually, except for the remote computer part!
According to the documentation:
I just need to pass a LPCTSTR containing the address of the remote server, and it should return a registry handle to the requested collection.
Here are the relevant code snippets:
LPCSTR lpszServer = pRequest->GetAttribute("SE
GetAttribute() is provided by the application server framework and just returns a pointer to a char string or null if the attribute was not defined in the user script.
I write it back to the user, so that I can be sure that my code is getting the right data:
key \"%s\\%s\" to server %s", lpszBranch, lpszEntry, lpszServer);
pRequest->Write( ResultText ) ;
(lpzBranch and lpszEntry are just strings I have collected in the same way as lpszServer)
So far, I can confirm that the dll is receiving a server name in the correct forma, displaying it back to the user script as something like "\\server.domain.com"
then later I use the server name to call RegConnect:
lpszServer, // LPTSTR lpMachineName, // address of name of remote computer
RootKey, // HKEY hKey, // predefined registry handle
&RegKey // PHKEY phkResult // address of buffer for remote registry handle
) == ERROR_SUCCESS)
// do stuff
// throw error
The problem is that when I pass the data I got from that GetAttribute function, the function returns zero (success) and executes 'do stuff' which is to write a string value to the registry of the local system - even though I know that the server name field is populated.
The annoying thing is that the behaviour is exactly like what I would expect if the value of lpszServer = null, that is it just opens the localhost registry and 'does work' on that! I don't think that this problem is permissions or access related, because if that was the case then RegConnectRegistry should return != ERROR_SUCCESS and so execute "throw error" code instead of "do stuff" code.
I suspect that this may have something to do with trying to pass an LPCSTR into a field that expects LPCTSTR, but exactly what the deal is, or how I should do the right conversion has eluded me thus far....
Any suggestions, tips, comments... even solutions(!)... will be most appreciated!
Thanks and regards, Mike.