Using exported varible from dll
-
Hi, I have exported dll from dll. I load dll using loadlibrary api. Using GetProceAddress I can get exported function pointer. But how can I use exported dll. __declspec(dllimport) only works when I link through .lib but in LoadLibrary? Thanks
-
Hi, I have exported dll from dll. I load dll using loadlibrary api. Using GetProceAddress I can get exported function pointer. But how can I use exported dll. __declspec(dllimport) only works when I link through .lib but in LoadLibrary? Thanks
manish rastogi wrote:
Using GetProceAddress I can get exported function pointer. But how can I use exported dll.
This way [^].
manish rastogi wrote:
__declspec(dllimport) only works when I link through .lib but in LoadLibrary?
You don't need
_declspec(dllimport)
when you use explicitDLL
linking (i.e.LoadLibrary
). Actually, when you use explicitDLL
linking, you don't need the library header file at all. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
manish rastogi wrote:
Using GetProceAddress I can get exported function pointer. But how can I use exported dll.
This way [^].
manish rastogi wrote:
__declspec(dllimport) only works when I link through .lib but in LoadLibrary?
You don't need
_declspec(dllimport)
when you use explicitDLL
linking (i.e.LoadLibrary
). Actually, when you use explicitDLL
linking, you don't need the library header file at all. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Sir, Thanks for your quick response. I want to import data. Suppose I exported data from dll using this way __declspec(dllexport) long g_lValue. How can I access it using explicit dll linking. Thanks
-
Sir, Thanks for your quick response. I want to import data. Suppose I exported data from dll using this way __declspec(dllexport) long g_lValue. How can I access it using explicit dll linking. Thanks
Why don't you (write and) export the accessors (i.e.
get
/set
functions) of your integer variable? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Why don't you (write and) export the accessors (i.e.
get
/set
functions) of your integer variable? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Sir, I can do this by writing get/set functions. I want to know this only It is possible or not.
-
Sir, I can do this by writing get/set functions. I want to know this only It is possible or not.
manish rastogi wrote:
I want to know this only It is possible or not.
Yes, it is possible. :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
manish rastogi wrote:
I want to know this only It is possible or not.
Yes, it is possible. :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]How can I do it Sir?
-
How can I do it Sir?
For instance: (DLL header)
#ifdef __cplusplus
extern "C"
{
#endif
extern DLLTEST_API int iExported;
#ifdef __cplusplus
};
#endif(DLL source)
#ifdef __cplusplus
extern "C"
{
#endif
DLLTEST_API int iExported;
#ifdef __cplusplus
};
#endif(DLL client)
//...
int * pInt =(int *) GetProcAddress(hLib, "iExported");:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
For instance: (DLL header)
#ifdef __cplusplus
extern "C"
{
#endif
extern DLLTEST_API int iExported;
#ifdef __cplusplus
};
#endif(DLL source)
#ifdef __cplusplus
extern "C"
{
#endif
DLLTEST_API int iExported;
#ifdef __cplusplus
};
#endif(DLL client)
//...
int * pInt =(int *) GetProcAddress(hLib, "iExported");:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Thanks Sir, It worked.
-
Thanks Sir, It worked.
You're welcome. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]