Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Need help to return string value from COM

Need help to return string value from COM

Scheduled Pinned Locked Moved COM
c++helpcsharpdotnetcom
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    agarunk
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • A agarunk

      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

      M Offline
      M Offline
      Milton Karimbekallil
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups