Re: How to instantiate an [appobject] coclass
"Barzo" <dbarzo@gmail.com> wrote in message
news:aa9a107b-b9d3-431d-8f4d-975276568f1c@k33g2000yqa.googlegroups.com...
Hi,
in my DLL I have a coclass defined with [appobject] attribute:
-------------------------------------------------------------------------------
[
object,
uuid(AB566C82-AF54-11DE-B5BE-00A0D15E9B20),
dual,
nonextensible,
helpstring("IAudioLib Interface"),
hidden,
pointer_default(unique)
]
interface IAudioLib : IDispatch
{
[id(1), helpstring("Retrieve the library version.")]
HRESULT GetLibVersion([out, retval] BSTR* pVal);
[id(2), helpstring("Retrieve the error description.")]
HRESULT RetValToStr([in] E_AUDIOLIB_RET_VAL rv, [out, retval] BSTR*
pVal);
[id(3), helpstring("Retrieve the number of devices for a specific
API.")]
HRESULT GetDeviceCount([in] E_AUDIO_API audio_api, [out, retval]
short* pVal);
[id(4), helpstring("Retrieve the informations of a single device.")]
HRESULT GetDeviceInfo([in] long device,
[in] E_AUDIO_API audio_api,
[in, out] T_DeviceInfo* retDevInfo,
[out, retval] E_AUDIOLIB_RET_VAL* pVal);
[id(5), helpstring("Retreive an array containing informations for
all devices.")]
HRESULT GetDevicesInfo([in] E_AUDIO_API audio_api, [out, retval]
SAFEARRAY(T_DeviceInfo)* pVal);
};
....
....
[
uuid(AB566C81-AF54-11DE-B5BE-00A0D15E9B20),
appobject,
helpstring("AudioLib Class")
]
coclass AudioLib
{
[default] interface IAudioLib;
};
-------------------------------------------------------------------------------
I have implemented all the IAudioLib methods in AudioLib.cpp but, in
VB6, when I call a method:
MgsBox AxAudioLib4.GetLibVersion
--------------------
What is AxAudioLib4? I'll have to assume it's something like:
Dim AxAudioLib4 as NameOfCOMLibrary.AudioLib
and somewhere before you call AxAudioLib4.GetLibVersion you've done this:
Set AxAudioLib4 = new NameOfCOMLibrary.AudioLib
If either of the above is incorrect then that's your problem.
Drew
I get the error:
Runtime Error 429, "ActiveX component can't create object"
This kind of classes have to be implemented (or created) in a special
way?
Thanks,
Daniele.