---------------------structure in dll
#pragma pack(1)
struct __declspec(dllexport) summary
{
char DeviceName[300];
char DeviceId[15];
char DeviceClass[10];
char DeviceComport[6];
unsigned long long DevicelongId;
int DeviceCount;
}Summary[100];
-------------------------in console application
in .h
struct __declspec(dllimport) summary
{
char DeviceName[300];
char DeviceId[15];
char DeviceClass[10];
char DeviceComport[6];
unsigned long long DevicelongId;
int DeviceCount;
}Summary[100];
in .c file
HINSTANCE hMod = LoadLibrary (L"BTCdll.dll");
if (NULL == hMod)
printf ("LoadLibrary failed\n");
else
printf ("LoadLibrary LOADED\n");
FARPROC initfn = GetProcAddress(hMod, (LPCSTR)MAKEWORD(4,0));
initfn();
printf("%d",Summary[1]->DeviceCount);
How to import my structure in the console application code ?
[edit originator="01.mandar"]
dll export details
==================================================
Function Name : public: struct summary & __thiscall summary::operator=(struct summary const &)
Address : 0x1002708c
Relative Address : 0x0002708c
Ordinal : 2 (0x2)
Filename : BTCdll.dll
Full Path : D:\BTCdll.dll
Type : Exported Function <<<=====(this is struct summary..!)
==================================================
==================================================
Function Name : int __cdecl BT_Initialise2(void)
Address : 0x10027d7f
Relative Address : 0x00027d7f
Ordinal : 3 (0x3)
Filename : BTCdll.dll
Full Path : D:\BTCdll.dll
Type : Exported Function
==================================================
i have made the BTCdll.dll and exported 2 struct and 2 function. I can LoadLibrary and call 2 function successfully.
when the function init is executed it will populate the 2 struct which i want to import in console application.
can I
----in BTCdll.h
include the struct like
struct __declspec(dllimport) summary
{
char DeviceName[300];
char DeviceId[15];
char DeviceClass[10];
char DeviceComport[6];
unsigned long long DevicelongId;
int DeviceCount;
}Summary[100];
can i some how get "Summary[100]" which is populated
--- in console.c
FARPROC mystruct= GetProcAddress(hMod, (LPCSTR)MAKEWORD(2,0));
int cnt=mystruct[3]->DeviceCount;
[/edit]