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

Status
Not open for further replies.

Garbage

God of Mistakes...
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
 
Last edited:

dheeraj_kumar

Legen-wait for it-dary!
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.
 
OP
Garbage

Garbage

God of Mistakes...
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

Legen-wait for it-dary!
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.
 
OP
Garbage

Garbage

God of Mistakes...
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

Legen-wait for it-dary!
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 :)
 
Status
Not open for further replies.
Top Bottom