Quick DLL question

Started by
3 comments, last by RoTTer 23 years, 9 months ago
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
Advertisement
I believe you have to declare the data as export and in the Exe, declare it as import..
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

You can try searching the MSDN in the dll section. It explains and gives example on how to import/export data in dll.
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

Mark Fassett

Laughing Dragon Games

http://www.laughing-dragon.com

This topic is closed to new replies.

Advertisement