Click here to Skip to main content
16,006,341 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: what about dll application Pin
Michael P Butler25-Jan-02 0:22
Michael P Butler25-Jan-02 0:22 
GeneralRe: what about dll application Pin
Gérald Mercet25-Jan-02 3:14
Gérald Mercet25-Jan-02 3:14 
AnswerRe: what about dll application Pin
Michael P Butler25-Jan-02 0:26
Michael P Butler25-Jan-02 0:26 
GeneralSubClassing Pin
RaviRao24-Jan-02 20:05
RaviRao24-Jan-02 20:05 
Questionhow to change the IP address of local machine without rebooting? Pin
Shuyi Vi24-Jan-02 19:52
Shuyi Vi24-Jan-02 19:52 
GeneralDirectly accessing KB hardware Pin
Jason Hooper24-Jan-02 17:51
Jason Hooper24-Jan-02 17:51 
GeneralRe: Directly accessing KB hardware Pin
Nish Nishant24-Jan-02 19:45
sitebuilderNish Nishant24-Jan-02 19:45 
Questionstl/dll problem with virtual destructor? Pin
24-Jan-02 16:31
suss24-Jan-02 16:31 
Hello.

I got a problem when using vector which is filled in dll. I have a vector of objects, then I pass this address of this vector to the function in a loaded dll. In the dll I'm filling this vector with some values. And problem is that when free dll handler, the memory in the vector got released also, so vector couses an exception when destructors of objects are called.

So it works untill dll FreeLibrary is called.

I've descover that there's no problem when destructor is not decleared as a vertul function. But what if I want to have it virtual?

There's an example of my code:

//It's a simple object:
class CSJImage
{
public:
CSJImage(){};
CSJImage(const CSJImage& orig){};
CSJImage &operator=(const CSJImage& orig){};
// remove virtual and everything is fine,
// but with virtual I have an error if I want to clear the vecor!
virtual ~CSJImage(){};
};
// vector type which address is passed to the dll
typedef std::vector<csjimage> VectorType;
// prototype of function in the dll
typedef int(*fntTest)(VectorType*);

This's function in DLL:
extern "C" __declspec(dllexport)
int Test(VectorType *vec)
{
CSJImage so1,so2;
vec->push_back(so1);
vec->push_back(so2);
return 2;
}

In the main program I'm doing this:
VectorType vec;
HINSTANCE m_hAcqLib;
fntTest fntAddr;
// Load function address into fntAddr here!!!
fntAddr=GetAddress();
fntAddr(&vec);
// Here I can use vec and what it contains
// vec.clear() // this wouldn't couse any exceptions
if(m_hAcqLib!=NULL) FreeLibrary(m_hAcqLib);
// But here I can not any more Frown | :(
vec.clear() // this couses an exception!

Thanks for help

Alexander.
AnswerRe: stl/dll problem with virtual destructor? Pin
Joaquín M López Muñoz24-Jan-02 21:22
Joaquín M López Muñoz24-Jan-02 21:22 
GeneralRe: stl/dll problem with virtual destructor? Pin
25-Jan-02 3:28
suss25-Jan-02 3:28 
GeneralRTTI Help Pin
alex.barylski24-Jan-02 16:17
alex.barylski24-Jan-02 16:17 
GeneralRe: RTTI Help Pin
Christian Graus24-Jan-02 16:27
protectorChristian Graus24-Jan-02 16:27 
GeneralRe: RTTI Help Pin
alex.barylski24-Jan-02 18:00
alex.barylski24-Jan-02 18:00 
GeneralRe: RTTI Help Pin
Christian Graus24-Jan-02 18:08
protectorChristian Graus24-Jan-02 18:08 
Questionhow to show/hide the activate/deactive VIEW? Pin
AnonymousBabe@usa.net24-Jan-02 16:02
AnonymousBabe@usa.net24-Jan-02 16:02 
GeneralDesktop FLASHING?! Pin
gh24-Jan-02 16:01
gh24-Jan-02 16:01 
GeneralRe: Desktop FLASHING?! Pin
Christian Graus24-Jan-02 16:14
protectorChristian Graus24-Jan-02 16:14 
GeneralRe: Desktop FLASHING?! Pin
gh24-Jan-02 16:18
gh24-Jan-02 16:18 
GeneralRe: Desktop FLASHING?! Pin
Christian Graus24-Jan-02 16:28
protectorChristian Graus24-Jan-02 16:28 
GeneralRe: Desktop FLASHING?! Pin
gh24-Jan-02 16:31
gh24-Jan-02 16:31 
GeneralRe: Desktop FLASHING?! Pin
24-Jan-02 16:44
suss24-Jan-02 16:44 
GeneralRe: Desktop FLASHING?! Pin
gh24-Jan-02 16:51
gh24-Jan-02 16:51 
GeneralRe: Desktop FLASHING?! Pin
Nish Nishant24-Jan-02 17:31
sitebuilderNish Nishant24-Jan-02 17:31 
GeneralGUI Programming :: C++ Exclusive Pin
valikac24-Jan-02 13:29
valikac24-Jan-02 13:29 
GeneralRe: GUI Programming :: C++ Exclusive Pin
Christian Graus24-Jan-02 13:36
protectorChristian Graus24-Jan-02 13:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.