Author Topic: COM object calling notation - Program Inentifier  (Read 2033 times)

0 Members and 1 Guest are viewing this topic.

Offline Ramesh Chandra

  • Newbie
  • *
  • Posts: 1
COM object calling notation - Program Inentifier
« on: February 17, 2011, 09:00:24 AM »
Code: [Select]
#COMPILE DLL
#DIM ALL
#RESOURCE "TestCom.pbr"  '

$LIBID = GUID$("{45F73B17-D4DD-474E-B6F6-87518643955F}")
$CLSID = GUID$("{F51D93D8-ABEB-4108-853B-A2FEEC630EC2}")
$IID = GUID$("{8C796C42-0442-4E0E-8F5C-839B8E450BAF}")

#COM DOC "Test COM created with PowerBASIC "
#COM NAME "TestCom", 1.10
#COM GUID $LIBID
#COM TLIB ON

%USEMACROS=1
#INCLUDE "Win32Api.inc"

CLASS PBClass $CLSID AS COM

   INSTANCE idVal1 AS DWORD
   INSTANCE idVal2 AS DWORD

   CLASS METHOD CREATE ALIAS "Create"()
      idVal1 = 1
      idVal2 = 2
   END METHOD

   INTERFACE PBInt $IID
      INHERIT IUNKNOWN

      PROPERTY GET Val1 ALIAS "Val1" AS DWORD
         PROPERTY = idVal1
      END PROPERTY

      PROPERTY SET Val1 ALIAS "Val1" (BYVAL inVal AS DWORD)
         idVal1 = inVal
      END PROPERTY

      PROPERTY GET Val2 ALIAS "Val2" AS DWORD
         PROPERTY = idVal2
      END PROPERTY

      PROPERTY SET Val2 ALIAS "Val2" (BYVAL inVal AS DWORD)
         idVal2 = inVal
      END PROPERTY

      METHOD SumVals ALIAS "SumVals" AS DWORD
         METHOD = idVal1 + idVal2
      END METHOD

      METHOD ResetVals ALIAS "ResetVals"
         Me.Create
      END METHOD

      METHOD Num2String ALIAS "Num2String"(BYVAL inVal AS DWORD) AS STRING
         METHOD = UCODE$(FORMAT$(inVal))
      END METHOD

      METHOD ClearVals ALIAS "ClearVals"
         idVal1 = 0: idVal2 = 0
      END METHOD
   END INTERFACE

END CLASS

GLOBAL ghInstance AS DWORD
FUNCTION LIBMAIN (BYVAL hInstance   AS LONG, _
                  BYVAL fwdReason   AS LONG, _
                  BYVAL lpvReserved AS LONG) AS LONG

    SELECT CASE fwdReason
        CASE %DLL_PROCESS_ATTACH
            ghInstance = hInstance
            FUNCTION = 1   'success!
        CASE %DLL_PROCESS_DETACH
            FUNCTION = 1   'success!
        CASE %DLL_THREAD_ATTACH
            FUNCTION = 1   'success!
        CASE %DLL_THREAD_DETACH
            FUNCTION = 1   'success!
    END SELECT
END FUNCTION

From  vb / vbscript,

I want to call like
dim obj
set obj=createObject("TestCom.PbClass") instead of
set obj=createObject("PbClass") .

other words,
I need like to use
createObject("Progname.Class")
NOT in this format
createObject("Class")

How do I achieve that? Anything need to specify in the COM declaration?

Please help me,

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 3126
  • Gender: Male
    • José Roca Software
Re: COM object calling notation - Program Inentifier
« Reply #1 on: February 17, 2011, 03:40:33 PM »
 
PB does not use the doted notation when it builds the type library. You will need to use the MIDL compiler to build your type library.