The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: askm on February 15, 2006, 04:03:37 AM

Title: com
Post by: askm on February 15, 2006, 04:03:37 AM
If you reference from the Ernest's mycom2 example

    mov (MyCom2ObjData ptr [edx]).m_Value, eax

it works there.

But how do you get a string into it

It wont let u use ADDR or offset
says 'invalid operand' or
says 'expression expected'

how many ways to get a string buffer into it w'out error msg ?

I have put bstr into the idl,tlb as referenced elsewhere, taken out 'long'

Is SetValue a method or just arbitrary
Do I need SetText where it would be ' mycom3.Text = "abc" ' ?

askm
Title: Re: com
Post by: donkey on February 16, 2006, 02:10:05 PM
Your string is probably local, in that case it is an invalid operand as it would assemble to a memory to memory move, try moving the string pointer into EAX then into the structure.
Title: Re: com
Post by: Tedd on February 16, 2006, 06:07:27 PM
lea eax,[the_string]
mov (MyCom2ObjData ptr [edx]).m_Value, eax


This is what ADDR usually produces for you anyway.
Title: Re: com
Post by: askm on February 17, 2006, 12:03:50 AM

Before, I simply copied/changed the proc names to SetStr & GetStr. OK

I used
    mov eax, DWORD ptr buffer
or
    lea eax, [buffer]
or
    lea eax, DWORD ptr [buffer]

and string not appearing in *.struct , eg. lea eax, (MyCom2ObjData ptr [edx]).struct

Ok I changed from/to
BSTR* Pstr / long* pStr (in *.idl/*.tlb)

and now shows 0.

ok
now I'm using lea on both the getstr and setstr ends

some progress

in vbs i get just ?????? or ?c????? or ?d????

in vb i get something like  ?b      ?À???ÿ??? ??? ??? etc
    and error like 'out of string space'


askm
Title: Re: com
Post by: tenkey on February 19, 2006, 04:44:13 AM
IIRC, BSTR strings passed back to VB should be allocated with SysAllocString.
Title: Re: com
Post by: zooba on February 19, 2006, 07:45:11 AM
Try using StrConv(string, vbUnicode) in VB.
Title: Re: com
Post by: askm on February 20, 2006, 03:32:16 AM
Are you all one-liners on this ?

I have it as ( [in] BSTR ...

The string is just not getting into the object.

Or its illegal operation.

Where are the two- and three- and four- and ... liners ?
Title: Re: com
Post by: zooba on February 20, 2006, 04:37:03 AM
From which end? Are you attempting to use the object from VB? Are you passing a string from VB and it's not showing up inside the object? Or are you passing a string from the object back to VB? I assume you're aware that a BSTR is a pointer to the second word of data?

The reason we're all one-liners is because we don't know what you're doing. Perhaps you could provide all of your code rather than snippets of lines which mean next-to-nothing on their own.
Title: Re: com
Post by: askm on February 20, 2006, 08:38:00 PM
Thanks.

OK I realize everyone is ahead of my curve on these matters 'cause ...

I've only taken the MyCom example, changed\added a few basics for string handling purpose.

I have ( [in] BSTR / [out] BSTR *ptr ) in (a getstring function, say like getvalue) the idl/tlb.
I've tried ([in] long / [out] long * ptr) and it seems I was getting something intelligible (out).
Which way is best ?

I want it to work in vb or vbscript.

Have you seen the strcat.dll, 'catter' thats avail for download. It's in C(++?).
It works both vb and vbscript. No 'illegal ops', errors? etc. Of course I havent
a need to fully test it.
It's OK. Could it be faster ? Faster than vbscript itself ?

So that's the interest. I know theres ways.

And why's certain bstr routine(s) in the masm folder limited to a 100-some length ?

So many questions, thats why I

askm
Title: Re: com
Post by: zooba on February 20, 2006, 10:18:10 PM
That's still not enough information. We need to be able to see if the code inside your GetString function is alright. We need to be able to see how you are using it in VB. We need to see a much larger chunk of the IDL file.

From what you've provided, I think BSTR is better than long, since that is your string format. However, it depends on everything I've asked for above :U
Title: Re: com
Post by: askm on February 20, 2006, 10:50:51 PM
Just tinkering with the MyCom2.idl made ...

// MyCom3.idl : IDL source for MyCom3.ocx (or dll)
//
import "oaidl.idl";
import "ocidl.idl";
[
   uuid(F8CE5E42-1135-11d4-A324-0040F6D487D9),
   helpstring("MyCom3 1.0 Type Library"),
   version(1.0)
]
library MyCom3Lib
{
   importlib("stdole32.tlb");
   [
      uuid(F8CE5E41-1135-11d4-A324-0040F6D487D9),
      dual,
      helpstring("IMyCom3 Dispatch Interface")
   ]
   interface IMyCom3 : IDispatch
   {
      [propget, id(0), helpstring("property Value")]
        HRESULT Value([out, retval] long *pVal);

      [ id(1), helpstring("property GetStr")]
        HRESULT GetStr([out, retval] BSTR* pStr);

      [propput, id(0), helpstring("property Value")]
        HRESULT Value([in] long newVal);

      [ id(3), helpstring("property SetStr")]
        HRESULT SetStr([in] BSTR newStr);

      [ id(4), helpstring("method Mid")]
        HRESULT SetMid([in] BSTR AddStr);

      [ id(5), helpstring("method to get the current length of the total string.")]
        HRESULT sLength([out, retval] long *pLal);
   };
   [
      uuid(F8CE5E43-1135-11d4-A324-0040F6D487D9),
      helpstring("MyCom3 Class")
   ]
   coclass MyCom3
   {
      [default] interface IMyCom3;
   }
}
//

That is the order that I have the methods in.

askm
Title: Re: com
Post by: askm on October 26, 2008, 04:46:44 PM
Just revisiting

I got sidetracked with this too

as I lost verion files when my Win 2000 crash in 06.

Those machines !@$%^ ... let you down.

RAID yours.

Title: Re: com
Post by: askm on October 26, 2008, 04:49:00 PM
Should read

as I lost version files when my Win 2000 crash in 06.