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. Dll?

Dll?

Scheduled Pinned Locked Moved C#
questioncsharpc++
2 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.
  • S Offline
    S Offline
    SherKar
    wrote on last edited by
    #1

    hi does any one know how can i convert this code that is made by C++ in dll to C# also to be put in dll #define DllExport __declspec( dllexport ) HHOOK h; DllExport extern LRESULT CALLBACK CallWndProc(int nCode,WPARAM wParam,LPARAM lParam) { switch(nCode) { case WM_SIZING: return 0; break; case WM_MOVING: return 0; break; default: return CallNextHookEx(h,nCode,wParam,lParam); } } DllExport extern void InstallHook() { h=SetWindowsHookEx(WH_CALLWNDPROC,CallWndProc,0,0); }

    H 1 Reply Last reply
    0
    • S SherKar

      hi does any one know how can i convert this code that is made by C++ in dll to C# also to be put in dll #define DllExport __declspec( dllexport ) HHOOK h; DllExport extern LRESULT CALLBACK CallWndProc(int nCode,WPARAM wParam,LPARAM lParam) { switch(nCode) { case WM_SIZING: return 0; break; case WM_MOVING: return 0; break; default: return CallNextHookEx(h,nCode,wParam,lParam); } } DllExport extern void InstallHook() { h=SetWindowsHookEx(WH_CALLWNDPROC,CallWndProc,0,0); }

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

      There's three types of ways to handle Windows messages in .NET:

      1. Override the WndProc method of a control (including Form, which derives from Control). The Message structure contains the necessary information. You can use the Marshal class and the GCHandle structure to assist with marshaling the WPARAM and LPARAM. This is a Window hook.
      2. Implement IMessageFilter and add it to the collection of message pump filters using Application.AddMessageFilter. This is an application hook.
      3. Finally - and you should be very careful and write good, efficient, error-checking code - are global system hooks like WH_CALLWNDPROC. See the article Global System Hooks in .NET[^] for more information

      Decide whether you really need a global hook that applies to all Windows though. Using any language, this can decrease the performance and stability of Windows, but using a managed language will definitely decrease performance because of the runtime. In most cases, this is not necessary. Just today I recommended handling these very notification messages by simply overriding WndProc on a form to prevent it from being moved or resized. This would be the most efficient way and would not affect other applications.

      Microsoft MVP, Visual C# My Articles

      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