Global application interrupt

  • Thread starter Thread starter Tamir Khason
  • Start date Start date
T

Tamir Khason

I need the way to interrupt (freeze) ANY program currenlty running at the
computer, then to activate the application and return the previous
applications state after my application execution. Is any way to do it
managed?

TNX
 
Tamir Khason said:
I need the way to interrupt (freeze) ANY program currenlty running at the
computer, then to activate the application and return the previous
applications state after my application execution. Is any way to do it
managed?

What exactly does "freeze" mean to you?
You could probably set your thread priority to highest or realtime, that way
the thread scheduler shouldn't allocate any time slices to other threads as
long as your one is busy. However, I somehow doubt this is a good idea...

What are you trying to acchieve? Why isn't it enough to make your
application topmost?

Niki
 
I have to run my application ANYWAY, by interrupting (pausing) anything
running currently on the computer. EG. The user playing game. The
application should popup and leave ne option to using, but do anything in
the application. After this will be done the game previously player will be
resumed.
 
Tamir Khason said:
I have to run my application ANYWAY, by interrupting (pausing) anything
running currently on the computer. EG. The user playing game. The

Windows is a multitasking OS, so your application *will* run anyway. Why do
you have to interrupt other applications, and how are you going to find out
what applications to interrupt? Interrupting anything (including system
services) will likely cause the PC to crash.
application should popup and leave ne option to using, but do anything in
the application. After this will be done the game previously player will
be resumed.

I doubt you'll have much luck with that: There's no way to prevent the
CTRL-ALT-DEL combination, and using task manager the user will be able to
close your app.

What are you writing? A virus? I doubt users would like what you're
planing...

Niki
 
Let's say anything other then Windows Services . Applications the user
currently running in his username account
 
Tamir Khason said:
Let's say anything other then Windows Services . Applications the user
currently running in his username account

You should be able to enumerate all processes using WMI, and suspend all
threads in these processes.
 
I'd using WMI in a couple of projects and notice about real differences
between OSes. Are there any other way?
 
Tamir Khason said:
I'd using WMI in a couple of projects and notice about real differences
between OSes. Are there any other way?

There is no direct way to do this using Managed code nor WMI (well, you can
get a list of processes and threads using WMI), your only option is to use
unmanaged code, provided you have the necessary privileges to control other
processes/threads, here's what you have to do:
1. (Using WMI) Get a list of processes you need to suspend.
2. (Using WMI) For each in 1, get associated thread ID's.
3. Get thread handle from threadID by caling Win32 API OpenThread.
3. Call Win32 API SuspendThread using the thread handles from 2
4. Do your thing....
5. Call Win32 API ResumeThread using the same thread handles as in 3.

Willy.
 
Back
Top