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. winAPI functions

winAPI functions

Scheduled Pinned Locked Moved C#
csharpquestion
3 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.
  • D Offline
    D Offline
    datainjector
    wrote on last edited by
    #1

    Can i use winAPI functions in C#??

    J P 2 Replies Last reply
    0
    • D datainjector

      Can i use winAPI functions in C#??

      J Offline
      J Offline
      Jon Newman
      wrote on last edited by
      #2

      You can import functionality from a native dll. For example:

      [DllImport("kernel32", SetLastError=true)]
      static extern IntPtr CreateFile(
      string filename,
      uint desiredAccess,
      uint shareMode,
      uint attributes,
      uint creationDisposition,
      uint flagsAndAttributes,
      uint templateFile
      );

      You can then call CreateFile as you would a normal C# method. You will need to know the basic conversion types from C++ to C#. Or you can use [MarshalAs(UnmanagedType...)] attribute on a field.


      "If you just say porn then you get all manner of chaff and low grade stuff."
      - Paul Watson, Lounge 25 Mar 03
      "If a man is standing in the middle of the forest speaking and there is no woman around to hear him, is he still wrong?"
      - Anon


      Jonathan 'nonny' Newman Homepage [www.nonny.com] [^]

      1 Reply Last reply
      0
      • D datainjector

        Can i use winAPI functions in C#??

        P Offline
        P Offline
        Paresh Gheewala
        wrote on last edited by
        #3

        yes, ofcourse you can use. you can use regular static/nonstatic mfc/nonMfc dll. + you can use COM dll using COM dll is easy as eating popcorn ;P and using other dll is hard and will need testing using marshalling etc :((

        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