Help Needed for COM Automation
Posted: Wed Feb 16, 2011 5:49 pm
Hi
I am attempting to access a VFP multi-threaded dll from PB and I have the following code so far. I am wondering why the CoCreateInstance_ fails. The error it reports is :
I am attempting to access a VFP multi-threaded dll from PB and I have the following code so far. I am wondering why the CoCreateInstance_ fails. The error it reports is :
However I have registered the dll and it reported "succeeded". I am not sure that I have correctly setup the CoCreateInstance. The MSDN documenation says:A specified class is Not registered in the registration database. Also can indicate that the type of server you requested in the CLSCTX Enumeration is Not registered Or the values For the server types in the registry are corrupt.
So I any one has any suggestions about what is wrong I would appreciate it.HRESULT CoCreateInstance(
__in REFCLSID rclsid,
__in LPUNKNOWN pUnkOuter,
__in DWORD dwClsContext,
__in REFIID riid,
__out LPVOID *ppv
);
Parameters
rclsid [in]
The CLSID associated with the data and code that will be used to create the object.
pUnkOuter [in]
If NULL, indicates that the object is not being created as part of an aggregate. If non-NULL, pointer to the aggregate object's IUnknown interface (the controlling IUnknown).
dwClsContext [in]
Context in which the code that manages the newly created object will run. The values are taken from the enumeration CLSCTX.
riid [in]
A reference to the identifier of the interface to be used to communicate with the object.
ppv [out]
Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppv contains the requested interface pointer. Upon failure, *ppv contains NULL.
Code: Select all
Interface Idckardauth
QueryInterface()
Addref()
Release()
GetTypeInfoCount()
GetTypeInfo()
GetIDsOfNames()
Invoke()
PrepareResponse.s(tcRcvd.s)
EndInterface
Define loVFP.idckardauth,lcRcvd.s
lcRcvd = "DONEY CRES PVSystem211001.2@KT782448300000013004T01011.000201DATE02162011TIME0952060011$"
CoInitializeEx_(0,#COINIT_MULTITHREADED)
hr = CoCreateInstance_("{8DC6BA5D-6861-4F0A-A080-7DEDCC97C10F}", NULL, 0,"{4C791FAF-8649-462D-A93A-185F95C2DC0E}",@loVFP.Idckardauth)
Select hr
Case #S_OK
Debug "Success"
Case #REGDB_E_CLASSNOTREG
Debug "A specified class is Not registered in the registration database. Also can indicate that the type of server you requested in the CLSCTX Enumeration is Not registered Or the values For the server types in the registry are corrupt."
Case #CLASS_E_NOAGGREGATION
Debug "This class cannot be created As part of an aggregate."
Case #E_NOINTERFACE
Debug "The specified class does Not implement the requested Interface, Or the controlling IUnknown does Not expose the requested Interface."
Case #E_POINTER
Debug "The ppv parameter is NULL."
Default
Debug hr
EndSelect
lcTxt.s = loVFP\PrepareResponse(lcRcvd)
loVFP\Release()
loVFP = 0
CoUninitialize_()