Writing to registry in Win 2000

jeffcoop_69

New Member
Hi-de-ho good neighbor:
I have a procedure that writes writes data to the registry. The procedure works great on Win 95 and 98 but on Win 2000 it returns an error code 5 - which translates to Access Denied; but I can go into the registry using regedit and edit the same key I'm trying to write to. Has anyone experienced this problem? I don't think it's anything with the user rights on the machine because I have administrator rights which should allow me access. I'm using the following function to write to the registry:

PROCEDURE RegSetValueExA EXTERNAL "advapi32" :
DEFINE INPUT PARAMETER hkey AS LONG.
DEFINE INPUT PARAMETER lpValueName AS CHARACTER.
DEFINE INPUT PARAMETER lpdwReserved AS LONG.
DEFINE INPUT PARAMETER lpdwType AS LONG.
DEFINE INPUT PARAMETER lpbData AS LONG.
DEFINE INPUT PARAMETER lpcbData AS LONG.
DEFINE RETURN PARAMETER lpresult AS LONG.
/****
Declare Function RegSetValueEx Lib "advapi32" Alias "RegSetValueExA" _
(ByVal hKey As Long, _
ByVal lpszValueName As String, _
ByVal dwReserved As Long, _
ByVal fdwType As Long, _
lpbData As Any, _
ByVal cbData As Long) _
As Long

LONG RegSetValueEx(
HKEY hKey, // handle to key
LPCTSTR lpValueName, // value name
DWORD Reserved, // reserved
DWORD dwType, // value type
CONST BYTE *lpData, // value data
DWORD cbData // size of value data
);
****/
END PROCEDURE.

TIA!
 
Actually there are some 4GL statements you can use to read/write the registry :

read :

LOAD "Software" BASE-KEY "HKEY_CURRENT_USER".
USE "Software".
GET-KEY-VALUE SECTION "TVH-Applicatie" KEY "LastLogin" VALUE charUser.
UNLOAD "Software".
IF charUser = ? THEN ASSIGN charUser = "".

write:

LOAD "Software" BASE-KEY "HKEY_CURRENT_USER".
USE "Software".
PUT-KEY-VALUE SECTION "TVH-Applicatie" KEY "LastLogin" VALUE charUser.
PUT-KEY-VALUE SECTION "TVH-Applicatie" KEY "HomeDir" VALUE charHomeDir.
UNLOAD "Software".


Hope this works :rolleyes:
 

jeffcoop_69

New Member
Thanks, but I know how to do it with the 4GL commands but I was wondering why this DLL function no longer works? If this one doesn't work, then I wonder what other ones may or may not behave the same way - or maybe I was just doing something wrong.
 
I never used that particular dll, but for other functionality, I never had any problems since I use win2000 (about a year now).

My opinion is on the other hand that it isn't necessary to use a dll when there is a similar 4GL statement, unless you would gain a lot of speed...
 

jeffcoop_69

New Member
In this case there is no speed gain and the 4GL would be the best way to go, but I have a library that contains external procedures that do various things that progress didn't contain and this was just one of the functions that we used (don't remember the particular reason this function was used instead of the 4GL). I agree with you about using the 4GL if it allows it and there is no gain/loss in performance.
 
Top