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. C#
  4. C# and standard C library

C# and standard C library

Scheduled Pinned Locked Moved C#
csharpquestionvisual-studio
6 Posts 4 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.
  • H Offline
    H Offline
    hung_ngole
    wrote on last edited by
    #1

    I have a standard C library file : "abc.dll". Now I want to reuse it with C# (VS.NET 2005). How can I do this? Thanks, Hung. Hung

    J R 2 Replies Last reply
    0
    • H hung_ngole

      I have a standard C library file : "abc.dll". Now I want to reuse it with C# (VS.NET 2005). How can I do this? Thanks, Hung. Hung

      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #2

      Search for "pinvoke"; you can use Platform Invocation Services (P/Invoke) to call native exported C methods.

      Tech, life, family, faith: Give me a visit. I'm currently blogging about: How 'bout a little guitar now? The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

      1 Reply Last reply
      0
      • H hung_ngole

        I have a standard C library file : "abc.dll". Now I want to reuse it with C# (VS.NET 2005). How can I do this? Thanks, Hung. Hung

        R Offline
        R Offline
        russellsoft
        wrote on last edited by
        #3

        You must use InteropServices... using System.Runtime.InteropServices then DllImport attribute [DllImport("User32.dll")] public static extern int MessageBox(int h, string m, string c, int type); Then you are avaible to use MessageBox function all code will be locking such the following: using System; using System.Runtime.InteropServices; class MainClass { [DllImport("User32.dll")] public static extern int MessageBox(int h, string m, string c, int type); static int Main() { string myString; Console.Write("Enter your message: "); myString = Console.ReadLine(); return MessageBox(0, myString, "My Message Box", 0); } }

        H 1 Reply Last reply
        0
        • R russellsoft

          You must use InteropServices... using System.Runtime.InteropServices then DllImport attribute [DllImport("User32.dll")] public static extern int MessageBox(int h, string m, string c, int type); Then you are avaible to use MessageBox function all code will be locking such the following: using System; using System.Runtime.InteropServices; class MainClass { [DllImport("User32.dll")] public static extern int MessageBox(int h, string m, string c, int type); static int Main() { string myString; Console.Write("Enter your message: "); myString = Console.ReadLine(); return MessageBox(0, myString, "My Message Box", 0); } }

          H Offline
          H Offline
          hung_ngole
          wrote on last edited by
          #4

          Thanks! But my "abc.dll" file is not registered in Windows, and I don't want to register it! Do you have other ideas? Hung

          D 1 Reply Last reply
          0
          • H hung_ngole

            Thanks! But my "abc.dll" file is not registered in Windows, and I don't want to register it! Do you have other ideas? Hung

            D Offline
            D Offline
            Dominik Reichl
            wrote on last edited by
            #5

            Put it into the same directory where your .NET executable is. Best regards Dominik


            _outp(0x64, 0xAD); and __asm mov al, 0xAD __asm out 0x64, al do the same... but what do they do?? ;) (doesn't work on NT)

            H 1 Reply Last reply
            0
            • D Dominik Reichl

              Put it into the same directory where your .NET executable is. Best regards Dominik


              _outp(0x64, 0xAD); and __asm mov al, 0xAD __asm out 0x64, al do the same... but what do they do?? ;) (doesn't work on NT)

              H Offline
              H Offline
              hung_ngole
              wrote on last edited by
              #6

              Can you explain more details!! I tried to add reference to standard C .dll file but VS.NET does not allow me to do. Thanks, Hung

              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