Hi
I had previously tried the code using pointers as shown below but the results are the same.
Code: Select all
Interface Idckardauth Extends IDispatch
PrepareResponse.s(tcRcvd.p-bstr)
EndInterface
Define.i CLSID_Class,CLSID_Interface,lnRtn
Define.s GUID_C,GUID_I
GUID_C = "{8DC6BA5D-6861-4F0A-A080-7DEDCC97C10F}"
lnRtn = CLSIDFromString_(@GUID_C,@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
GUID_I = "{4C791FAF-8649-462D-A93A-185F95C2DC0E}"
lnRtn = CLSIDFromString_(@GUID_I,@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
lnRtn = CoInitializeEx_(0,#COINIT_MULTITHREADED)
;hr = CoInitializeEx_(0,#COINIT_APARTMENTTHREADED)
Select lnRtn
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
lnRtn = CoCreateInstance_(@CLSID_Class, 0,1,@CLSID_Interface,@loVFP)
Select lnRtn
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 lnRtn
EndSelect
Just for the curious this is the VFP code that works correctly:
Code: Select all
#Define NOERROR 0
#Define CO_E_CLASSSTRING 0x800401f3
#Define REGDB_E_CLASSNOTREG 0x80040154
#Define REGDB_E_READREGDB 0x80040150
#Define S_OK 0
#Define S_FALSE 1
#Define RPC_E_CHANGED_MODE 0x80010106
#Define CLASS_E_NOAGGREGATION 0x80040110
#DEfine E_NOINTERFACE 0x80004002
#Define COINIT_APARTMENTTHREADED 0x2
#Define COINIT_MULTITHREADED 0x0
#Define E_POINTER 0x80004003
DECLARE INTEGER CLSIDFromString IN ole32 STRING lpsz,STRING @ pclsid
Declare Integer CoInitializeEx IN ole32 Integer lpsz, Integer lpsz2
Declare Integer CoCreateInstance In ole32 String lpClass, Integer,Integer lnSrvType,String lpInterface, Object @ loVFP
Declare Integer CoUninitialize in Ole32
lcRcvd = "DONEY CRES PVSystem211001.2@KT782448300000013004T01011.000201DATE02162011TIME0952060011$"
Local lcClass,lcInterface,lnRtn,loVFP
lcClass = REPLICATE(CHR(0), 16)
*
* option 5 in StrConv() converts the string to Unicode
*
lnRtn = CLSIDFromString(Strconv("{8DC6BA5D-6861-4F0A-A080-7DEDCC97C10F}",5),@lcClass)
Do Case
Case lnRtn = NOERROR
DebugOut "Success"
Case lnRtn = CO_E_CLASSSTRING
DebugOut "The class string was improperly formatted."
Case lnRtn = REGDB_E_CLASSNOTREG
DebugOut "The CLSID corresponding to the class string was not found in the registry."
Case lnRtn = REGDB_E_READREGDB
DebugOut "The registry could not be opened for reading."
Otherwise
DebugOut lnRtn
EndCase
lcInterface = REPLICATE(CHR(0), 16)
*
* option 5 in StrConv() converts the string to Unicode
*
lnRtn = CLSIDFromString(Strconv("{4C791FAF-8649-462D-A93A-185F95C2DC0E}",5),@lcInterface)
Do Case
Case lnRtn = NOERROR
DebugOut "Success"
Case lnRtn = CO_E_CLASSSTRING
DebugOut "The class string was improperly formatted."
Case lnRtn = REGDB_E_CLASSNOTREG
DebugOut "The CLSID corresponding to the class string was not found in the registry."
Case lnRtn = REGDB_E_READREGDB
DebugOut "The registry could not be opened for reading."
Otherwise
DebugOut lnRtn
EndCase
lnRtn = CoInitializeEx(0,COINIT_MULTITHREADED)
*lnRtn = CoInitializeEx(0,COINIT_APARTMENTTHREADED)
Do Case
Case lnRtn = S_OK
DebugOut "Success"
Case lnRtn = S_FALSE
DebugOut "Failed"
Case lnRtn = RPC_E_CHANGED_MODE
DebugOut "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."
EndCase
loVFP = 0
lnRtn = CoCreateInstance(@lcClass, 0,5,@lcInterface,@loVFP)
Do Case
Case lnRtn = S_OK
DebugOut "Success"
Case lnRtn = REGDB_E_CLASSNOTREG
DebugOut "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 lnRtn = CLASS_E_NOAGGREGATION
DebugOut "This class cannot be created As part of an aggregate."
Case lnRtn = E_NOINTERFACE
DebugOut "The specified class does Not implement the requested Interface, Or the controlling IUnknown does Not expose the requested Interface."
Case lnRtn = E_POINTER
DebugOut "The ppv parameter is NULL."
Otherwise
DebugOut lnRtn
EndCase
Debugout loVFP.PrepareResponse(lcRcvd)
loVFP = 0
CoUninitialize()