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

NativeMethods

Scheduled Pinned Locked Moved C#
comtoolsquestion
3 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.
  • L Offline
    L Offline
    Luis Alonso Ramos
    wrote on last edited by
    #1

    Hello, I have a question I've been trying to answer and I just can't find anything. When I use an interop method, I know I must put it inside a NativeMethods class. I'm writing a little utility library for my company and I was wondering where should that NativeMethods class go: inside the class that uses it as a nested type, or only one globally for all classes that use any interop method in it? By the way, can anyone explain to me what's the difference between SafeNativeMethods, UnsafeNativeMethods, and NativeMethods? I just don't understand what MSDN says. -- LuisR


    Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

    The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005

    H 1 Reply Last reply
    0
    • L Luis Alonso Ramos

      Hello, I have a question I've been trying to answer and I just can't find anything. When I use an interop method, I know I must put it inside a NativeMethods class. I'm writing a little utility library for my company and I was wondering where should that NativeMethods class go: inside the class that uses it as a nested type, or only one globally for all classes that use any interop method in it? By the way, can anyone explain to me what's the difference between SafeNativeMethods, UnsafeNativeMethods, and NativeMethods? I just don't understand what MSDN says. -- LuisR


      Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

      The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005

      H Offline
      H Offline
      Hesham Desouky
      wrote on last edited by
      #2

      You can group nativemethods in different classes. for example, process related methods in NativeProcessMethods, GDI related methods in NativeGDIMethods. where to put these classes is a raltive issue dependent in your design. But I prefer to put all native methods classes in a class library to use it in another porject in the future to avoid rewriting the code. Hope this helps:) Hesham

      L 1 Reply Last reply
      0
      • H Hesham Desouky

        You can group nativemethods in different classes. for example, process related methods in NativeProcessMethods, GDI related methods in NativeGDIMethods. where to put these classes is a raltive issue dependent in your design. But I prefer to put all native methods classes in a class library to use it in another porject in the future to avoid rewriting the code. Hope this helps:) Hesham

        L Offline
        L Offline
        Luis Alonso Ramos
        wrote on last edited by
        #3

        Interesting comments, thanks!! :) Yes, I think I'll move everything into a global class for easier reusability, with hopes that the library will grow. -- LuisR


        Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

        The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005

        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