Hello,
I posted this question already, but in the wrong newsgroup... so here again:
I have a COM interface which has the following method:
HRESULT Item(
[in] DWORD dwIndex,
[in] DWORD dwWhichName,
[in] DWORD cchLength,
[out,size_is(cchLength)] LPSTR pszName
);
When I create a Wrapper-Dll with midl.exe and tlbimp.exe, this method is
converted to:
public void Item ( System.UInt32 dwIndex , System.UInt32 dwWhichName ,
System.UInt32 cchLength , System.String pszName )
pszName is supposed to be a buffer, so obviously, this won't work. I've
already decompiled the dll I generated with ildasm, the result is this:
.method public hidebysig newslot abstract virtual
instance void Item([in] unsigned int32 dwIndex,
[in] unsigned int32 dwWhichName,
[in] unsigned int32 cchLength,
[out] string marshal( lpstr) pszName)
runtime managed internalcall
My question is: How do I need to modify this so that pszName becomes a
buffer that can be filled by the called method?
Some time ago I read something about using a StringBuilder... but I lost the
link.
Any ideas?
Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)
Ajit - 24 Jun 2005 18:56 GMT
Instead of using string use long and pass address of string. Use Marshalling
to manipulate the address to get back buffer.
Regards,
Ajit
> Hello,
>
[quoted text clipped - 38 lines]
> Try my free Exchange Explorer: Mistaya
> (http://www.infinitec.de/software/mistaya.aspx)
Henning Krause [MVP - Exchange] - 26 Jun 2005 15:12 GMT
Hello,
if anyone has a similar problem, here is a possible solution:
.method public hidebysignewslot abstract virtual instance void Item(
[in] unsigned int32 dwIndex,
[in] unsigned int32 dwWhichName,
[in] unsigned int32 chLength,
class [mscorlib]System.Text.StringBuilder marshal( lpstr) pszName)
runtime managed internalcall
Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)
> Instead of using string use long and pass address of string. Use
> Marshalling
[quoted text clipped - 47 lines]
>> Try my free Exchange Explorer: Mistaya
>> (http://www.infinitec.de/software/mistaya.aspx)