Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting constants from a C DLL?
#1
*Warning, possible dumb question*

Is it possible to get the constants from a DLL?

This is what I am trying to do....

The GSL dlls have several constants defined (Pi, Euler's, etc). I have the .h files so I could hard code them in FB, but I think it would be better to get them from the DLL that way if a new version comes out its just a matter of dropping the new dll in (or at least it should be).

I understand the Declare (sub|function) bit, is it possible to do this with constants?
Reply
#2
If they're #define'd in the .h, you can't get them from the DLL. If they're actual const variables, as in 'const int pi = 3;', then you should be able to do:
Code:
extern import pi as integer
print "pi = "; pi
Reply
#3
They are #defined <insert profanity here>

Oh well,

Thanks
Reply
#4
You can use the Win32 API, I have used LoadLibrary or GetModuleHandle and then GetProcAddress to get variables from a DLL. I don't have an example in FreeBASIC though.
Reply
#5
But if they're #define'd, they're not variables; therefore, you can't get their addresses.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)