|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Borrmann Manfred
Joined: 29 Mar 2007 Posts: 28
|
Posted: Mon Apr 02, 2007 3:48 pm Post subject: REG_DWORD |
|
|
Hello,
can anyone tell me how to get the decimal value of a variable of type REG_DWORD which i have read from the registry using the STDCALL "REGQUERYVALUEEX".
Many Thanks
Manfred |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Mon Apr 02, 2007 5:27 pm Post subject: |
|
|
It has the value 4 in win32prm.ins. |
|
Back to top |
|
|
Borrmann Manfred
Joined: 29 Mar 2007 Posts: 28
|
Posted: Tue Apr 03, 2007 8:04 am Post subject: REG_DWORD |
|
|
Paul, thanks for your comment, but this is not my problem.
I tried to read the registry item "Test" of type REG_DWORD which has the value 0x00000020(32). When i read this item with the STDCALL "REGQUERYVALUEEX(hkey,'Test',CORE4(0), what_type, iwert, length)" where hkey, what_type, iwert and length are integers and length has the value of 4 i got for iwert a value of 538976288 and not the value 32.
Manfred |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Tue Apr 03, 2007 8:30 am Post subject: |
|
|
Can you post all of the relevant code for opening the key etc. |
|
Back to top |
|
|
Borrmann Manfred
Joined: 29 Mar 2007 Posts: 28
|
Posted: Tue Apr 03, 2007 11:01 am Post subject: REG_DWORD |
|
|
Hello Paul, here comes the relevant code
IMPLICIT NONE
STDCALL RegOpenKeyEx 'RegOpenKeyExA' (VAL,STRING,VAL,VAL,REF):INTEGER*4
STDCALL RegQueryValueEx'RegQueryValueExA'(VAL,STRING,REF,REF,STRING,REF):INTEGER
STDCALL RegCloseKey'RegCloseKey'(VAL):INTEGER
INTEGER,PARAMETER :: HKEY_LOCAL_MACHINE=Z'80000002'
INTEGER,PARAMETER :: KEY_ALL_ACCESS=Z'f003f'
INTEGER,PARAMETER :: BUFSIZE=256
INTEGER :: hKey,res,length, what_type, iwert
length = BUFSIZE
res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,'SOFTWARE\DYSMASP',0,KEY_ALL_ACCESS,hKey)
IF(res /= 0) STOP 'ERROR:Cannot open registry key : HKEY_LOCAL_MACHINE\SOFTWARE\DYSMASP'
res = RegQueryValueEx(hKey,'Test',CORE4(0),what_type,iwert,length)
IF(res /= 0)THEN
PRINT*,'ERROR:Cannot read REG_DWORD Test'
ELSE
PRINT*,'REG_DWORD Test = ', iwert
ENDIF
res = RegCloseKey(hKey)
END
Thanks, Manfred |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Tue Apr 03, 2007 11:59 am Post subject: |
|
|
Two things...
1. Modify the declaration of RegQueryValueEx
2. set length = 4 before the call as below
IMPLICIT NONE
STDCALL RegOpenKeyEx 'RegOpenKeyExA' (VAL,STRING,VAL,VAL,REF):INTEGER*4
STDCALL RegQueryValueEx'RegQueryValueExA'(VAL,STRING,REF,REF,REF,REF):INTEGER
STDCALL RegCloseKey'RegCloseKey'(VAL):INTEGER
INTEGER,PARAMETER :: HKEY_LOCAL_MACHINE=Z'80000002'
INTEGER,PARAMETER :: KEY_ALL_ACCESS=Z'f003f'
INTEGER,PARAMETER :: BUFSIZE=256
INTEGER :: hKey,res,length, iwert
length = BUFSIZE
res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\.NETFramework',0,KEY_ALL_ACCESS,hKey)
IF(res /= 0) STOP 'ERROR:Cannot open registry key'
length = 4
res = RegQueryValueEx(hKey,'DbgJITDebugLaunchSetting',CORE4(0),CORE4(0),iwert,length)
IF(res /= 0)THEN
PRINT*,'ERROR:Cannot read REG_DWORD'
ELSE
PRINT*,'REG_DWORD Test = ', iwert
ENDIF
res = RegCloseKey(hKey)
END |
|
Back to top |
|
|
Borrmann Manfred
Joined: 29 Mar 2007 Posts: 28
|
Posted: Tue Apr 03, 2007 12:48 pm Post subject: REG_DWORD |
|
|
Hello Paul,
the modification of the declaration of "REGQUERY..." is the key in order to become successful.
Many thanks for solving my problem.
Manfred |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Wed Apr 04, 2007 7:51 am Post subject: |
|
|
According to the documentation the call will fail if length is less than 4 on input. |
|
Back to top |
|
|
silverdan
Joined: 14 May 2009 Posts: 29
|
Posted: Thu Mar 25, 2010 11:01 pm Post subject: |
|
|
When I use the code from this thread that Paul posted I get the following error message:
System.InvalidProgramException was unhandled
Message: Common Language Runtime detected an invalid program.
If I replace CORE4(0) with 0, I do not get that error message, but the call to RegQueryValueEx returns an invalid value of 87.
Do I need to import something to use CORE4?
Here is the code I am using:
Code: |
IMPLICIT NONE
STDCALL RegOpenKeyEx 'RegOpenKeyExA' (VAL,STRING,VAL,VAL,REF):INTEGER*4
STDCALL RegQueryValueEx'RegQueryValueExA'(VAL,STRING,REF,REF,REF,REF):INTEGER
STDCALL RegCloseKey'RegCloseKey'(VAL):INTEGER
INTEGER,PARAMETER :: HKEY_LOCAL_MACHINE=Z'80000002'
INTEGER,PARAMETER :: KEY_ALL_ACCESS=Z'f003f'
INTEGER,PARAMETER :: BUFSIZE=256
INTEGER :: hKey,res,length, iwert
length = BUFSIZE
res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\.NETFramework',0,KEY_ALL_ACCESS,hKey)
IF(res /= 0) STOP 'ERROR:Cannot open registry key'
length = 4
res = RegQueryValueEx(hKey,'DbgJITDebugLaunchSetting',CORE4(0),CORE4(0),iwert,length)
IF(res /= 0)THEN
PRINT*,'ERROR:Cannot read REG_DWORD'
ELSE
PRINT*,'REG_DWORD Test = ', iwert
ENDIF
res = RegCloseKey(hKey)
END
|
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Tue Jul 13, 2010 9:12 am Post subject: |
|
|
I do not know what is going wrong here but if you need to use .NET rather than Win32 then you can avoid CORE4 by using a VAL rather than a REF...
Code: | IMPLICIT NONE
STDCALL RegOpenKeyEx 'RegOpenKeyExA' (VAL,STRING,VAL,VAL,REF):INTEGER*4
STDCALL RegQueryValueEx'RegQueryValueExA'(VAL,STRING,VAL,VAL,REF,REF):INTEGER
STDCALL RegCloseKey'RegCloseKey'(VAL):INTEGER
INTEGER,PARAMETER :: HKEY_LOCAL_MACHINE=Z'80000002'
INTEGER,PARAMETER :: KEY_ALL_ACCESS=Z'f003f'
INTEGER,PARAMETER :: BUFSIZE=256
INTEGER :: hKey,res,length, iwert
length = BUFSIZE
res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\.NETFramework',0,KEY_ALL_ACCESS,hKey)
IF(res /= 0) STOP 'ERROR:Cannot open registry key'
length = 4
res = RegQueryValueEx(hKey,'DbgJITDebugLaunchSetting',0,0,iwert,length)
IF(res /= 0)THEN
PRINT*,'ERROR:Cannot read REG_DWORD'
ELSE
PRINT*,'REG_DWORD Test = ', iwert
ENDIF
res = RegCloseKey(hKey)
END |
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|