>George,
>
>I finally got it working. It seems I had the "@" token in the declare in places
>it shouldn't have been:
>
>
> DECLARE INTEGER RegCreateKeyEx IN Win32API;
> INTEGER @iBaseKey,;
> STRING @sSubKey,;
> INTEGER @iReserved,;
> STRING @iClass,;
> INTEGER @iOptions,;
> INTEGER @iAccess,;
> INTEGER @iSecurity,;
> INTEGER @iHandle,;
> INTEGER @iDisposition
>
>
>instead of
>
> DECLARE INTEGER RegCreateKeyEx IN Win32API;
> INTEGER iBaseKey,;
> STRING @sSubKey,;
> INTEGER iReserved,;
> STRING iClass,;
> INTEGER iOptions,;
> INTEGER iAccess,;
> INTEGER iSecurity,;
> INTEGER @iHandle,;
> INTEGER @iDisposition
>
>
>After that change, I tried:
>
>
>iBaseKey = HKEY_LOCAL_MACHINE
>sSubKey = REG_TEST_KEY
>iHandle = 0
>iDisposition = 0
>
>? RegCreateKeyEx(iBaseKey, @sSubKey, 0, 0, 0, 0, 0, @iHandle, @iDisposition)
>
>
>and all works fine now. So that leads me to my next question. Does the "@" token
>in the DECLARE mean the value is expected to be passed by reference? And how do
>I know when to pass a value by reference to an API call? And finally, Is there
>some compelling reason to use the RegCreateKeyEx over RegCreateKey?
>
>Thanks for all your experct help!
First, you're welcome.
Second, yes, the "@" symbol indicates that the value is passed by reference.
The key to making this determination is in either checking the C declaration or the parameter description as found in the Platform SDK.
In the former case, any parameter that begins with either "lp" (Long pointer) or "p" (pointer) should be passed by reference.
In the latter, the parameter description, will say something like "...a pointer to...". Again, this tells you to pass the parameter by reference.
There is one exception, however. In a case where a null pointer is optional, regardless of the type being passed (string, integer, etc.) you can simply pass a zero by value. This indicates to the function that a null is being passed.
RegCreateKey is provided for backward compatibility with Win16. So, under Win32, it's more appropriate to call RegCreateKeyEx. However, if you examine the code in the registry class that ships with VFP, you'll note that it calls RegCreateKey instead.
Hope this answers your questions.
George
Ubi caritas et amor, deus ibi est