Hi,
i want to transmit a string from a C++-COM-DLL to C#. I wrote this
code:
STDMETHODIMP CWinpcap::hrGetAdapterNameFromAdapterNumber(int
iAdapterNumber, BSTR * AdapterName)
{
int index = 1;
dev = alldevs;
CComBSTR bstr = A2BSTR(dev->name);
*AdapterName = bstr.Copy();
return S_OK;
}
in VCC6. Then i generate the DLL and use tlbimp to generate a Wrapper
for C#.
In C# i use this code:
int nr = 0;
string sAdapterName = null;
WINPCAP_COM_ZUGRIFFLib.WinpcapClass wpcap = new
WINPCAP_COM_ZUGRIFFLib.WinpcapClass();
wpcap.hrGetNumberOfAdapters(ref nr);
wpcap.hrGetAdapterNameFromAdapterNumber(1,ref sAdapterName);
But when debugging in C#, sAdapterName is always empty. When i debug
the C++-DLL, i can see, that AdapterName points to the first character
of the BSTR.
Does anybody know what i made wrong?
Thanks for your help
Volker Kugler