Announcement

Collapse
No announcement yet.

Direct Interface Error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Direct Interface Error

    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:

    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
    From the object library:

    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
    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.
    --
    <strong>Billing clients for your freelance work?</strong> Try <a href="http://www.minute-2-minute.com">Minute-2-Minute</a>, the project management, timing, and billing system. Perfect for programmers who charge by the hour. FREE 45-day trial.

  • #2
    The error code for this message is 1 (%ERROR_INVALID_FUNCTION). My guess is that this is the result returned by the method, not an error code.

    You told me by email that my browser generated the following definition

    Code:
      METHOD GetNextMarketProfile <31> ( _             ' VTable offset = 168
      )                                                ' void
    My guess is that the type library for this component is buggy.

    Try it changing the declaration to:

    Code:
    METHOD GetFirstMarketProfile <30> (BYREF nProfile AS LONG)
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      Thanks, José, but I'm still getting the "Incorrect function" error even with the change you suggested.

      The example provided with the Unfair Advantage COM API document is VB code, and I thought something might have gotten lost in translation (although the VB code appears to be straightforward). The PB code does work well when using the dispatch interface. Also, we can set and get properties using the direct method in PB (no error is produced); only when calling a method do we run into problems.

      Thanks again for your help on this problem and all the other help you provide for the PB community.
      --
      <strong>Billing clients for your freelance work?</strong> Try <a href="http://www.minute-2-minute.com">Minute-2-Minute</a>, the project management, timing, and billing system. Perfect for programmers who charge by the hour. FREE 45-day trial.

      Comment

      Working...
      X