forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

REG_DWORD

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
Borrmann Manfred



Joined: 29 Mar 2007
Posts: 28

PostPosted: Mon Apr 02, 2007 3:48 pm    Post subject: REG_DWORD Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7925
Location: Salford, UK

PostPosted: Mon Apr 02, 2007 5:27 pm    Post subject: Reply with quote

It has the value 4 in win32prm.ins.
Back to top
View user's profile Send private message AIM Address
Borrmann Manfred



Joined: 29 Mar 2007
Posts: 28

PostPosted: Tue Apr 03, 2007 8:04 am    Post subject: REG_DWORD Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7925
Location: Salford, UK

PostPosted: Tue Apr 03, 2007 8:30 am    Post subject: Reply with quote

Can you post all of the relevant code for opening the key etc.
Back to top
View user's profile Send private message AIM Address
Borrmann Manfred



Joined: 29 Mar 2007
Posts: 28

PostPosted: Tue Apr 03, 2007 11:01 am    Post subject: REG_DWORD Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7925
Location: Salford, UK

PostPosted: Tue Apr 03, 2007 11:59 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
Borrmann Manfred



Joined: 29 Mar 2007
Posts: 28

PostPosted: Tue Apr 03, 2007 12:48 pm    Post subject: REG_DWORD Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7925
Location: Salford, UK

PostPosted: Wed Apr 04, 2007 7:51 am    Post subject: Reply with quote

According to the documentation the call will fail if length is less than 4 on input.
Back to top
View user's profile Send private message AIM Address
silverdan



Joined: 14 May 2009
Posts: 29

PostPosted: Thu Mar 25, 2010 11:01 pm    Post subject: Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7925
Location: Salford, UK

PostPosted: Tue Jul 13, 2010 9:12 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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