Need help to return string value from COM
-
I'm trying to create a .dll using ATL, which I want use in C#. Can anybody please guide me to create a simple method / function which takes string in input parameters and returns the same(string).. I tried a lot but always faced problem of returing string back to calling function in C#. I did the same with C++ class library successfully but when it comes to ATL its not the same. As I'm using other SDK API's in creation of .dll and I can't go with Class Library its having problem with "CLR and MTd". Which can't go together. Finally I decided to stick to ATL. Now please guide me to create the methods which I can use in C# to get the string value. Arun
-
I'm trying to create a .dll using ATL, which I want use in C#. Can anybody please guide me to create a simple method / function which takes string in input parameters and returns the same(string).. I tried a lot but always faced problem of returing string back to calling function in C#. I did the same with C++ class library successfully but when it comes to ATL its not the same. As I'm using other SDK API's in creation of .dll and I can't go with Class Library its having problem with "CLR and MTd". Which can't go together. Finally I decided to stick to ATL. Now please guide me to create the methods which I can use in C# to get the string value. Arun
IDL defenition will be:
[id(1), helpstring("your atl method signature")] HRESULT YourATLMethod( [out,retval] BSTR* ReturnString);
and the C++ implimentation signature will be:STDMETHODIMP CYourClass::YourATLMethod(BSTR* ReturnString) { _bstr_t bstrReturnstring = _T("some string here"); *ReturnString = bstrReturnstring ; return S_OK; }
cheers..milton kb.