News:

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

How do I call a COM DLL from MASM32?

Started by axtens, June 19, 2007, 06:57:43 AM

Previous topic - Next topic

axtens

What tools are there for doing a COM call from MASM? There doesn't seem to be much out there that is recent, except perhaps for ObjAsm32, but its examples aren't meeting me where I need help.

I've already got a MASM32-coded DLL and I'm trying to add to it a call or two to a COM DLL I wrote a while back.

Any clues, anyone?

Kind regards,
Bruce.

hutch--

Bruce,

I am sorry I am not much use to you but I avoid COM intentionally. What you need to be able to do is work out what the interface is to the COM object(s) you have written in another language so you can then write the calling code to call your own DLL. I know of them in Delphi, VC and VB and from memory there are a couple of different interfaces that can be used. The more you know about the DLL you have written the more chance you have of being able to use it from MASM or similar.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

axtens

Okay, well COMView says this:


;--- Generated .INC file by COMView
;--- typelib name=COMlibiconv
;--- documentation=COMlibiconv Library
;--- GUID={55B7D56A-C63A-4B39-9833-A2925972CA96}
;--- Version 1.0, LCID 0

;--- prototypes too complex for MASM may exist
;--- if such ones reside in a vtable they will be replaced by dummies
;--- search for occurances of ';+++' to have a closer look at these

sTLBID_COMlibiconv textequ <GUID {055B7D56Ah,0C63Ah,04B39h,{098h,033h,0A2h,092h,059h,072h,0CAh,096h}}>
_MajorVer_COMlibiconv equ 1
_MinorVer_COMlibiconv equ 0

;--- IConverters, Type=INTERFACE, GUID={8DD3E3E3-5DF7-4BA8-8C00-2D22DEFF8190}

ifndef IConvertersVtbl
BEGIN_INTERFACE IConverters, IDispatch
STDMETHOD ConvertToUnicode , :BSTR,:BSTR,:SDWORD,:SDWORD,:ptr VARIANT
STDMETHOD get_ErrorCode , :ptr SDWORD
STDMETHOD get_Success , :ptr BOOL
STDMETHOD get_Count , :ptr SDWORD
STDMETHOD Aliases , :SDWORD,:ptr VARIANT
STDMETHOD CNames , :SDWORD,:ptr VARIANT
STDMETHOD AliasKeys , :ptr VARIANT
STDMETHOD AliasDictionary , :ptr VARIANT
STDMETHOD get_ErrorString , :ptr VARIANT
STDMETHOD ConvertToMultibyte , :BSTR,:BSTR,:SDWORD,:SDWORD,:ptr VARIANT
STDMETHOD CheckConversion , :BSTR,:BSTR,:SDWORD,:BOOL,:ptr VARIANT
STDMETHOD get_CharactersConsumed , :ptr SDWORD
STDMETHOD get_CharactersGenerated , :ptr SDWORD
STDMETHOD GuessEncoding , :BSTR,:BOOL,:BSTR,:ptr VARIANT
STDMETHOD VariantConvertToUnicode , :BSTR,:VARIANT,:SDWORD,:SDWORD,:ptr VARIANT
STDMETHOD VariantConvertToMultibyte , :BSTR,:BSTR,:SDWORD,:SDWORD,:ptr VARIANT
STDMETHOD VariantCheckConversion , :BSTR,:VARIANT,:SDWORD,:BOOL,:ptr VARIANT
STDMETHOD VariantGuessEncoding , :VARIANT,:BOOL,:BSTR,:ptr VARIANT
STDMETHOD VariantConvertToMultibyteBuffered , :BSTR,:BSTR,:SDWORD,:SDWORD,:ptr VARIANT
STDMETHOD VariantConvertToMultibyteBuffer , :SDWORD,:ptr VARIANT
STDMETHOD IetfToUTF8 , :BSTR,:ptr VARIANT
STDMETHOD get_Logging , :ptr BOOL
STDMETHOD put_Logging , :BOOL
STDMETHOD IsEnc , :VARIANT,:ptr BOOL
STDMETHOD get_LogDirectory , :ptr VARIANT
STDMETHOD put_LogDirectory , :VARIANT
END_INTERFACE
endif

sIID_IConverters textequ <IID {08DD3E3E3h,05DF7h,04BA8h,{08Ch,000h,02Dh,022h,0DEh,0FFh,081h,090h}}>

;--- Converters, Type=COCLASS, GUID={0CF7C6A0-981D-4C2C-A74C-26DD713C22BE}

sCLSID_Converters textequ <GUID {00CF7C6A0h,0981Dh,04C2Ch,{0A7h,04Ch,026h,0DDh,071h,03Ch,022h,0BEh}}>

;--- end of type library ---


Where do I go from here??

With thanks,
Bruce.

jdoe


In the com folder of masm32 you will find informations about using COM with MASM.

These pages helped me a lot to know more about COM and how to use it. Very good links.

http://www.codeproject.com/com/comintro.asp
http://www.codeproject.com/com/comintro2.asp
http://www.massmind.org/techref/language/asm/masmwin/com/com_1.txt
http://www.massmind.org/techref/language/asm/masmwin/com/com_2.txt
http://yanaware.com/com4me/


Can you post more details about what you want to do.
Maybe looking in \MASM32\com\examples\shortcut will give an idea how to make a simple call.




axtens

I have looked at those without a lot of sense being made of it all. I am thick, I know.

The trouble with \MASM32\com\examples\shortcut is that it doesn't apply to my situation directly. the interfaces are already figured out and stored in oaidl.inc and shlobj.inc, whereas I'm still trying to find out how to generate the interface code and how to talk through it.

Kind regards,
Bruce.

drizz

Quote from: axtens on June 19, 2007, 07:41:11 AMWhere do I go from here??
i think it should be something like this:

.data
pv dd 0
clsid sCLSID_Converters
guidy sIID_IConverters
.code
invoke DllRegisterServer
invoke DllGetClassObject,offset clsid,offset guidy,offset pv
.if eax ==CLASS_E_CLASSNOTAVAILABLE
; Error
.else
??? invoke vf(This, Interface, Method),...
.endif
invoke DllCanUnloadNow
invoke DllUnregisterServer
i'm not an expert on the subject
The truth cannot be learned ... it can only be recognized.