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. Is there a way to make native win32 call?

Is there a way to make native win32 call?

Scheduled Pinned Locked Moved C#
c++question
5 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.
  • L Offline
    L Offline
    Le centriste
    wrote on last edited by
    #1

    Any win32 call, I mean.

    D 1 Reply Last reply
    0
    • L Le centriste

      Any win32 call, I mean.

      D Offline
      D Offline
      Duncan Edwards Jones
      wrote on last edited by
      #2

      Yes - check out the DLLImport attribute from System.Marshal (Don't know the C# syntax I'm afraid but theres a VB example in my "Monitoring the printer in VB.Net" article) '--8<------------------------ Ex Datis: Duncan Jones Merrion Computing Ltd

      P 1 Reply Last reply
      0
      • D Duncan Edwards Jones

        Yes - check out the DLLImport attribute from System.Marshal (Don't know the C# syntax I'm afraid but theres a VB example in my "Monitoring the printer in VB.Net" article) '--8<------------------------ Ex Datis: Duncan Jones Merrion Computing Ltd

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

        if you want to check out all the win32 API for reference then check the following site, ;) http://www.codeproject.com/system/hooksys.asp http://leb.net/wine/WinDoc/funcIndex-local.html :laugh:

        S 1 Reply Last reply
        0
        • P Paresh Gheewala

          if you want to check out all the win32 API for reference then check the following site, ;) http://www.codeproject.com/system/hooksys.asp http://leb.net/wine/WinDoc/funcIndex-local.html :laugh:

          S Offline
          S Offline
          spolia
          wrote on last edited by
          #4

          Michel, here's an example for you. You can group the import specs as shown here, or interspersed through your code... class Win32 { [DllImport("kernel32.dll")] public static extern bool Beep(int freq, int duration); [DllImport("kernel32.dll")] public static extern void SleepEx(int imeinms, int alert); [DllImport("kernel32.dll")] public static extern int WinExec(string pgmname, int hideorshow); [DllImport("kernel32.dll")] public static extern void ExitProcess(uint exitCode); [DllImport("winmm.dll")] public static extern bool PlaySound(string pszSound, int hmod, uint fdwSound); [DllImport("kernel32.dll")] public static extern uint GetCurrentProcess(); [DllImport("kernel32.dll")] public static extern bool TerminateProcess(uint hndl, uint exitcode); } call the functions from your code (say the Beep function) as: Win32.Beep(freq,duration); Hope this helps. Spolia Opima

          L 1 Reply Last reply
          0
          • S spolia

            Michel, here's an example for you. You can group the import specs as shown here, or interspersed through your code... class Win32 { [DllImport("kernel32.dll")] public static extern bool Beep(int freq, int duration); [DllImport("kernel32.dll")] public static extern void SleepEx(int imeinms, int alert); [DllImport("kernel32.dll")] public static extern int WinExec(string pgmname, int hideorshow); [DllImport("kernel32.dll")] public static extern void ExitProcess(uint exitCode); [DllImport("winmm.dll")] public static extern bool PlaySound(string pszSound, int hmod, uint fdwSound); [DllImport("kernel32.dll")] public static extern uint GetCurrentProcess(); [DllImport("kernel32.dll")] public static extern bool TerminateProcess(uint hndl, uint exitcode); } call the functions from your code (say the Beep function) as: Win32.Beep(freq,duration); Hope this helps. Spolia Opima

            L Offline
            L Offline
            Le centriste
            wrote on last edited by
            #5

            Tx exactly what I was looking for.

            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