Re: EuCOM : Attn Matt : String Return Value
- Posted by Matt Lewis <matthewwalkerlewis at g?ail.?om> Oct 02, 2007
- 691 views
Rad wrote: > > }}} <eucode> pBstr = invoke( OC6, {OneCryptA_m_EncryptString}, {alloc_bstr(OW6AppId), alloc_bstr(OCString)}, {VT_BSTR, VT_BSTR}, DISPATCH_METHOD ) void = message_box("Input String = " & OCString & "\n" & "pBstr = " & sprintf("%d", pBstr), "msg", MB_ICONINFORMATION) setText(EditText19, peek_bstr(pBstr)) </eucode> {{{ > > Whatever be the value of EditText18, pBstr always comes back with fixed value > 2147614729. > And following error is generated at the syntax line of setText(EditText19, > peek_bstr(pBstr))- This is actually an error code. Try putting:
com_err_out( 1 )
Somewhere above this call. You should get an error message (which might or might not be helpful). The method might want named parameters, in which case you could change the call into:
pBstr = invoke( OC6, {OneCryptA_m_EncryptString, 1, 2}, {alloc_bstr(OW6AppId), alloc_bstr(OCString)}, {VT_BSTR, VT_BSTR}, DISPATCH_METHOD )
> I tried to get the return value in a sequence but got type mismatch error. > > How to get a String as return value for this method? If the method is successful, it should return it as a sequence. invoke() will convert the return variant to the appropriate data type automatically, but you do have to check for errors. Note that com_err_out() can be redirected to a routine_id so that you can do custom error handling. Also (you probably know this, and it's just for expediency in getting it working, but...) calling alloc_bstr() inside the call to invoke will leak memory, because you don't have the pointer around to call free_bstr(). Matt