' Interface Demo — COM QueryInterface via DECLARE
#COMPILE EXE
#DIM ALL

DECLARE FUNCTION CoInitialize LIB "OLE32.DLL" (BYVAL pvReserved AS LONG) AS LONG
DECLARE FUNCTION CoUninitialize LIB "OLE32.DLL" () AS LONG
DECLARE FUNCTION CoCreateInstance LIB "OLE32.DLL" (BYREF rclsid AS LongPtr, BYVAL pUnkOuter AS LONG, BYVAL dwClsContext AS LONG, BYREF riid AS LongPtr, BYREF ppv AS LongPtr) AS LONG

%CLSCTX_INPROC_SERVER = 1

FUNCTION PBMAIN() AS LONG
    PRINT "COM Interface via DECLARE:"
    PRINT "1. CoInitialize(0)"
    PRINT "2. CoCreateInstance(clsid, ...) -> pUnk"
    PRINT "3. pUnk->QueryInterface(riid, &ppv)"
    PRINT "4. Call interface methods via vtable"
    PRINT "INTERFACE/OBJECT CALL in native PB"
    PRINT "See com_guid.pb for GUID generation"
    FUNCTION = 0
END FUNCTION
