Hello.
I have a type library compiled with VC6 (APuma.dll) that I load in C + + Builder with this header:
[...]
typedef TComInterface<IStrings> IStringsPtr;
typedef TComInterface<IStringsDisp> IStringsDispPtr;
extern __declspec (package) const GUID LIBID_TIGERLib;
extern __declspec (package) const GUID DIID__IRecognitionEvents;
extern __declspec (package) const GUID IID_IRecognition;
extern __declspec (package) const GUID CLSID_Recognition;
interface DECLSPEC_UUID("{229C1071-829F-11D2-BA6E-0000E8D9FDF6}") _IRecognitionEvents;
typedef TComInterface<_IRecognitionEvents, &DIID__IRecognitionEvents> _IRecognitionEventsPtr;
interface DECLSPEC_UUID("{229C106F-829F-11D2-BA6E-0000E8D9FDF6}") IRecognition;
typedef TComInterface<IRecognition, &IID_IRecognition> IRecognitionPtr;
typedef IRecognition Recognition;
typedef IRecognitionPtr RecognitionPtr;
[...]
In C + + Builder, I was not using Recognition to instantiate the class, I used IRecognitionPtr, because when I used Recognition, the class is instantiated for each call to a procedure and then destroyed. With IRecognitionPtr, the class is instantiated and kept instantiated until eliminated.
When I go to carry the type library, I use dumpcpp tool, which generates a. Cpp and a. H, which I included in my project.
dumpcpp generates something like this:
[...]
struct IDispatch;
namespace TIGERLib {
// skipping event interface _IRecognitionEvents
class TIGERLIB_EXPORT IRecognition : public QAxObject
{
public:
IRecognition(IDispatch *subobject = 0, QAxObject *parent = 0)
: QAxObject((IUnknown*)subobject, parent)
{
internalRelease();
}
inline int AutoRotate() const;
[...]
static const QMetaObject staticMetaObject;
virtual const QMetaObject *metaObject() const { return &staticMetaObject; }
virtual void *qt_metacast(const char *);
};
class TIGERLIB_EXPORT Recognition : public QAxObject
{
public:
Recognition(QObject *parent = 0)
: QAxObject(parent)
{
setControl("{84e06770-9fd3-11d2-baa9-0000e8d9fdf6}");
}
Recognition(IRecognition *iface)
: QAxObject()
{
initializeFrom(iface);
delete iface;
}
inline int AutoRotate() const;
[...]
static const QMetaObject staticMetaObject;
virtual const QMetaObject *metaObject() const { return &staticMetaObject; }
virtual void *qt_metacast(const char *);
};
[...]
// aqui se ubican las implementaciones de Recognition y de IRecognition
[...]
template<>
inline void *qMetaTypeConstructHelper(const TIGERLib::Recognition *t)
{ Q_ASSERT(!t); return new TIGERLib::Recognition; }
template<>
inline void *qMetaTypeConstructHelper(const TIGERLib::IRecognition *t)
{ Q_ASSERT(!t); return new TIGERLib::IRecognition; }
I use this unit as follows:
Recognition *recog = new Recognition(this);
And then call the methods. However, I can think the same thing that happened with C + + Builder, apparently the class is instantiated for each call to the methods. I can not find the way that the Instance is maintained.
I appreciate any help I can get to fix this.
Greetings and thank you very much.