In working on converting PB8 code (using COM Dispatch calls) to PB9 (and COM Direct calls), we've run into an interesting problem. We're calling an out-of-process COM server in a program called Unfair Advantage. The interface includes a method called GetFirstMarketProfile that returns a long value. While calling this method works perfectly for the dispatch interface, it fails using the direct interface under PB9.
After spending some time with the help file, we developed the following test code:
From the object library:
OBJRESULT$ returns "Incorrect function". Since we know the method is available in the interface, we're at a loss as to why it cannot be accessed using the direct method. Any help is appreciated.
After spending some time with the help file, we developed the following test code:
Code:
#COMPILE EXE #DIM ALL #INCLUDE "D:\_AMR\QBH\QB3_source\Include\UAPB.inc" ' Object library FUNCTION PBMAIN () AS LONG LOCAL ret& LOCAL oUA AS IAPI2 oUA = NEWCOM $PROGID_UA_API2API2 IF ISOBJECT(oUA) AND ISFALSE ERR THEN oUA.IsStock = 0 ret& = oUA.GetFirstMarketProfile MSGBOX OBJRESULT$ oUA.HoldUAOpenOnClose = 0 oUA = NOTHING ELSE MSGBOX "Unable to open Unfair Advantage." END IF END FUNCTION
Code:
' Generated by: PowerBASIC COM Browser v.2.00.0058 ' DateTime : 8/26/2008 at 9:20 PM ' ------------------------------------------------ ' Library Name: UA ' Library File: C:\UA\uad.exe ' Description : CSI's Unfair Advantage® Library ' GUID : {6F2F99A0-6600-11D3-B331-525400E8C92C} ' LCID : 0 ' Version : 1.0 ' Version Dependant ProgID's $PROGID_UA_API2API2 = "Ua.API2" $PROGID_UA_UAScriptCallBackObjectUAScriptCallBackObject = "Ua.UAScriptCallBackObject" ' Class Indentifiers $CLSID_UA_API2 = GUID$("{6F2F99A3-6600-11D3-B331-525400E8C92C}") $CLSID_UA_UAScriptCallBackObject = GUID$("{A7120BAF-D87E-4949-93A0-53BB63F4D528}") ' Interface Indentifiers $IID_UA_IAPI2 = GUID$("{6F2F99A1-6600-11D3-B331-525400E8C92C}") $IID_UA_IUAScriptCallBackObject = GUID$("{F9EBB714-9476-4EA4-8F4C-1CB041E57708}") ' Interface Name : IAPI2 ' Description : Dispatch interface for API2 Object ' ClassID : $CLSID_UA_API2 INTERFACE IAPI2 $IID_UA_IAPI2 INHERIT IDISPATCH PROPERTY GET MarketNumber <1> () AS LONG PROPERTY SET MarketNumber <1> (BYVAL Value AS LONG) PROPERTY GET MarketSymbol <2> () AS STRING ' < - snip - > METHOD GetFirstMarketProfile <30> () AS LONG
Comment