News:

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

com

Started by askm, February 15, 2006, 04:03:37 AM

Previous topic - Next topic

askm

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

donkey

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.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Tedd

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


This is what ADDR usually produces for you anyway.
No snowflake in an avalanche feels responsible.

askm


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

tenkey

IIRC, BSTR strings passed back to VB should be allocated with SysAllocString.
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8

zooba

Try using StrConv(string, vbUnicode) in VB.

askm

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 ?

zooba

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.

askm

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

zooba

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

askm

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

askm

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.


askm

Should read

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