Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community

At 01 MAY 2002 11:28:14PM S Botes wrote:

I have been trying to read keys from the registry. I am using OI32. I have setup a test program using RegCloseKey, RegQueryValueEx and RegOpenKeyEx

I have created records in sysprocs called DLL_DSL_USER32 AND DLL_DSL_KERNEL32

USER32 or KERNEL32 depending on which one of the above

LONG STDCALL RegQueryValueExA(HANDLE,LPCHAR,LPCHAR,LPCHAR,LPCHAR,LPCHAR,LPCHAR) AS REGQUERYVALUEEX

LONG STDCALL RegOpenKeyExA(HANDLE,LPCHAR,ULONG,LPCHAR,LPCHAR) AS REGOPENKEYEX

I then ran DECLARE_FCNS "DLL_DSL_USER32" …etc.

OI can't find RegOpenKeyExA etc. I have tried with and without the AS"functionname" in the definitions. I have tried the vb script that Bob wrote and can't get that to work. I have looked through the discussion databases and found Don's discussion with Gene and Cam. I didn't want to use the 16bit steps.

Can someone help me with:

1. How to define the datatypes, i.e. HANDLE,LPCHAR…… I can't find anywhere that I can look up the choices that I have in OI.

2. Where do I define the functions Reg…. etc, USER32 or KERNEL32? How do I tell if they are available in OI?

3. What is the correct format for the records in DLL_USER32 or as in my case DLL_DSL_USER32

Thanks


At 02 MAY 2002 02:11AM Pat McNerthney wrote:

Both of the registry apis you are trying to access are in ADVAPI32.DLL.

Check this link at msdn.microsoft.com:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/regapi_7yns.asp

Towards the bottom it says "Library: Use Advapi32.lib.". Generally this means that it runs using a dll of the same name as the .lib.

Pat


At 02 MAY 2002 05:39AM [url=http://www.sprezzatura.com" onMouseOver=window.status=Click here to visit our web site?';return(true)]The Sprezzatura Group[/url] wrote:

Steve

If you've still got problems after following Pat's advice, drop us a line. We've got all of the registry stuff integrated into Utility32 as our standard MDI Frames and utilities such as S/List automatically maintain MRU info, window positioning in the Registry.

The Sprezzatura Group

[i]Celebrate CeBIT with Sprezz Local![/i]


At 07 MAY 2002 09:39PM S Botes wrote:

Okay, I am making some progress. I appear to be able to open the registry key that I want. However, when I attempt to read it windows cancels openengine. It seems to occur with any reference to the pointer returned by the call to RegOpenKeyEx. I even tried a getvalue to KeyHandle and that will cause the same error to occur, W2K terminates openengine.

This is the code that I am using. Any help would be appreciated.

equ HKEY_LOCAL_MACHINE$ to 0x80000002

equ STANDARD_RIGHTS_READ$ to 0x0002000

equ STANDARD_RIGHTS_WRITE$ to 0x0002000

equ STANDARD_RIGHTS_EXECUTE$ to 0x0002000

equ STANDARD_RIGHTS_ALL$ to 0x001F0000

equ STANDARD_RIGHTS_REQUIRED$ to 0x000F0000

equ KEY_QUERY_VALUE$ to 0x0001

equ KEY_SET_VALUE$ to 0x0002

equ KEY_CREATE_SUB_KEY$ to 0x0004

equ KEY_ENUMERATE_SUB_KEYS$ to 0x0008

equ KEY_NOTIFY$ to 0x0010

equ KEY_CREATE_LINK$ to 0x0020

equ KEY_READ$ to STANDARD_RIGHTS_READ$ + KEY_QUERY_VALUE$ + KEY_ENUMERATE_SUB_KEYS$ + KEY_NOTIFY$

equ KEY_WRITE$ to STANDARD_RIGHTS_WRITE$ + KEY_SET_VALUE$ + KEY_CREATE_SUB_KEY$

equ KEY_EXECUTE$ to KEY_READ$

equ KEY_ALL_ACCESS$ to STANDARD_RIGHTS_ALL$ + KEY_QUERY_VALUE$ + KEY_SET_VALUE$ + KEY_CREATE_SUB_KEY$ + KEY_ENUMERATE_SUB_KEYS$ + KEY_NOTIFY$ + KEY_CREATE_LINK$

equ ERROR_SUCCESS to 0x0000

options=0

samDesired=KEY_QUERY_VALUE$

declare function RegOpenKeyEx, RegCloseKey, RegQueryValueEx
declare subroutine Set_Property, RegQueryValueEx
KeyHandle=0
Hkey=HKEY_LOCAL_MACHINE$
SubKey=SOFTWARE\DYMO\LabelWriter":\00\
stat=0
null='
LockVariable KeyHandle as Long
stat=RegOpenKeyEx(Hkey,SubKey,options,samDesired,getpointer(KeyHandle))
If Stat=ERROR_SUCCESS Then

* debug

* HKeyValue=GetValue(KeyHandle,LONG,4)

	Path=str(\00\, 512)
	Reg_SZ=1
	cbBuf=512
    Key=InstallPath":\00\
	RegQueryValueEx(KeyHandle, Key, 0, Reg_SZ, Path, cbBuf)

declaration

ONG STDCALL RegOpenKeyExA(HANDLE, LPCHAR, ULONG, ULONG, LONG) AS RegOpenKeyEx

LONG STDCALL RegQueryValueExA(HANDLE,LPCHAR,LPVOID,ULONG,LPCHAR,ULONG) AS RegQueryValueEx

LONG STDCALL RegCloseKeyA(HANDLE) AS RegCloseKey


At 07 MAY 2002 10:26PM Pat McNerthney wrote:

Try this:

LONG STDCALL RegOpenKeyExA(HANDLE, LPCHAR, ULONG, ULONG, LPLONG) AS RegOpenKeyEx

LONG STDCALL RegQueryValueExA(HANDLE, LPCHAR, LPVOID, LPULONG, LPCHAR, LPULONG) AS RegQueryValueEx

LONG STDCALL RegCloseKeyA(HANDLE) AS RegCloseKey

then try this:

KeyHandle=0

Hkey=HKEY_LOCAL_MACHINE$

SubKey=SOFTWARE\DYMO\LabelWriter":\00\

stat=0

null='

LockVariable KeyHandle as Long

stat=RegOpenKeyEx(Hkey, SubKey, options, samDesired, KeyHandle)

If Stat=ERROR_SUCCESS Then

* debug

* HKeyValue=GetValue(KeyHandle,LONG,4)

Path=str(\00\, 512)

Reg_SZ=1

cbBuf=512

Key=InstallPath":\00\

RegQueryValueEx(KeyHandle, Key, 0, Reg_SZ, Path, cbBuf)

Pat


At 08 MAY 2002 12:54AM S Botes wrote:

Thanks Pat, that did the trick.

It appears that I had the parameter types screwed up. I did find information all over about them but never quite understood just how to use them. I would be happy to try and put together a knowledgebase article if you would help me accumulate the information needed. I am not asking you to do the work but help me learn where to find things. At that point I should be able to organize the information and send it to you for editin….. up to you. Let me know. It would be a good way for me to learn and maybe help others like me.

View this thread on the forum...

  • third_party_content/community/commentary/forums_nonworks/00f99537e23fc49e88256bad0013107f.txt
  • Last modified: 2023/12/28 07:40
  • by 127.0.0.1