- Joined
- Jun 16, 2009
- Messages
- 1
- Reaction score
- 0
I have written a COM DLL which gives the
out parameter as BSTR**(Typically 2D Char Array).
This COM function will fill the values of BSTR** variable.
I am able to use this function sucessfully in MFC Application.
But I face problem in using it in C#.
The Sample code is as follows:
///////////COM Function////////////////////////////////////////
STDMETHODIMP CSampleTest::GetAllDeviceList2(BSTR** szMaclist)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
for(int i=0;i<10;i++)
{
szMaclist = new BSTR[100];
wchar_t *szTmp = new wchar_t[100];
wsprintf(szTmp,L"Device%d",i+1);
*szMaclist=SysAllocString(szTmp);
}
return S_OK;
}
///////////////////////////////////////////////////////////////
I acessed this in VC++ by,
BSTR **szMaclist = new BSTR*[10];
CoInitialize(NULL);
HRESULT hr = CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,iid,(void**)&pText);
if( SUCCEEDED(hr) )
{
pText->GetAllDeviceList2(szMaclist);
pText->Release();
}
and i am sucessful in acessing this function in MFC Application.
Can anyone tell me how to acess this GetAllDeviceList2() function in c#.
If there is any alternative please let me know.
out parameter as BSTR**(Typically 2D Char Array).
This COM function will fill the values of BSTR** variable.
I am able to use this function sucessfully in MFC Application.
But I face problem in using it in C#.
The Sample code is as follows:
///////////COM Function////////////////////////////////////////
STDMETHODIMP CSampleTest::GetAllDeviceList2(BSTR** szMaclist)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
for(int i=0;i<10;i++)
{
szMaclist = new BSTR[100];
wchar_t *szTmp = new wchar_t[100];
wsprintf(szTmp,L"Device%d",i+1);
*szMaclist=SysAllocString(szTmp);
}
return S_OK;
}
///////////////////////////////////////////////////////////////
I acessed this in VC++ by,
BSTR **szMaclist = new BSTR*[10];
CoInitialize(NULL);
HRESULT hr = CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,iid,(void**)&pText);
if( SUCCEEDED(hr) )
{
pText->GetAllDeviceList2(szMaclist);
pText->Release();
}
and i am sucessful in acessing this function in MFC Application.
Can anyone tell me how to acess this GetAllDeviceList2() function in c#.
If there is any alternative please let me know.