Are there any examples of how to access say Excel or Word using COM with Masm32 (hutch's)?

Thanks
Posted on 2004-02-18 15:39:27 by StillLearning
Here is a sample using excel automation.
Posted on 2004-02-19 00:08:21 by japheth
Thank you for that link and code..I have not looked it over as of yet, but perhaps you can tell mw why I get this errors when I run your make from the Comview28 zip file



C:\Comview28\Webbrowser>make

Microsoft (R) Macro Assembler Version 7.00.9466
Copyright (C) Microsoft Corporation. All rights reserved.

Assembling: webbrowserapp.asm
oaidl.inc(24) : error A2004: symbol type conflict : PVOID
oaidl.inc(28) : error A2004: symbol type conflict : LPWSTR
shdocvwc.inc(29) : fatal error A1016: Internal Assembler Error
MacroLoop(1): iteration 0: Macro Called From
DEFINE_DISPMETHOD(11): Macro Called From
shdocvwc.inc(29): Include File
\masm32\include\resource.h(1229) : warning RC4005: 'IDC_EDIT1' : rede
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

LINK : fatal error LNK1181: cannot open input file "webbrowserapp.obj

C:\comview28\Webbrowser>


Again thanks for responding :alright:
Posted on 2004-02-19 00:36:09 by StillLearning
japheth:

Ok, I tried to assemble the ExcelHost and received these errors....

Same error types as the WebBrowser Errors


Win2K
Excel 97
Masm32v8sp1 Hutch's
RadAsm IDE


Assembling: ExcelHost.asm
oaidl.inc(20) : error A2004: symbol type conflict : PVOID
oaidl.inc(24) : error A2004: symbol type conflict : LPWSTR
excel.inc(1595) : error A2008: syntax error : EQU
excelc.inc(33) : fatal error A1016: Internal Assembler Error
DEFINE_DISPMETHOD(1): Macro Called From
excelc.inc(33): Include File

Make error(s) occured.


Are those dsw dsp files needed ( they are present) and can it be done without them.... If they are needed by all files how do a make them?

Inside the rc file is a reference to afxres.h I don't have this file

Nor do I have the NMake file needed to try using your .mak file

What is the correct procedure to correct the Comview output files that contain the ;+++ definitions?

Should one look at the ComView display and manually extend the definitions to the proper structure? Is it possible it correct them?


I sure need this to build cleanly as I ran the enclosed ExcelHost.exe and WOW......It got my tail wagging...........This my be the example I need!!!!!

Thanks again
Posted on 2004-02-19 01:17:06 by StillLearning
Hi,

possibly you are using MASM V8, which has some small incompatibilities. View http://www.japheth.de/masm32.html and download the package mentioned there.

Japheth
Posted on 2004-02-19 08:50:44 by japheth
Hi:

Yes, as stated in my second post I am using Masm32, which is what I thought your example code was made for.


Your code example is like a big piece of candy to me now.

It's the example that I really need to understand, but can't get it
to build cleanly.

The excelc.inc produces errors and I have no idea how to fix them.

excelc.inc ( Excel 8 ) built using comview28

Masm 7.00.9xxx

So no clean build

If I switch over to:

Masm 6.14xx

It assembles and reports no errors.

But the linker...

Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

ExcelHost.obj : error LNK2001: unresolved external symbol _IID_IUnknown
ExcelHost.exe : fatal error LNK1120: 1 unresolved externals

Make error(s) occured.

1). Why does Masm v7 not like the excelc.inc file?

2). How do a fix the linker problem, if a use Masm v6.14 to assemble it?

3). What is the correct procedure to correct the Comview output files that contain the ;+++ definitions?

Should one look at the ComView display and manually extend the definitions to the proper structure? Is it possible it correct them?


I really really appreciate your time and help in this matter.

Thank you.
Posted on 2004-02-19 16:47:55 by StillLearning
Hi,

1). Why does Masm v7 not like the excelc.inc file?

I dont know, will check it

2). How do a fix the linker problem, if a use Masm v6.14 to assemble it?

the public _IID_IUnknown is defined in UUID.LIB of MASM32 V7 (you have V8, which includes a crippled version of this library). As I have mentioned in my previous post, you can download some MASM32 V7 includes/libraries from my site, which will resolve this issue.

3). What is the correct procedure to correct the Comview output files that contain the ;+++ definitions?

same answer as to 1).

Japheth
Posted on 2004-02-19 23:55:40 by japheth
Hi:

I did download the different includes and built the new libs....

Didn't seem to help.

That's not saying I didn't make a mistake somewhere in the process.

Again I thank you for looking into it.
Posted on 2004-02-20 00:10:27 by StillLearning
Hi,

I had some problems with this sample as well because its so old.
The main problem is that this sample doesnt use include file DISPHLP.INC.
So I updated the include files and made some small changes to the source.

Just updated the new version on my site. Use the link from my first post.

With these modifications I had no problems with masm v615 and v700.
But you still need a proper version of UUID.LIB. If still errors occur during
the assembly step, you should post the generated includes in zipped format.

Japheth
Posted on 2004-02-20 01:22:54 by japheth
japheth:

Microsoft (R) Macro Assembler Version 7.00.9466
Copyright (C) Microsoft Corporation. All rights reserved.

Assembling: ExcelHost.asm
excelc.inc(77) : fatal error A1016: Internal Assembler Error
MacroLoop(1): iteration 0: Macro Called From
DEFINE_DISPMETHOD(11): Macro Called From
excelc.inc(77): Include File

Make error(s) occured.

If I comment out that line the error just continues down the file to the next line.

What is the version # of your Masm v7.???? Mine is 7.00.9466

Thanks...I think we are getting close.

P.S.

It does assemble and build under 6.14 - no problem.
Posted on 2004-02-20 02:58:26 by StillLearning
Hi,

regretably I used the same version, and I dont get any errors.

Japheth
Posted on 2004-02-20 05:19:15 by japheth
Hi:

ok,

Well I guess you can't fix what isn't broken on your end.

It sure is a beautiful example on accessing COM.

Thank you very much for all of your help.

The ;+++ 's inside the inc's are being caused by the fact that the Excel 8 dll carries many of the parms out to 30!


Any chance in Comview going out that far to caught them all?

Is there any setting in Comview for me to request parms be generated out that far?


Your example is a GREAT help, thanks again.
Posted on 2004-02-20 10:13:15 by StillLearning
Hi,


The ;+++ 's inside the inc's are being caused by the fact that the Excel 8 dll carries many of the parms out to 30!
Any chance in Comview going out that far to caught them all?


There is a MASM limitation of 30/31 parameters, so modifying comview wont help.

Japheth
Posted on 2004-02-20 12:22:20 by japheth
japheth:

I few questions.

Please understand I may not the using the correct COM usage or reference in my questions, but hopefully you get the idea.

1). How would this type of method be handled?

STDMETHOD OpenApplication , :BSTR,:ptr ptr dxoPApplication


2). If one call returns a ptr to another interface or dispatch then am I required to CoCreateInstance on this interface dispatch?


3). If the return is a ptr to another interface within the same dll, does the orginal CoCreateInstance handle that interface/dispatch?


Thank for you time.
Posted on 2004-02-25 14:32:46 by StillLearning
Hi,

to your questions:

1.)
local bstr:BSTR

invoke SysAllocString, addr wszString
mov bstr, eax
invoke vf(pObject, Ixxx, OpenApplication), bstr, addr pApplication

2.) No (how would you tell CoCreateInstance about your dispatch pointer?)

3.) Dont understand this question. If you get an Idispatch pointer, you can do with it
what you want. CoCreateInstance is just a wrapper for
- loading your dll
- calling DllGetClassObject (returns a class factory object)
- calling CreateInstance method of class factory (hopefully returns the object you want)
- releasing class factory
- calling QueryInterface on the object and returning this object
Posted on 2004-02-25 23:37:01 by japheth
Hi:

I'm back, I've been trying to work with your macros, with some success.

Can not get over a bump.


An external APP is sending into my dll code the IDispatch address of an Object.


How do I set this up in ASM to access the items of that dispatch.

CoCreateInstance always returns A class factory error.


If we assume this is the IUnknown of the dispatch, how would that be set up?




In PB if I do a setup such as:


Dim ThisObject as xxIThisObject ; references the Interface Dispatch definition


Set ThisObject = "Passed in dispatched pointer" ; dispatch pointer passed in by the external app


BINGO I have access


I understand that PB is doing the CO stuff, but what sequence is the proper ones in assembler?


If an Interface is COclass does this mean that both items can be referenced by one of the other names / or class?



Thanks
Posted on 2004-03-09 10:42:08 by StillLearning
Hi,

if you get an idispatch from outside you dont need cocreateinstance.

> Dim ThisObject as xxIThisObject
> Set ThisObject = "Passed in dispatched pointer"

vb doesnt do this either with the code above, it would call cocreateinstance only with

> Dim ThisObject as NEW xxIThisObject

So I would suggest you to post your code (partly).

Japheth
Posted on 2004-03-10 01:52:24 by japheth
Sorry, out of town no access


The code to do the same thing PB does is what I'm looking for.

Dim ThisObject as xxIThisObject

Set ThisObject = "Passed in dispatched pointer"


ok, so If I have a dispatch pointer, how do I use your Invoke vf() macro (as this is not a pointer to the unknown) to perform this:

Dim vTargetItemValue as Variant
Dim TargetItemValue as Double

Object Get ThisObject.TargetDouble = vTargetItemValue

TargetItemValue=Variant#(vTargetItemValue)

TargetItemValue will now contain a double prec value.


Thank you for your time and help on this.
Posted on 2004-03-21 14:37:56 by StillLearning
I hope to learn OOP because I need to communicate with excel, word and MsProject. I have downloaded you example ExcelHost.

When compiling your example there is a conflicting parameter definition in masm32 user32.inc file and Debugout.inc.
wsprintfA PROTO C :DWORD,:VARARG

wsprintf equ <wsprintfA>


Then I have a question. It takes a very long time to compile (appr 45 sek). I have not experienced such a long time before. The ExcelHost.obj file is 2.8 Mb. Is this significant for OOP projects?
Posted on 2004-03-22 09:19:04 by minor28