Pause process and kill it

K

kids_pro

Dear All,

How can I hook code to window so that each time new application is lunch it
send notify to my application first.

Regards
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi,

You can, for example, find the window handle of the application to receive
the "ping" through P/Invoking to FindWindow API and then P/Invoke to
PostMessage to ping the first application. This code should be placed to the
Main method, before calling Application.Run().

If the first application actually launches the second one, you could pass
the HWND of the first app's main window in the command line to avoid calling
FindWindow (or even resorting to EnumWindows).
 
K

kids_pro

Hi,

My appologize of first post.
I would like to clearify what I want to do.

I want to install a hook into system and monitoring the system from that
point forward.
I think it call system wide hook. Let say each time application lunch
(iexplorer.exe, word.exe, excel.exe) message will send to my hook procedure
and I will pause that process until valid authentication.
I got sample code from msdn it local thread hook. I can't make is system
wide hook. `CuttingEdge0210.exe`

May be C# won't allow system wide hook.
Please advice.

Regards


Dmitriy Lapshin said:
Hi,

You can, for example, find the window handle of the application to receive
the "ping" through P/Invoking to FindWindow API and then P/Invoke to
PostMessage to ping the first application. This code should be placed to the
Main method, before calling Application.Run().

If the first application actually launches the second one, you could pass
the HWND of the first app's main window in the command line to avoid calling
FindWindow (or even resorting to EnumWindows).

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

kids_pro said:
Dear All,

How can I hook code to window so that each time new application is lunch it
send notify to my application first.

Regards
 
D

Dmitriy Lapshin [C# / .NET MVP]

Umm... I've heard of serious difficulties related to implementing hooks with
C#. I think you might get a piece of advice from a more experienced person
by re-posting your question in the microsoft.public.dotnet.framework.interop
newsgroup.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

kids_pro said:
Hi,

My appologize of first post.
I would like to clearify what I want to do.

I want to install a hook into system and monitoring the system from that
point forward.
I think it call system wide hook. Let say each time application lunch
(iexplorer.exe, word.exe, excel.exe) message will send to my hook procedure
and I will pause that process until valid authentication.
I got sample code from msdn it local thread hook. I can't make is system
wide hook. `CuttingEdge0210.exe`

May be C# won't allow system wide hook.
Please advice.

Regards


Dmitriy Lapshin said:
Hi,

You can, for example, find the window handle of the application to receive
the "ping" through P/Invoking to FindWindow API and then P/Invoke to
PostMessage to ping the first application. This code should be placed to the
Main method, before calling Application.Run().

If the first application actually launches the second one, you could pass
the HWND of the first app's main window in the command line to avoid calling
FindWindow (or even resorting to EnumWindows).

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

kids_pro said:
Dear All,

How can I hook code to window so that each time new application is
lunch
it
send notify to my application first.

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top