Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending byte[] from C# to C

Status
Not open for further replies.

1acer1

Programmer
Aug 14, 2003
14
0
0
CZ
hi,

need some help ;)

i have C# COM and C++ client and i want to get byte array from this COM (for getting string in utf8).

i tried this:
C#:
public void GetName(out byte[] name)
{
name = utf8.GetBytes(name);
}

C++:
...
SAFEARRAY* sa = NULL;
com->GetName(&sa);
...

- for initializing that SAFEARRAY i tried NULL, SafeArrayCreate() and SafeArrayAllocDescriptor() (all of them seem to work)
- i also tried to destroy that SAFEARRAY later with SafeArrayDestroy() or SafeArrayDestroyDescriptor(), but the application raised an exception

and finally the problem is that after a few calls of this function my client application freezes.

what's wrong, where's the problem?
(i am not very familiar with COM and SAFEARRAYs, so forgive me if it's total bullshit)

thanks much for any help
(or any idea for getting string to C++ in utf8 encoding??)

acer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top