Trapping SendMessage via interop services 
Author Message
 Trapping SendMessage via interop services

Hi,

I've got a small C# app which is required to post specific win32 messages to a win32 legacy application.  This is very straightforward via interop services,  I just import the user32.dll, and away I go. :
  public class Win32

  {

  [DllImport("user32.dll", CharSet=CharSet.Auto)]

  public static extern bool PostMessage(uint hWnd, uint msg, int wParam, int lParam);

  }

  <snip>
  Win32.PostMessage(winHandle, msg, 0, 0)

Does anyone know however, how to do a PostMessage or SendMessage from a win32 app and trap this in a c# windows app?  Note, that the win32 app in question does not provide support for the COM programming model.

Thanks...

Rob.



Tue, 15 Feb 2005 12:26:30 GMT  
 Trapping SendMessage via interop services

Rob, to catch a windows message in your C# app you'll need to override WndProc in your form.  You will have access to all of the windows messages posted to your form in there.  

To post a message from a Win32 app you will have to call the same PostMessage API.  How you call that is going to depend on what language you are using.  

--
Greg
http://www.claritycon.com/

  Hi,

  I've got a small c# app which is required to post specific win32 messages to a win32 legacy application.  This is very straightforward via interop services,  I just import the user32.dll, and away I go. :
    public class Win32

    {

    [DllImport("user32.dll", CharSet=CharSet.Auto)]

    public static extern bool PostMessage(uint hWnd, uint msg, int wParam, int lParam);

    }

    <snip>
    Win32.PostMessage(winHandle, msg, 0, 0)

  Does anyone know however, how to do a PostMessage or SendMessage from a win32 app and trap this in a c# windows app?  Note, that the win32 app in question does not provide support for the COM programming model.

  Thanks...

  Rob.



Tue, 15 Feb 2005 21:51:01 GMT  
 Trapping SendMessage via interop services

Ok thanks Greg.

  Rob, to catch a windows message in your C# app you'll need to override WndProc in your form.  You will have access to all of the windows messages posted to your form in there.  

  To post a message from a Win32 app you will have to call the same PostMessage API.  How you call that is going to depend on what language you are using.  

  --
  Greg
  http://www.claritycon.com/

    Hi,

    I've got a small c# app which is required to post specific win32 messages to a win32 legacy application.  This is very straightforward via interop services,  I just import the user32.dll, and away I go. :
      public class Win32

      {

      [DllImport("user32.dll", CharSet=CharSet.Auto)]

      public static extern bool PostMessage(uint hWnd, uint msg, int wParam, int lParam);

      }

      <snip>
      Win32.PostMessage(winHandle, msg, 0, 0)

    Does anyone know however, how to do a PostMessage or SendMessage from a win32 app and trap this in a c# windows app?  Note, that the win32 app in question does not provide support for the COM programming model.

    Thanks...

    Rob.



Fri, 18 Feb 2005 08:31:04 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Sending messages over MSN Messenger via Interop.Messenger.dll

2. problem: debugging a service while logged in via terminal services client

3. Problem calling Access via COM interop

4. Question: using SendMessage via DllImport

5. Crashing when sending a pointer to a large chunk of shared memory via an IPC SendMessage

6. atl web service interop with apache

7. trapping keys to black box app via COM

8. Using FindWindow/SendMessage in a service???

9. SendMessage() fails in a Service.

10. NT Service MFC/ATL Problem when another app does SendMessage(BROADCAST)

11. Using FindWindow/SendMessage in a service???

12. Service Event Trap

 

 
Powered by phpBB® Forum Software