Archived

This topic is now archived and is closed to further replies.

Quick DLL question

This topic is 6364 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey A quick and easy one : How can I access something (lets say a struct) that is in a DLL? I mean I have something like this in a DLL :
        
typedef struct
{

int a, b, c;

} SOMEDATA;

SOMEDATA Some_Data;
extern DLL SOMEDATA Some_Data;
    
And then I want to access this in my EXE. I tried :
typedef struct
{

int a, b, c;

} SOMEDATA;

extern DLL SOMEDATA Some_Data;
 
But it gives me an error. Obviously something must be wrong (or no error would appear, right? hehe), but I cant find it as its my 1st try with DLLs. Thanks a lot, -RoTTer (Using 2 (SOURCE) and (/SOURCE)s caused weird results so I had to use one (SOURCE) and one (CODE), sorry) Edited by - RoTTer on 7/12/00 9:10:35 PM

Share this post


Link to post
Share on other sites
Hey

Thanks for the reply! :>

Uhmm.. Im almost copying this DLL thing from another code, and it did it that way... And when I try it the compiler gives me an error =/.

What exactly the "extern DLL" is? Cause it gotta work, as its on the code Im looking (and it compiles perfectly here =/, the only difference I can see is that it is C and my code is C++ eheh).

But if I dont manage to make that work Ill try your import/export . Thanks.

Ah, just curious : What happens if I try to use a var (with extern DLL or import, whatever) and its not in the DLL? Program crashes?

Thanks, and cya,
-RoTTer

Share this post


Link to post
Share on other sites
You can try searching the MSDN in the dll section. It explains and gives example on how to import/export data in dll.

Share this post


Link to post
Share on other sites
I''m not sure about the DLL part, but I usually do something like this (so does msdn):

#define DLLEXPORT __declspec( dllexport )
#define DLLIMPORT __declspec( dllimport )

and then use the defines in place of having to remember the rest. It''s probable your DLL is defined as one or the other, and maybe it''s the wrong one.


Mark Fassett
Laughing Dragon Entertainment
http://www.laughing-dragon.com

Share this post


Link to post
Share on other sites