Re: EuCom - Matt Lewis

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jonas Temple wrote:
> 
> > The "Set " here indicates that you need to use DISPATCH_PROPERTYPUTBYREF
> > (according to my FAQ that I just reread :).
> 
> I assume you meant DISPATCH_PROPERTYPUTREF, right?  That's what I used.

Yep. :)

> Here's the code that I got to work:
include cwbx.ew
with trace
without warning

integer cwb_cmd, as400_system, errors
atom void, sys_ptr, ptr, err_count

com_err_out(1)
trace(1)

cwb_cmd = create_com_object( Command_clsid_ix )
as400_system = create_com_object( AS400System_clsid_ix )

sys_ptr = alloc_bstr("DILBERT.MKG.COM")
void = invoke(as400_system,
{AS400System_m_Define},{sys_ptr},{VT_BSTR},DISPATCH_METHOD)
void = invoke(cwb_cmd,
{Command_p_system,DISPID_PROPERTYPUT},{get_obj_this(as400_system)},
	{VT_UNKNOWN},DISPATCH_PROPERTYPUTREF)

ptr = alloc_bstr("SNDMSG MSG('This is a test') TOUSR(JOTEMPL)")
void = invoke(cwb_cmd, {Command_m_Run},{ptr},{VT_BSTR},DISPATCH_METHOD)
errors = ref_com_object(Errors_clsid_ix, invoke(cwb_cmd, {Command_p_Errors}, {},
{},
	DISPATCH_PROPERTYGET))

err_count = invoke(errors, {Errors_p_Count}, {}, {}, DISPATCH_PROPERTYGET)

free_bstr(sys_ptr)
free_bstr(ptr)
release_com() 


> Using DISPID_VALUE gave me a "Parameter not found" error from the object.
> I removed DISPID_VALUE and got the same result.  It finally worked when
> I changed it to DISPID_PROPERTYPUT.  Don't ask me how I figured that out,
> I just got lucky.  Why did that work instead of DISPID_VALUE?  

I think it depends on how the object was built.  That's really a named 
parameter.  Have you seen VB code, for instance, where parameters are 
named, like:

myObject.myMethod thisParam:=1, thatParam:="a"

This is what you're doing, except that it's a 'special' name that's being
used.  Something like VB would take care of this for you automatically,
but EuCOM and I aren't that smart.
 
> Also, I looked at the EuCom docs and wondered how do I know when to use
> the {this,vtbl} obj parm for the invoke routine versus just the object?  
> Maybe I'm not reading the docs correctly or it's just my lack of COM/ActiveX
> knowledge.

You can use the {this,vtbl} way of doing things if you're working directly
with the pointers, instead of a EuCOM index.  I've found that sometimes,
I'm creating and destroying lots of little 'helper' objects--take a look
at tbrowse, if you dare.  It's sometimes quicker and easier to not have 
to make lots of calls to ref_com_object().  It is also a little quicker,
since EuCOM has to look up these values from a table before it can make
the call, so another reason to use it is if you want to speed something 
up (although the gain is likely to be miniscule, unless you make lots of
calls, and then you're probably better off calling a real interface, 
rather that the DispInterface).

Some of your difficulties are undoubtedly due to lack of COM experience
on your part, and the rest is assuredly my lack of COM experience and
my mediocre documentation skills (plus other included 'features' and 
real missing features of EuCOM).

> Thanks for the assistance!  I'll definitely have more questions.

I'll definitely have more answers.  If we're lucky, they'll be correct!

Matt Lewis

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu