P
Peter
I use dynamically loaded dll's a lot in my programs. The one thing i cannot
figure out how do is too to sucessfully pass the address of a class instance
created within the dynamically loaded dll. I step thru the code and confirm
that the class is correctly created in the dll, but as soon as it steps out
of the dll i loose the address. For example:
hLib = LoadLibrary("RasterIO.dll");
ImageIOClass *ImageIO = (ImageIOClass
*)GetProcAddress((HINSTANCE)hLib, "_GetImageIOClass");
if (ImageIO != NULL)
{
TRasterIO *IO;
ImageIO(IO, ...); // instance created with new in dll.
if (IO)
{
// do something with IO
....
}
else
{
return;
}
delete IO;
}
UnloadPackage(hLib);
That is the basic idea of what i am trying to do. If i statically link the
dll i can get an instance of the class no problem. I suppose this is all
something to do with the way dlls handle and share memory - something i
obviously do not understand!
Peter
figure out how do is too to sucessfully pass the address of a class instance
created within the dynamically loaded dll. I step thru the code and confirm
that the class is correctly created in the dll, but as soon as it steps out
of the dll i loose the address. For example:
hLib = LoadLibrary("RasterIO.dll");
ImageIOClass *ImageIO = (ImageIOClass
*)GetProcAddress((HINSTANCE)hLib, "_GetImageIOClass");
if (ImageIO != NULL)
{
TRasterIO *IO;
ImageIO(IO, ...); // instance created with new in dll.
if (IO)
{
// do something with IO
....
}
else
{
return;
}
delete IO;
}
UnloadPackage(hLib);
That is the basic idea of what i am trying to do. If i statically link the
dll i can get an instance of the class no problem. I suppose this is all
something to do with the way dlls handle and share memory - something i
obviously do not understand!
Peter