2
我的應用程序調用一個DLL並使用DLL結構更新應用程序結構。 但是在應用程序結構中有一個額外的字段(bool enable)。DLL和應用程序之間的VC++結構比較
當我嘗試分配我的應用程序struture.enable,我得到相同更新與垃圾值。
如何檢查dll中定義的結構和應用程序中定義的結構的大小是否具有相同的語法。
我不能改變任何東西在DLL中。
我想如果該字段不存在於dll結構中,則應用程序結構將初始化爲零。
我提供下面的代碼,
///// ** structure definition in the dll called application ** //////
typedef struct
{
DWORD Size;
bool mode;
BYTE check;
DWORD time_1;
DWORD time_2;
} STR_INTERFACE;
///// ** structure definition in the application ** //////
typedef struct
{
DWORD Size;
bool mode;
BYTE check;
DWORD time_1;
DWORD time_2;
bool enable;
} STR_INTERFACE;
///
///mypassedstr will conatin the updated structure pointer with the
///structure members updated by the dll
int MY_Appli_function::Interface_1_func (LPCTSTR name_1, LPVOID mypassedstr)
{
STR_INTERFACE mycodestr;
STR_INTERFACE* mynewstr = (STR_INTERFACE*)mypassedstr;
mycodestr.Size = mynewstr->.Size ;
mycodestr.mode = mynewstr->.mode ;
mycodestr.check = mynewstr->.check ;
mycodestr.time_1 = mynewstr->.time_1 ;
mycodestr.time_2 = mynewstr->.time_2 ;
mycodestr.enable = mynewstr->.enable ;
}
如果DLL也做了同樣這不僅有助於收拾你的結構。 – 2013-12-20 10:07:06