Announcement

Collapse
No announcement yet.

Create COM Object Fails

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

  • Create COM Object Fails

    I've done a bit of work with COM before to drive Excel - no problems, all worked following the examples on here. I've now got a small project to link to a third party VB6 DLL that has been supplied with a TLB file, should be no problem I thought but I cannot get the COM object to initialise. Here's what I've done:

    1. Registered the VB6 DLL using regsvr32.
    2. Used the PB object browser to create an include file.
    3. Run the code below:

    Code:
    #COMPILE EXE
    #INCLUDE "teCPPClient.INC"
    
    FUNCTION PBMAIN () AS LONG
        DIM oCPPClient AS teCPPClientclsConnect
        :
        LET oCPPClient = NEW teCPPClientclsConnect IN $PROGID_teCPPClientclsConnect
        IF ISFALSE ISOBJECT(oCPPClient) OR ERR THEN
            MSGBOX "Error linking  to CPP Client "+STR$(ERR)
        END IF
    END FUNCTION
    The include file is as follows:

    Code:
    ' ------------------------------------------------------------
    ' Library Name:      teCPPClient 2.0
    ' Library File:      C:\IMPRINT\teCPPClient.DLL
    ' ------------------------------------------------------------
    ' Version Info:
    ' -------------
    ' File Version:      2.02
    ' Internal Name:     teCPPClient
    ' Original Filename: teCPPClient.dll
    ' Product Name:      teCPPClient
    ' Product Version:   2.02
    ' ------------------------------------------------------------
    ' ProgID:            teCPPClient.clsConnect
    ' Interface Name:    teCPPClientclsConnect
    '
    ' Interface Prefix:  teCPPClient
    ' ------------------------------------------------------------
    
    $PROGID_teCPPClientclsConnect = "teCPPClient.clsConnect"
    
    
    'Enumeration eSecurityLevel
    MACRO enumteCPPClienteSecurityLevel = LONG
    %High                                                   = &H00000000
    %Low                                                    = &H00000001
    
    
    INTERFACE DISPATCH teCPPClientclsConnect
        MEMBER LET UseHTTP<&H68030015>()   'Parameter Type As Long
        MEMBER GET UseHTTP<&H68030015>() AS LONG
        MEMBER LET STATUS<&H68030014>()   'Parameter Type As String
        MEMBER GET STATUS<&H68030014>() AS STRING
        MEMBER CALL SEND<&H60030016>(OPTIONAL IN Request AS STRING<&H00000000>)
        MEMBER LET SecurityLevel<&H68030013>()   'Parameter Type As enumteCPPClienteSecurityLevel
        MEMBER GET SecurityLevel<&H68030013>() AS enumteCPPClienteSecurityLevel
        MEMBER LET ProxyPassword<&H68030012>()   'Parameter Type As String
        MEMBER GET ProxyPassword<&H68030012>() AS STRING
        MEMBER LET ProxyUsername<&H68030011>()   'Parameter Type As String
        MEMBER GET ProxyUsername<&H68030011>() AS STRING
        MEMBER GET Response<&H68030010>() AS VARIANT
        MEMBER GET ContentType<&H6803000F>() AS STRING
        MEMBER LET Request<&H6803000E>()   'Parameter Type As String
        MEMBER GET Request<&H6803000E>() AS STRING
        MEMBER LET ProxyPort<&H6803000D>()   'Parameter Type As Integer
        MEMBER GET ProxyPort<&H6803000D>() AS INTEGER
        MEMBER LET Proxy<&H6803000C>()   'Parameter Type As String
        MEMBER GET Proxy<&H6803000C>() AS STRING
        MEMBER LET URL<&H6803000B>()   'Parameter Type As String
        MEMBER GET URL<&H6803000B>() AS STRING
    END INTERFACE
    Any clues at to what I'm not doing or doing wrong that could be causing the object not to load? Or the best way to start trying to debug this.

    Nick

  • #2
    Have you tried to prototype it in VB6 ?

    I often do this with new projects to double check that the tlb is OK as I am not a COM expert.

    Bob

    Comment


    • #3
      No, not tried that yet - don't really like to use MS products unless I have to

      The DLL was written by a third party in VB6, I don't have a copy of that to try a prototype but I could try a .NET program - not all that experienced with .NET tending to use PB or PHP only.

      Nick

      Comment


      • #4
        I have just looked at one of my recent programs - seem to start the program a different way :

        Code:
        LET myInDesign = NEW DISPATCH IN "InDesign.Application.CS3"
        IF ISFALSE ISOBJECT(myInDesign) THEN
            MSGBOX "Not there!"
        END IF
        Just realised I am linking to a full program so the above may not mean anything - sorry!

        Bob
        Last edited by Robert Wallace; 2 Jul 2009, 07:35 AM.

        Comment


        • #5
          Thanks Robert, that's a late bound example you have posted where I have used early binding. Neither method works unfortunately

          Nick

          Comment


          • #6
            Compiler version not shown, but in 9x "NEW" is, well, "old" ....

            LET objvar = NEWCOM ProgID$
            LET objvar = GETCOM ProgID$
            LET objvar = ANYCOM ProgID$

            ...
            Previous versions of PowerBASIC Compilers supported another syntax for the
            creation of objects:

            LET objvar = [NEW] Interface name ON ClassName|ProgID$

            While this syntax will still be temporarily supported for the sake of compatibility, it will be removed in the next major release of PowerBASI
            ...
            But I can't believe that is your problem.
            Last edited by Michael Mattias; 2 Jul 2009, 07:47 AM.
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Yep, sorry forgot that one! I'm using 8.04, we still have a few variable name clashes with new reserved words in version 9.

              My main question is what could cause the object not to load and how do I go about debugging that. I'm on Vista if that causes any issues such as me thinking the DLL is registered but Windows thinking otherwise...

              Comment


              • #8
                As this is a VB DLL or exe go to Jose's forum and download his TLB etc. Has fixed similar problems for me using PB 8
                Later
                Actually I open them with
                LET oCPPClient = NEW teCPPClientclsConnect IN "teCPPClientclsConnect"
                instead of
                LET oCPPClient = NEW teCPPClientclsConnect IN $PROGID_teCPPClientclsConnect

                hope that helps
                Last edited by John Petty; 2 Jul 2009, 12:15 PM.

                Comment

                Working...
                X