Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RegEnumValue from WinApi32 function call
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00562037
Message ID:
00562542
Views:
17
>>>>>>>>>>
>>>>>>>>>>It's hard to make other suggestions without seeing what the actual parameters are. Could you post them?
>>>>>>>>>
>>>>>>>>> hKey = 0
>>>>>>>>> retval = RegOpenKey(HKEY_CLASSES_ROOT, "Minitab.mpj\shell\open\command", @hKey)
>>>>>>>>> valuename = Space(255)
>>>>>>>>> valuelen = 255
>>>>>>>>> STORE 0 TO lpdwReserved,dataType, xindex
>>>>>>>>> Store Space(255) to indata
>>>>>>>>> datalen = Len(indata)
>>>>>>>>
>>>>>>>>Is the value returned by RegOpenKey equal to zero (ERROR_SUCCESS)? If not, the key may not exist.
>>>>>>>
>>>>>>>Sorry hit reply before i oculd finish my changes but
>>>>>>>
>>>>>>>Value returned is 0 and hkey changes to different numbers per run. It does find the key
>>>>>>>
>>>>>>>HKEY_CLASSES_ROOT = -2147483648
>>>>>>
>>>>>>OH yeah, AND this program DOES work in win 95,98!!!!!!!
>>>>>
>>>>>Sounds like a problem with registry access caused by WinNT/2K security settings. I generally use the registry class in the FFC. I'm about to leave and won't have access to Win2K again until Monday. If no one else checks for you, I will then.
>>>>
>>>>I'm leaving myself so I may see ya then!!!
>>>
>>>Found it! In my tests I made the same mistake you did. The declaration should be
DECLARE INTEGER RegEnumValue IN Win32API;
>>>  INTEGER hKey, INTEGER dwIndex,;
>>>  STRING @lpValueName, INTEGER @lpcValueName,;
>>>  INTEGER <b>lpReserved</b>, INTEGER @lpType,;
>>>  STRING @lpData, INTEGER @lpcbData
Both of us passed the lpReserved parameter by reference rather than value. Change the declaration and it should work fine.

I think i found the problem but it's in another part of the program. I beleive that part is solved!!! thanks again
>>
>>
>>I only wish it was that nice, but i keep getting SYNTAX ERROR from the Darn thing. I evan copied and pasted into prog but still doesn't work. I'm using foxpro 5.0 will that make a difference?
>
>It shouldn't. I tested the code below in both 6.0 and 7.0 (don't have 5.0 any longer). Try changing the lckey value after copying and pasting it into a prg file.
#DEFINE HKEY_CLASSES_ROOT           -2147483648  && BITSET(0,31)
>DECLARE INTEGER RegOpenKey IN Win32API;
>  INTEGER hKey, STRING @lpSubKey,;
>  INTEGER @phkResult
>DECLARE INTEGER RegEnumValue IN Win32API;
>  INTEGER hKey, INTEGER dwIndex,;
>  STRING @lpValueName, INTEGER @lpcValueName,;
>  INTEGER lpReserved, INTEGER @lpType,;
>  STRING @lpData, INTEGER @lpcbData
>DECLARE INTEGER RegCloseKey IN Win32API;
>  INTEGER hKey
>lckey = 'oasis.oasis\CLSID' && Change this to your key.
>lnkey = 0
>IF RegOpenKey(HKEY_CLASSES_ROOT, @lckey, @lnkey) = 0
>  STORE SPACE(256) TO lcbuffer, lcdata
>  STORE LEN(lcbuffer) TO lnsize, lndatasize
>  lntype = 0
>  lnindex = 0
>  lnreserved = 0
>  ? RegEnumValue(lnkey, lnindex, @lcdata, @lndatasize, lnreserved, @lntype, @lcbuffer, @lnsize) && Should return zero.
>  ? lcdata
>  ? lcbuffer
>  = RegCloseKey(lnkey)
>ENDIF
Let me know if this works.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform