replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - FTN95 Interface to Windows registry
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 

FTN95 Interface to Windows registry

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



Joined: 21 Jun 2006
Posts: 404
Location: N�rnberg, Germany

PostPosted: Fri Aug 25, 2006 12:14 am    Post subject: FTN95 Interface to Windows registry Reply with quote

Hallo,

is it possible to access the windows registry using FTN95. The reason
for this is to extract the initial paths for a program that is called from
the FTN95 source.

Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Fri Aug 25, 2006 2:52 am    Post subject: FTN95 Interface to Windows registry Reply with quote

Johannes

You can access the Registry using Windows API functions such RegOpenKeyEx and RegQueryValueEx that are declared in win32api.ins and the equivalent MODULE.

The documentation for these functions is in
http://msdn.microsoft.com/library/en-us/sysinfo/base/registry_functions.asp
Back to top
View user's profile Send private message AIM Address
Anonymous
Guest





PostPosted: Mon Aug 28, 2006 5:05 am    Post subject: FTN95 Interface to Windows registry Reply with quote

Hi Paul,

I could not find an example and tried out the program below. There was a similar
question in the forum. However, I get the error - Retrun type is expected

Since I am using free format there should not be any truncation problems. What
could be the possible problem in this case?

Code:
program test_win32api
implicit none
include 'win32api.ins'

! Example from FTN95 Help
stdcall SUB2 'GetAttr':integer
stdcall CSUB3(REF,STRING(20)):STRING
stdcall SUB4 'GetSize'(REF,VAL,VAL,INSTRING,OUTSTRING(100))

! Copied this line from win32ins.api
STDCALL REGOPENKEYEX 'RegOpenKeyExA' (VAL,STRING,VAL,VAL,REF):INTEGER
STDCALL REGQUERYVALUE 'RegQueryValueA' (VAL,STRING,STRING,REF):INTEGER*4
end test_win32api
Back to top
Anonymous
Guest





PostPosted: Mon Aug 28, 2006 7:01 am    Post subject: FTN95 Interface to Windows registry Reply with quote

Hi Paul,

I assume that by using
Code:
include 'win32api.ins'
I do not
have to define it again as I did. In the documentaion only examples
of how to define the calls are given.

From the MSDN the syntax is clear, I have however difficulties implementing
what I would like to do.

Is there some complete example in the documentation available?

Back to top
PaulLaidler
Site Admin


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

PostPosted: Mon Aug 28, 2006 12:44 pm    Post subject: FTN95 Interface to Windows registry Reply with quote

Johannes

Does the following program compile OK for you?


include "win32api.ins"
end


I did have a sample program that accesses the registry. I will see if I can find it.

Back to top
View user's profile Send private message AIM Address
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: N�rnberg, Germany

PostPosted: Mon Aug 28, 2006 12:48 pm    Post subject: FTN95 Interface to Windows registry Reply with quote

Hi Paul,

it is working!

If you could send your sample program that access the registry it will help me a lot! Smile

Thanks

Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Tue Aug 29, 2006 2:51 am    Post subject: FTN95 Interface to Windows registry Reply with quote

IMPLICIT NONE
STDCALL RegOpenKey'RegOpenKeyA'(VAL,STRING,REF):INTEGER
STDCALL RegQueryValueEx'RegQueryValueExA'(VAL,STRING,REF,REF,STRING,REF):INTEGER
STDCALL RegCloseKey'RegCloseKey'(VAL):INTEGER
INTEGER,PARAMETER::HKEY_LOCAL_MACHINE=Z'80000002'
INTEGER,PARAMETER::BUFSIZE=256
INTEGER hKey,res,cbValue
CHARACTER(LEN=BUFSIZE) processorName
cbValue = BUFSIZE
res = RegOpenKey(HKEY_LOCAL_MACHINE,"HARDWAREDESCRIPTIONSystemCentralProcessor",hKey)
IF(res /= 0) STOP "ERROR:Cannot open registry key"
res = RegQueryValueEx(hKey,"ProcessorNameString",CORE4(0),CORE4(0),processorName,cbValue)
IF(res /= 0)THEN
PRINT*,"ERROR:Cannot read processor name"
ELSE
PRINT*,processorName(1:LEN_TRIM(processorName))
ENDIF
res = RegCloseKey(hKey)
end
Back to top
View user's profile Send private message AIM Address
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: N�rnberg, Germany

PostPosted: Tue Aug 29, 2006 4:01 am    Post subject: FTN95 Interface to Windows registry Reply with quote

Hi Paul,

thanks. This helps a lot Smile

From the example I could get the the desired result!

What I did not know was the following:
80000000 -> HKEY_CLASSES_ROOT
80000001 -> HKEY_CURRENT_USER
80000002 -> HKEY_LOCAL_MACHINE
80000003 -> HKEY_USERS
Back to top
View user's profile Send private message
dheller



Joined: 12 May 2011
Posts: 13
Location: Germany

PostPosted: Tue Dec 10, 2013 4:47 pm    Post subject: Reply with quote

Please allow me to resurrect this topic, because I have a similar problem right now.

My code, in a nutshell, opens a subkey of HKCU, enumerates its underlying sub-subkeys, and checks them for a certain value.

Code:
      integer, parameter :: ERROR_SUCCESS = 0, KEY_READ = Z'20019'
      integer*8, parameter :: HKEY_CURRENT_USER = Z'80000001'
....
      ret = RegOpenKeyEx(HKEY_CURRENT_USER, subkey, 0, KEY_READ,
     +            key_handle)
.... !if no error ....
c......... number of subkeys?
          ret = RegQueryInfoKey(key_handle, 0, 0, 0, LOC(num_subkeys),
     +                   0, 0, 0, 0, 0, 0, 0)
.... rest of code


However, RegQueryInfoKey always fails with ret equal to 87:
(WindowsError 87: ERROR_INVALID_PARAMETER The parameter is incorrect.)

What is wrong here? The code runs just fine with Intel Fortran, but I need it to work with FTN95, as well.

I already did try to use CORE4(0) instead of directly passing zeros, but I just get a runtime exception then.
Also, Paul, I don't understand why in your last code sample you used CORE4(0) instead of directly passing a 0-pointer.
As I understand it, CORE4(x) kind of de-references a pointer, much like * in C, but is the content of address 0 even well-defined?


Thanks in advance for any help. Smile


*Please note that I just included win32api.ins, instead of copying those STDCALL-statements like above.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Thu Dec 12, 2013 9:03 am    Post subject: Reply with quote

I am not able to give you a quick response. I have added it to my "to do" list.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Thu Dec 12, 2013 8:03 pm    Post subject: Reply with quote

Here is a small program to get the number of sub keys under Plato3.
The answer is 26.

Note that I have modified the binding for RegQueryInfoKey to pass a REF rather than an INSTRING. Also this is FTN95 so the handles are 32 bit integers.

Code:
integer, parameter :: KEY_READ = Z'20019'
integer, parameter :: HKEY_CURRENT_USER = Z'80000001'
stdcall RegOpenKeyEx 'RegOpenKeyExA' (VAL,STRING,VAL,VAL,REF):integer
stdcall RegQueryInfoKey 'RegQueryInfoKeyA'(VAL,REF,REF,REF,REF,REF,REF,REF,REF,REF,REF,REF):integer
stdcall RegCloseKey 'RegCloseKey' (VAL):integer
integer ret,key_handle,num_subkeys
character(len=80)::subkey
subkey = "Software\Salford Software\Plato3"
num_subkeys = 0     
ret = RegOpenKeyEx(HKEY_CURRENT_USER, subkey, 0, KEY_READ, key_handle)
ret = RegQueryInfoKey(key_handle, CORE4(0), CORE4(0), CORE4(0), num_subkeys, &
      & CORE4(0), CORE4(0), CORE4(0), CORE4(0), CORE4(0), CORE4(0), CORE4(0))
ret = RegCloseKey(key_handle) 
print*, num_subkeys
end     
       
Back to top
View user's profile Send private message AIM Address
dheller



Joined: 12 May 2011
Posts: 13
Location: Germany

PostPosted: Fri Dec 13, 2013 1:28 pm    Post subject: Reply with quote

Works for me now, thanks for your quick help.
Back to top
View user's profile Send private message
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