Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
String vs Character Type in COM Object
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01501310
Message ID:
01501554
Views:
37
Hi Anatoliy

I am trying to access a VFP MT dll from PureBasic. The problem is that everything works up until the "CoCreateInstance" which returns #REGDB_E_CLASSNOTREG. However, the class is registered and I can use it from VFP.

The "#" prefix indicates a Constant and the dot notation is used to indicate variable types. The "\" is used like VFP dot notation when calling methods and getting properties of objects. I have included my code below.

Thanks,
Simon
Define lcRcvd.s
lcRcvd = "DONEY CRES  PVSystem211001.2@KT782448300000013004T01011.000201DATE02162011TIME0952060011$"

Interface Idckardauth Extends IDispatch
	PrepareResponse.s(tcRcvd.p-bstr)
EndInterface	


Define *CLSID_Class,*CLSID_Interface,lnRtn.i

lnRtn = CLSIDFromString_("{8DC6BA5D-6861-4F0A-A080-7DEDCC97C10F}",@*CLSID_Class)

Select lnRTn
   Case #NOERROR
      Debug "Success"
   Case #CO_E_CLASSSTRING
      Debug "The class string was improperly formatted."
   Case #REGDB_E_CLASSNOTREG
      Debug "The CLSID corresponding to the class string was not found in the registry."
   Case #REGDB_E_READREGDB
      Debug "The registry could not be opened for reading."
   Default
      Debug lnRtn
EndSelect
      
lnRtn =  CLSIDFromString_("{4C791FAF-8649-462D-A93A-185F95C2DC0E}",@*CLSID_Interface)

Select lnRtn
   Case #NOERROR
      Debug "Success"
   Case #CO_E_CLASSSTRING
      Debug "The class string was improperly formatted."
   Case #REGDB_E_CLASSNOTREG
      Debug "The CLSID corresponding to the class string was not found in the registry."
   Case #REGDB_E_READREGDB
      Debug "The registry could not be opened for reading."
   Default
      Debug lnRtn
EndSelect

Define loVFP.idckardauth

;hr = CoInitializeEx_(0,#COINIT_MULTITHREADED)
hr = CoInitializeEx_(0,#COINIT_APARTMENTTHREADED)

Select hr
Case #S_OK
 Debug "Success"
Case #S_FALSE
   Debug "Failed"
Case #RPC_E_CHANGED_MODE
   Debug "A previous call to CoInitializeEx specified the concurrency model for this thread as multithread apartment (MTA). This could also indicate that a change from neutral-threaded apartment to single-threaded apartment has occurred." 
EndSelect

hr = CoCreateInstance_(@*CLSID_Class, 0,5,@*CLSID_Interface,@loVFP)

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

Debug loVFP\PrepareResponse(lcRcvd)
loVFP\Release()
loVFP = 0
CoUninitialize_()
>My understanding that a String parameter is received by COM object as BSTR.
>http://msdn.microsoft.com/en-us/library/ms221069.aspx
>
>SysAllocString and SysFreeString can be used to handle BSTRs.
>
>Exactly how and where (a client) is your VFP MT COM instantiated?
Simon White
dCipher Computing
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform