RegConnectRegistry 
Author Message
 RegConnectRegistry

Mornin' all...

One of the parameters for the above API function is "lpctstr"....which is
defined as

Pointer to a null-terminated string containing the name of the remote
computer. The string has the following form: \\computername

which is hunkey dunkey...

The API header says (ByVal lpMachineName As String).

Now, do I use :

1) a normal vb string
2) a normal vb string with vbNullChar appended to the end
3) a normal vb string which is then put in a byte array (I've used it before
and it     worked)
4) a normal vb string with vbNullChar appended to the end, which is then put
in     a byte array.
5) StrPtr with (1,2,3 or 4)
6) StrConv(xxxxx, vbFromUnicode) with 1,2,3 or 4 (and possibly 5 :)

When I say "normal", I mean straight "Dim xxx As String".

In the MSDN, the "lpctstr" type is defined as :

    An LPCWSTR if UNICODE is defined, an LPCSTR otherwise.

What does "defined" mean?.....if Unicode is "defined"...you what??. I
thought all vb strings were Unicode....

An LPCSTR is :

    A Pointer to a constant null-terminated string of 8-bit Windows (ANSI)
    characters.

So if vb strings are Unicode, I have to StrConv(xxxx, vbFromUnicode), to
make it ANSI?....

Someone please help me clear up this tangle of confusion....    :(

Thanks.

StephenB.



Mon, 18 Mar 2002 03:00:00 GMT  
 RegConnectRegistry

The answer is 1) a normal vb string. VB converts strings to ANSI when you
call an API.

--
Eduardo A. Morcillo
Create your own shell extensions with VB
Free ActiveX Controls, TypeLibs & Code
http://www.geocities.com/SiliconValley/Foothills/9940



Mon, 18 Mar 2002 03:00:00 GMT  
 RegConnectRegistry
Stephen,

There are two entry points for this function in advapi32.dll

RegConnectRegistryA (
    LPCSTR lpMachineName,
    HKEY hKey,
    PHKEY phkResult
    );
RegConnectRegistryW (
    LPCWSTR lpMachineName,
    HKEY hKey,
    PHKEY phkResult
    );

However as far as I know, VB only really handles the ANSI version, which is
what
is spat out by the API text viewer. (below)

Public Declare Function RegConnectRegistry Lib "advapi32.dll" Alias
"RegConnectRegistryA" (ByVal lpMachineName As String, ByVal hKey As Long,
phkResult As Long) As Long

So in answer to your question, pass a normal string that has a vbNullChar
appended to it, and VB should automatically convert to ANSI for you.  Make
sure you pass the string ByVal.

--
Patrick Escarcega
patrickj AT itis DOT com
Consultant
Maxim Group



Mon, 18 Mar 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help! re:RegConnectRegistry

2. RegConnectRegistry and RegSetValueEx

3. Remote Registry (RegConnectRegistry) Problem

4. Need help with regConnectRegistry......

5. \\computer name format in the API: RegConnectRegistry

6. RegConnectRegistry ???

7. RegConnectRegistry, please help!

8. RegConnectRegistry to Remote Machine

9. RegConnectRegistry

10. RegConnectRegistry

11. RegConnectRegistry fails

12. RegConnectRegistry inside an out-of-process COM server

 

 
Powered by phpBB® Forum Software