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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. COM
  4. Pass by Value or by Reference

Pass by Value or by Reference

Scheduled Pinned Locked Moved COM
csharpquestion
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.
  • N Offline
    N Offline
    normanordas
    wrote on last edited by
    #1

    Using P/Invoke how would i know that i should be passing "by value" or "by reference" to the arguments of a method or function of the DLL? 2. Equivalent type in .Net of the used data type for each variable (e.g what's the equivalent type of BSTR in VB.Net/C#? 3. In the type library it says: VARIANT_BOOL _stdcall NE_QueryElementByID( [in] long net, [in] ElementTypeEnum eltype, [in, out] IDAttRec* id, [in, out] HandleAttRec* h); This is the way i called it in VB.Net...is this correct? ... _ Public Shared Function NE_QueryElementByID(ByRef net As Long, ByRef eltype As ElementTypeEnum, ByRef id As IDAttRec, ByRef h As HandleAttRec) As Boolean End Function ... Dim h1 As HandleAttRec hi.Handle = 0 Dim id1 As IDAttRec Dim m_startid As Int32 = 4424 id1.UserID = 99 id1.LayerKey = 1 dim bol as Boolean = NE_QueryElementByID(net, ElementTypeEnum.NE_EDGE, id1, h1) Tnx a lot!

    M 1 Reply Last reply
    0
    • N normanordas

      Using P/Invoke how would i know that i should be passing "by value" or "by reference" to the arguments of a method or function of the DLL? 2. Equivalent type in .Net of the used data type for each variable (e.g what's the equivalent type of BSTR in VB.Net/C#? 3. In the type library it says: VARIANT_BOOL _stdcall NE_QueryElementByID( [in] long net, [in] ElementTypeEnum eltype, [in, out] IDAttRec* id, [in, out] HandleAttRec* h); This is the way i called it in VB.Net...is this correct? ... _ Public Shared Function NE_QueryElementByID(ByRef net As Long, ByRef eltype As ElementTypeEnum, ByRef id As IDAttRec, ByRef h As HandleAttRec) As Boolean End Function ... Dim h1 As HandleAttRec hi.Handle = 0 Dim id1 As IDAttRec Dim m_startid As Int32 = 4424 id1.UserID = 99 id1.LayerKey = 1 dim bol as Boolean = NE_QueryElementByID(net, ElementTypeEnum.NE_EDGE, id1, h1) Tnx a lot!

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      COM's IDL follows C's convention: arguments are always copied (pass-by-value). Where it gets tricky is that the value copied might be a pointer, simulating pass-by-reference. In this case, you'll want to pass net and eltype ByVal, while id and h should be passed ByRef. However, if you have a type library, why aren't you using tlbimp? Stability. What an interesting concept. -- Chris Maunder

      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