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 / C++ / MFC
  4. .net application and C dll

.net application and C dll

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++question
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.
  • M Offline
    M Offline
    mosquitooth
    wrote on last edited by
    #1

    Hi, my current project consists of a .net application (exe in VB.NET) and a VC++ DLL. Normally, I just call functions in the DLL out of my application, which works just fine. But sometimes I'd like to do it the other way round: to call functions in the .net application out of my C++- Code. Is this possible, and if so, how is it done? Thanks a lot mosquitooth

    A 1 Reply Last reply
    0
    • M mosquitooth

      Hi, my current project consists of a .net application (exe in VB.NET) and a VC++ DLL. Normally, I just call functions in the DLL out of my application, which works just fine. But sometimes I'd like to do it the other way round: to call functions in the .net application out of my C++- Code. Is this possible, and if so, how is it done? Thanks a lot mosquitooth

      A Offline
      A Offline
      Antti Keskinen
      wrote on last edited by
      #2

      Hmm.. Considering that you can use the handle of a loaded DLL to get pointers to the exported functions inside, it would seem logical that the same procedure can be applied vice-versa. When you load an application, you usually get an instance handle. Passing this instance handle out of the application context (thread) into a DLL's handler function (residing in another thread), should allow you to use GetProcAddress or a similar function to get the exported symbols of your .Net application. This should be pretty easy to implement with MFC, just by using AfxGetInstanceHandle in the executable, and passing this handle over to the DLL, you can use the handle to get the exported symbols. But a case with VB .Net and VC++ DLL, I'm not sure. I don't know how you can export symbols from a VB.Net application/DLL. See the VB manual for instructions on this one. But the outline of the procedure I mentioned should work. An additional problem may arise because the .Net application most obviously runs over the CLR, and is thus considered 'managed'. Passing a handle of a managed application to an unmanaged DLL might prove "interesting" results :) All in all, try this out, and you'll see what happens.. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.

      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