News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

The more simple way to use existing COM

Started by ToutEnMasm, June 17, 2005, 12:53:16 PM

Previous topic - Next topic

ToutEnMasm

Hello,
I have modify the coinvoke macro,in the masm32 package,and I obtain a very simple syntaxe like that:

IShellLink QueryInterface,ADDR IID_IPersistFile,ADDR ppvIPersistFile

and when all is finish:

IShellLink Release

Explain:
There is one macro by interface.I use name convention like that:
                  If the interface is call            NameInterface
                  The interface pointer is        ppvNameInterface
                  The structure of proto is      STNameInterface

To make a new macro for a new interface , only change all of the Nameinterface by NewInterface in the new MACRO
You must respect this convention or modify the macro.

Here is a sample:

pcomethod1      TYPEDEF PROTO :DWORD
pcomethod2      TYPEDEF PROTO :DWORD, :DWORD
;/////////////////////////////////
comethod1           TYPEDEF PTR pcomethod1
comethod2           TYPEDEF PTR pcomethod2

STIShellLink         STRUCT
   ;   Iunknown  proto
    QueryInterface       comethod3 ?
    AddRef          comethod1 ?
    Release          comethod1 ?   
    ;------------- IShellLink proto
    GetPath                  comethod5 ?
    GetIDList                comethod2 ?
    SetIDList                comethod2 ?
;/////////////////////////////////////////////////
    GetIconLocation          comethod4 ?
    SetIconLocation          comethod3 ?
    SetRelativePath          comethod3 ?
    Resolve                  comethod3 ?
    SetPath                  comethod2 ?
STIShellLink        ENDS   


IShellLink MACRO  Function:REQ, args:VARARG
       LOCAL InvokeInterface, arg
    FOR arg, <args>     ;verifier que edx n'est pas dans la liste d'arguments args
        IFIDNI <&arg>, <edx>   ;
            .ERR <edx is not allowed as a coinvoke parameter>
        ENDIF
    ENDM

    IFIDNI <&pInterface>, <edx>
        .ERR <edx is not allowed as parameter>
    ENDIF
   
   ;---------- edx is not used , create  -----------------------------------
    InvokeInterface CATSTR <invoke (STIShellLink PTR[edx]).>,<&Function,ppvIShellLink>
    IFNB <args>     ; add the list of parameter arguments if any
        InvokeInterface CATSTR InvokeInterface, <, >, <&args>
    ENDIF
   ;
    mov edx, ppvIShellLink
    mov edx, [edx]
    InvokeInterface
ENDM   

Don't forget to call
invoke CoCreateInstance, ADDR CLSID_ShellLink, NULL,CLSCTX_INPROC_SERVER,\         ADDR IID_IShellLink,ADDR ppvIShellLink

                    a+
                                ToutEnMasm