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. GetProcAddress

GetProcAddress

Scheduled Pinned Locked Moved C#
csharpc++question
7 Posts 3 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.
  • V Offline
    V Offline
    Vadim Tabakman
    wrote on last edited by
    #1

    I'm new to C# but not programming. I need to dynamically load dlls (native) and I have that part working with the [DllImport .... LoadLibrary ], and the with GetProcAddress. What I am having trouble with, is the returning value from GetProcAddress. I have it returning an IntPtr. It is valid and I assume I should be able to use it. In C++ I can cast the pointer to a function pointer. Is this possible in C#? I understand in .NET that function pointers are delegates and that you can't cast an IntPtr to a delegate type. So how do I go about calling the function that i have just obtained from a DLL? Thanx :) If there's one thing I've learned, it's that life is one crushing defeat after another until you just wish Flanders was dead. - Homer Simpson

    H 1 Reply Last reply
    0
    • V Vadim Tabakman

      I'm new to C# but not programming. I need to dynamically load dlls (native) and I have that part working with the [DllImport .... LoadLibrary ], and the with GetProcAddress. What I am having trouble with, is the returning value from GetProcAddress. I have it returning an IntPtr. It is valid and I assume I should be able to use it. In C++ I can cast the pointer to a function pointer. Is this possible in C#? I understand in .NET that function pointers are delegates and that you can't cast an IntPtr to a delegate type. So how do I go about calling the function that i have just obtained from a DLL? Thanx :) If there's one thing I've learned, it's that life is one crushing defeat after another until you just wish Flanders was dead. - Homer Simpson

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      This has been covered before in this forum. The most recent thread can be found at http://www.codeproject.com/script/comments/forums.asp?msg=890289&forumid=1649#xx890289xx[^]. This was found quickly by searching for "LoadLibrary" after clicking "Search comments" above.

      Microsoft MVP, Visual C# My Articles

      V 1 Reply Last reply
      0
      • H Heath Stewart

        This has been covered before in this forum. The most recent thread can be found at http://www.codeproject.com/script/comments/forums.asp?msg=890289&forumid=1649#xx890289xx[^]. This was found quickly by searching for "LoadLibrary" after clicking "Search comments" above.

        Microsoft MVP, Visual C# My Articles

        V Offline
        V Offline
        Vadim Tabakman
        wrote on last edited by
        #3

        1. why would I search when I know that Heath Stewart answers questions on this forum within 20 mins? ;P 2. I did actually search and find that, but that tells me that it'll be available in .NET 2.0. I thought maybe someone had a work around for pre 2.0. There's gotta be some guru out there that has done it ? If there's one thing I've learned, it's that life is one crushing defeat after another until you just wish Flanders was dead. - Homer Simpson

        L H 2 Replies Last reply
        0
        • V Vadim Tabakman

          1. why would I search when I know that Heath Stewart answers questions on this forum within 20 mins? ;P 2. I did actually search and find that, but that tells me that it'll be available in .NET 2.0. I thought maybe someone had a work around for pre 2.0. There's gotta be some guru out there that has done it ? If there's one thing I've learned, it's that life is one crushing defeat after another until you just wish Flanders was dead. - Homer Simpson

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          1. Because you are an idiot then. :doh: top secret xacc-ide 0.0.1

          V 1 Reply Last reply
          0
          • V Vadim Tabakman

            1. why would I search when I know that Heath Stewart answers questions on this forum within 20 mins? ;P 2. I did actually search and find that, but that tells me that it'll be available in .NET 2.0. I thought maybe someone had a work around for pre 2.0. There's gotta be some guru out there that has done it ? If there's one thing I've learned, it's that life is one crushing defeat after another until you just wish Flanders was dead. - Homer Simpson

            H Offline
            H Offline
            Heath Stewart
            wrote on last edited by
            #5

            1. Because you always should search first. Good research is required skill for any good developer, and with forums like you have here today it's so easy compared to when I first started programming (no web; only gopher). 2. Nick did provide a work around that does work (though P/Invoking LoadLibrary really isn't necessary unless you want to check whether or not the DLL was actually loaded successfully since invoking the imported function won't tell you). Using the DllImportAttribute, the CLR will load the referenced DLL when necessary. You should still be able to unload it.

            Microsoft MVP, Visual C# My Articles

            V 1 Reply Last reply
            0
            • L leppie

              1. Because you are an idiot then. :doh: top secret xacc-ide 0.0.1

              V Offline
              V Offline
              Vadim Tabakman
              wrote on last edited by
              #6

              Leppie, thats a little harsh isn't it? p.s. I wasn't the one that gave you the 1. For something as intelligent as your comment, it isn't worth it. Jubjub If there's one thing I've learned, it's that life is one crushing defeat after another until you just wish Flanders was dead. - Homer Simpson

              1 Reply Last reply
              0
              • H Heath Stewart

                1. Because you always should search first. Good research is required skill for any good developer, and with forums like you have here today it's so easy compared to when I first started programming (no web; only gopher). 2. Nick did provide a work around that does work (though P/Invoking LoadLibrary really isn't necessary unless you want to check whether or not the DLL was actually loaded successfully since invoking the imported function won't tell you). Using the DllImportAttribute, the CLR will load the referenced DLL when necessary. You should still be able to unload it.

                Microsoft MVP, Visual C# My Articles

                V Offline
                V Offline
                Vadim Tabakman
                wrote on last edited by
                #7

                Thanx for your help Heath. Much appreciated. If there's one thing I've learned, it's that life is one crushing defeat after another until you just wish Flanders was dead. - Homer Simpson

                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