* Importing calls to access Windows registry
@ 1999-05-07 0:00 czgrr
1999-05-07 0:00 ` Tom Moran
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: czgrr @ 1999-05-07 0:00 UTC (permalink / raw)
Hello everybody, my turn to ask a question.
I am using ObjectAda 7.1.1 on Windows NT 4.0. I am trying to access the
registry, but I am coming across link errors which I have not been able to
fix. Something obvious, I expect, but just not to me! This was based on code
from a Windows 95 application in ActivAda (83) which works.
I only have Ada83 experience, so please let me know if anything you might
provide in a solution is only available in Ada95, or only in ObjectAda AFAYK.
I am doing this for one of a few functions I want...
TYPE windows_integer_type IS RANGE -2**31 .. ( 2**31 - 1 ) ;
FOR windows_integer_type'SIZE USE 32 ;
TYPE string_pointer_type IS ACCESS STRING ;
TYPE string_pointer_pointer_type IS ACCESS string_pointer_type ;
FUNCTION RegOpenKey
( key : SYSTEM.ADDRESS ; -- IN
subkey : STRING ; -- IN
key_address : string_pointer_pointer_type ) -- OUT
RETURN windows_integer_type ;
PRAGMA IMPORT ( WIN32, RegOpenKey ) ;
but I get the following link error...
registry_server.obj : error LNK2001: unresolved external symbol _RegOpenKey@12
What am I doing wrong?
Cheers in advance,
czgrr
--
No email, please - reply to the newsgroup. Email may be made public.
My opinions are not necessarily those of my employer.
My suggestions might not be correct. Use at your own risk.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Importing calls to access Windows registry
1999-05-07 0:00 Importing calls to access Windows registry czgrr
1999-05-07 0:00 ` Tom Moran
@ 1999-05-07 0:00 ` Sune Falck
1999-05-11 0:00 ` czgrr
2 siblings, 0 replies; 5+ messages in thread
From: Sune Falck @ 1999-05-07 0:00 UTC (permalink / raw)
RegOpenKey is in the advapi32.dll so you must somehow add
advapi32.lib to the linker command line.
One way might be to add ...objecta\apilib as a search path in the
Objectada IDE
Another alternativ is to set the environment variable LIB so
that it includes the ...objecta\apilib directory and then add
-ll advapi32.lib to the adabuild command.
>I am using ObjectAda 7.1.1 on Windows NT 4.0. I am trying to access the
>registry, but I am coming across link errors which I have not been able to
>fix. Something obvious, I expect, but just not to me! This was based on code
>
>registry_server.obj : error LNK2001: unresolved external symbol _RegOpenKey@12
>
>What am I doing wrong?
>
>Cheers in advance,
>czgrr
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Importing calls to access Windows registry
1999-05-07 0:00 Importing calls to access Windows registry czgrr
@ 1999-05-07 0:00 ` Tom Moran
1999-05-07 0:00 ` dennison
1999-05-07 0:00 ` Sune Falck
1999-05-11 0:00 ` czgrr
2 siblings, 1 reply; 5+ messages in thread
From: Tom Moran @ 1999-05-07 0:00 UTC (permalink / raw)
The immediate answer to your link errors, as pointed out by
Sune Falck, is to add advapi32.lib to your link.
As a comment, I'd also suggest you can save yourself a lot of
typing and probably a lot of grief by using the package
Interfaces.C, instead of defining your own "windows_integer_type"
etc and using your own code to append nulls to Ada Strings and
using System.Address.
In Claw we (internally) use RegOpenKeyEx like
function Reg_Open_Key_Ex(Key : Claw.Win32.HKey;
lpszSubKey: Claw.Win32.Lpcstr;
dwReserved: Claw.DWord := 0;
samDesired: Key_Access_Options;
phkResult: PHKey)
return Reg_Error_Code_Type;
pragma Import(Stdcall, Reg_Open_Key_Ex, "RegOpenKeyExA");
inside
procedure Open (Key : in out Key_Type;
Parent : in Key_Type;
Name : in String;
Access_Capability : in Access_Capabilities :=
ALLOW_ALL_ACCESS;
Creation_Option : Creation_Options := Open_Only);
which uses it with
C_Name : Interfaces.C.Char_Array
:= Interfaces.C.To_C(Name, Append_Nul=>True);
Handle : aliased Claw.Win32.HKey;
...
Result := Reg_Open_Key_Ex(Parent.Handle,
C_Name(0)'Unchecked_Access,
0, -- reserved
Access_Code(Access_Capability),
Handle'Unchecked_Access);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Importing calls to access Windows registry
1999-05-07 0:00 ` Tom Moran
@ 1999-05-07 0:00 ` dennison
0 siblings, 0 replies; 5+ messages in thread
From: dennison @ 1999-05-07 0:00 UTC (permalink / raw)
In article <37331c0b.1253787@news.pacbell.net>,
tmoran@bix.com (Tom Moran) wrote:
> As a comment, I'd also suggest you can save yourself a lot of
> typing and probably a lot of grief by using the package
> Interfaces.C, instead of defining your own "windows_integer_type"
> etc and using your own code to append nulls to Ada Strings and
> using System.Address.
Generally that may be the case, but in his case it was *ported* code, so it
will not save him any typing to change. However, it may indeed save him
grief.
--
T.E.D.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Importing calls to access Windows registry
1999-05-07 0:00 Importing calls to access Windows registry czgrr
1999-05-07 0:00 ` Tom Moran
1999-05-07 0:00 ` Sune Falck
@ 1999-05-11 0:00 ` czgrr
2 siblings, 0 replies; 5+ messages in thread
From: czgrr @ 1999-05-11 0:00 UTC (permalink / raw)
Thanks to all who replied, I can now link the library in successfully.
For anyone else who is interested...
1. In "Project/Settings/Link/Pass to linker" I added:
c:\progra~2\aonix\objectada\apilib\advapi32.lib
(it didn't like "Program Files" in the path, even with quotes)
2. In the source file I added:
PRAGMA Linker_Options ( "-defaultlib:advapi32" ) ;
3. For the specification of RegOpenKey, the import statement was
changed to:
PRAGMA IMPORT ( STDCALL, RegOpenKey, "RegOpenKeyA" ) ;
TTFN,
czgrr
--
No email, please - reply to the newsgroup. Email may be made public.
My opinions are not necessarily those of my employer.
My suggestions might not be correct. Use at your own risk.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1999-05-11 0:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-07 0:00 Importing calls to access Windows registry czgrr
1999-05-07 0:00 ` Tom Moran
1999-05-07 0:00 ` dennison
1999-05-07 0:00 ` Sune Falck
1999-05-11 0:00 ` czgrr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox