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. C#
  4. com object, [out] params (pointers to values), C#

com object, [out] params (pointers to values), C#

Scheduled Pinned Locked Moved C#
questioncsharpc++com
5 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
    alma
    wrote on last edited by
    #1

    I have a COM object written in C++. I want to use it from C#. For getting values out of the COM object I used functions like: HRESULT myfunction (/*[out]*/ BSTR* stringvalue, /*[out]*/ int* intvalue); How can I use these functions from c#? -Alma-

    A 1 Reply Last reply
    0
    • A alma

      I have a COM object written in C++. I want to use it from C#. For getting values out of the COM object I used functions like: HRESULT myfunction (/*[out]*/ BSTR* stringvalue, /*[out]*/ int* intvalue); How can I use these functions from c#? -Alma-

      A Offline
      A Offline
      Alexander Kojevnikov
      wrote on last edited by
      #2

      After you add a reference to your COM dll you will see the IntelliSence info for its COM objects. Also, you could just go to the Object Browser and check how the syntax looks like. Your function will probably translate into this: void myfunction(ref string stringvalue, ref int intvalue); Alexandre Kojevnikov MCAD charter member Leuven, Belgium

      A 1 Reply Last reply
      0
      • A Alexander Kojevnikov

        After you add a reference to your COM dll you will see the IntelliSence info for its COM objects. Also, you could just go to the Object Browser and check how the syntax looks like. Your function will probably translate into this: void myfunction(ref string stringvalue, ref int intvalue); Alexandre Kojevnikov MCAD charter member Leuven, Belgium

        A Offline
        A Offline
        alma
        wrote on last edited by
        #3

        In the object browser my functions syntax looks this way: HRESULT _stdcall MyGetValue([out] int* value); IntelliSence info looks like this: void MyGetValue(out int value); whatever I put as a parameter it results in an error: The best overloaded method match for 'MYComObjectDllLib.IMyObject.MyFunction(out int)' has some invalid arguments -Alma-

        A 1 Reply Last reply
        0
        • A alma

          In the object browser my functions syntax looks this way: HRESULT _stdcall MyGetValue([out] int* value); IntelliSence info looks like this: void MyGetValue(out int value); whatever I put as a parameter it results in an error: The best overloaded method match for 'MYComObjectDllLib.IMyObject.MyFunction(out int)' has some invalid arguments -Alma-

          A Offline
          A Offline
          Alexander Kojevnikov
          wrote on last edited by
          #4

          The calling code should look like this:

          int myValue;
          myCOMObject.MyGetValue(out myValue);

          Alexandre Kojevnikov MCAD charter member Leuven, Belgium

          A 1 Reply Last reply
          0
          • A Alexander Kojevnikov

            The calling code should look like this:

            int myValue;
            myCOMObject.MyGetValue(out myValue);

            Alexandre Kojevnikov MCAD charter member Leuven, Belgium

            A Offline
            A Offline
            alma
            wrote on last edited by
            #5

            Yes, that works! Thanks a lot!:) -Alma-

            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