How do you publish an object?

Publishing an object means making it available for access and use by other applications through the facilities of the COM Services of Windows.  With some compilers, this requires pages upon pages of code.  With PowerBASIC, you'll find it's fairly straightforward. Just add a Class Id (CLSID) GUID and the words "AS COM" to the end of the CLASS statement.  Then, add an Interface ID (IID) to the end of the INTERFACE statement.  Believe it or not, that's just about it!

$MyClassGuid = GUID$("{00000099-0000-0000-0000-000000000008}")
$MyIfaceGuid = GUID$("{00000099-0000-0000-0000-000000000009}")

CLASS MyClass $MyClassGuid AS COM
  INTERFACE MyInterface $MyIfaceGuid
    INHERIT IAutomation
    METHOD Method1(parm AS LONG)
      CALL abc(parm)

PowerBASIC handles all the messy details of COM for you.  The name of the CLASS (in this case MyClass) will be used as the ProgID for COM registration of the DLL.  The GUID's you selected will be used for the CLSID and IID, so you're ready to go...


See Also

What is an object, anyway?

Just what is COM?

What is a COM component?

How are GUID's used with objects?