DIGIT-ARC read-only archive · snapshot: July 23, 2026

[C#] NEED HELP - How to disable all other things except current windows form ?

6 posts · originally from https://geek.digit.in/community/threads/c-need-help-how-to-disable-all-other-things-except-current-windows-form.104136/

Garbage
Garbage Original post #1
Dec 11, 2008 at 2:44 PM
Hello.
Currently, I'm working on a windows form. For some reasones, I need that whenever I'll execute my windows form, all other things, like start menu, some windows services should be disabled.
Means, user shouldn't be able to use Start menu button, ALT+TAB, Browser, etc...
My windows form will be running full screen.

Is there any code available for this purpose in C# .Net ?

Thanks in advance.

no replies till ? :O
dheeraj_kumar
Dec 11, 2008 at 6:30 PM
C# is no good with low level windows functionality. You need to use pInvoke, to call the necessary APIs. You would need to use FindWindow to find your specific window, as all objects in windows are windows themselves. Then use EnableWindow to disable that window. Use Spy++ to find out window names, or better yet, use CreateToolSnapshot to get PIDs.

As for services, Codeproject helps you:
*www.codeproject.com/KB/system/ServiceManager.aspx

If you want to do it the API way, use OpenSCManager, OpenService, ControlService and CloseServiceHandle.

Again, I'm not familiar enough with C# to suggest, but as for API use RegisterHotKey to disable alt tab.

If you arent familiar with pinvoke, use www.pinvoke.net for instant function definitions.
Garbage
Garbage #3
Dec 12, 2008 at 11:09 AM
Thanks for the links Dheeraj.
Here is another link I got - *www.codeproject.com/KB/cs/globalhook.aspx

But still it's not working. :(
Need more help.
dheeraj_kumar
Dec 12, 2008 at 3:20 PM
Hmm... the codeproject link is just an implementation of SetWindowsHookEx. I dont know enough c# to help you, I'm good at unmanaged code though.

If you cant get them working, try the codeproject link, as well as
*www.codeproject.com/csharp/GlobalSystemHook.asp

If you cant use the source directly, link the DLL provided, and study the demo app to figure out how you can use it.
Garbage
Garbage #5
Dec 13, 2008 at 3:36 PM
Thanks Dheeraj again...

But I solved it. :) :p

I created a thread, which continuously search for the open processes like explorer.exe, iexplore.exe, taskmgr.exe. If it finds any open process, it kills. :D
dheeraj_kumar
Dec 14, 2008 at 1:35 AM
Hmm... another simpler way to be to hook CreateProcess() :)
If the exe name parameter matches your list, bang! return an error.

This way, you dont waste CPU time looking for a process.

First you need to use CreateToolhelp32Snapshot to get a list of the current processes, then terminate whatever you need to. Then hook CreateProcess and have fun :)