ım doing a c# security program this detect the desktop, any human musnt exit from program with use the windows types . what codes ı need

Dani AI

Generated

asked for a way to prevent users from leaving a C# app by using Windows/system key combos. rightly pointed toward handling keyboard input at the app level; however, form-level handlers alone are fragile for system shortcuts and global combos. Two safer patterns are recommended: use the OS kiosk features (Assigned Access / replacing Explorer shell) for a true lockdown, or install a global low-level keyboard hook from your process to selectively suppress combinations.

Assigned Access (kiosk) is the preferred, supportable option for production lock-downs — it is built into Windows and prevents most user escapes without hacks (). If a programmatic interception is required (for testing or a custom launcher), use a WH_KEYBOARD_LL global hook via the Windows API (SetWindowsHookEx) from C# (P/Invoke). That lets a single callback examine virtual-key codes and return a non-zero result to swallow the event before the system processes it. See the API reference for SetWindowsHookEx for details and correct usage: SetWindowsHookEx (Win32).

Example outline (install/uninstall hook, check vkCode, return non-zero to block):

/* Minimal pattern: SetWindowsHookEx(WH_KEYBOARD_LL,...), callback reads vkCode,
   checks for combinations (Alt+Tab, Ctrl+Esc, Win keys, Alt+F4) and returns (IntPtr)1 to swallow. */

Cautions: Ctrl+Alt+Del (Secure Attention Sequence) cannot be intercepted by user-mode hooks. Hooks require proper privileges and a stable process lifetime; antivirus or OS protections may block or ignore hooks. For reliable kiosk behavior on real systems, favor Assigned Access or replacing the shell instead of trying to catch every system shortcut in managed code.

Recommended Answers

All 3 Replies

You must control the LWin and RWin key codes on the keypreview event on form.

Hope this helps

if you know can you write entire codes

See here for a keys enumeration.

Hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.