>Something like this I guess:
>void MailAttachments::GetAttachmentBinary(MAPICDO::Attachment*
>pAttachment, Byte b[])
...
> b = attachmentArray;
You have to make b an output parameter if you want to return something
with it.
> IStream* streamUnk = NULL;
I assume you actually assign a valid pointer to streamUnk before
calling Read on it.
> //now i need to get the IStream into my Byte[] and return to c#
> hr = streamUnk->Read(attachmentArray, attSize, (ULONG*)&attSize);
>\\doesn't compile obviously
Try something like
Byte __pin* p = &attachmentArray[0];
hr = streamUnk->Read(p, attSize, (ULONG*)&attSize);
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Chris Capson - 09 Jun 2005 02:55 GMT
Thanks for the Information.
Another question related to this is how do I return a Byte array in C++
as an output? In C# I can do this
Calling application (C#)
{
byte[] attByteArray=null;
test.GetAttachmentBinary(attachment, ref attByteArray);
}
C# Method that would return my Byte Array information.
public void GetAttachmentBinary(MAPICDO::Attachment pAttachment, ref
byte[] AttachmentData)
{
...
}
How do I do the same in C++? I want to have my calling Application be
the same C# application. But I want my GetAttachmentBinary method to be
in C++ .NET. How Would I define my C++ method so that it would return
the byte[]?
Obviously this won't work but it is what I want to do.
public void GetAttachmentBinary(MAPICDO::Attachment* pAttachment, out
byte[] AttachmentData)
{
...
Byte attachmentArray[] = new Byte[attSize];
Byte __pin* p = &attachmentArray[0];
hr = streamUnk->Read(p, attSize, (ULONG*)&attSize);
AttachmentData = attachmentArray;
}
Once again your help is greatly appreciated on this.
Thanks
Chris
> >Something like this I guess:
> >void MailAttachments::GetAttachmentBinary(MAPICDO::Attachment*
[quoted text clipped - 25 lines]
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.
Mattias Sjögren - 13 Jun 2005 21:31 GMT
>How do I do the same in C++? I want to have my calling Application be
>the same C# application. But I want my GetAttachmentBinary method to be
[quoted text clipped - 4 lines]
>public void GetAttachmentBinary(MAPICDO::Attachment* pAttachment, out
>byte[] AttachmentData)
I can never quite remember the MC++ syntax but I believe it's
something like
void GetAttachmentBinary(MAPICDO::Attachment* pAttachment, [Out] Byte
(*AttachmentData)[] )
assuming you have
using namespace System;
using namespace System::Runtime::InteropServices;
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.