.NET Forum / Languages / VB.NET / October 2007
How to prevent Start menu to open (disable it)
|
|
Thread rating:  |
bz - 27 Sep 2007 22:28 GMT Hi,
I need an app to run in kiosk mode, so user will not have access to start menu and taskbar while the app is running
I was able to hide / show the taskbar with trhe following code when app starts / exits
(the code is in C#, but please help me with suggestion no matter what lang you are using)
[DllImport("user32.dll", EntryPoint = "FindWindowA")] static extern int FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")] static extern int SetWindowPos(int hwnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags);
const int SWP_HIDEWINDOW = 128; const int SWP_SHOWWINDOW = 64;
static public void HideTaskbar() { int intReturn = FindWindow("Shell_traywnd", ""); SetWindowPos(intReturn, 0, 0, 0, 0, 0, SWP_HIDEWINDOW); }
static public void ShowTaskbar() { int intReturn = FindWindow("Shell_traywnd", ""); SetWindowPos(intReturn, 0, 0, 0, 0, 0, SWP_SHOWWINDOW); }
But users still can access the start menu with Windows button (or Ctrl +Esc) Is there any way to disable start menu too?
Thank you
Cor Ligthert[MVP] - 28 Sep 2007 04:43 GMT bz,
If you don't use an installer (and setting shortcuts) it will not be in the Start menu, however programs running without a start menu are mostly windows services. However your code is not VB.Net, wrong newsgroup maybe?
Cor
bz - 28 Sep 2007 07:06 GMT Hi,
The issue is not about setting a shortcut. My program should behave like a kiosk application - full screen, exclusive mode (so to not give users access to other programs while starting this) I wrote the code to hide taskbare when app is started, and show it back when exit. But even w/o taskbar, users can open start menu by pressing Windows key (or CTRL+ESC) on keyboard And this is what I want to trap and prevent to happen
Regarding ng's, I know the code I post is C#, but this is not an issue, I post in this ng in purpose. My app contains several modules, written in various net languages (C#, VB.Net, and even some in PHP.NET), so the language is not important, I can translate then it in any lang I need for a particular project within the solution. I'm just trying several ng's, maybe someone knows a solution to this.
Thanks
On 28 Sep, 06:43, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl> wrote:
> bz, > [quoted text clipped - 3 lines] > > Cor Armin Zingler - 28 Sep 2007 12:08 GMT > Hi, > [quoted text clipped - 6 lines] > (the code is in C#, but please help me with suggestion no matter > what lang you are using) Instead of using this hack, I would try to find a supported way to suppress the start menu - if possible. To me this seems to be more like a security or policy issue. In any case, how to do it is not a VB.Net language related issue, therefore I'd ask in one of the m.p.win32.programmer.* groups. Unfortunatelly, I didn't find one that seems to be appropriate at first sight. I suggest asking in the .UI or .kernel group about /what/ to do.
Armin
(O)enone - 28 Sep 2007 14:57 GMT > I need an app to run in kiosk mode, so user will not have access to > start menu and taskbar while the app is running You can disable the Windows, Alt-Tab, Ctrl-Escape, etc. keyboard combinations using a low level keyboard hook.
I can tell you how to do it in C++, but I don't know how easy it would be to translate it to C# or VB.NET. Do managed languages support Win32 API callbacks?
 Signature (O)enone
bz - 30 Sep 2007 01:41 GMT > > I need an app to run in kiosk mode, so user will not have access to > > start menu and taskbar while the app is running [quoted text clipped - 5 lines] > translate it to C# or VB.NET. Do managed languages support Win32 API > callbacks? I guess they do, since it is possible to interface with API calls Please let me know how to do it with low level API keyboard hook, and I hope I'll find a way to port it in C# or vb.net
Or maybe I'll be able to write a small unmanaged C++ dll, and export a function to call from C# instead.
Thanks Bogdan
> -- > > (O)enone (O)enone - 01 Oct 2007 10:18 GMT > I guess they do, since it is possible to interface with API calls > Please let me know how to do it with low level API keyboard hook, and > I hope I'll find a way to port it in C# or vb.net > > Or maybe I'll be able to write a small unmanaged C++ dll, and export a > function to call from C# instead. This is based on the code found here:
http://msdn.microsoft.com/msdnmag/issues/02/09/CQA/
The callback function:
\\\ LRESULT CALLBACK MyTaskKeyHookLL(int nCode, WPARAM wp, LPARAM lp) { KBDLLHOOKSTRUCT *pkh = (KBDLLHOOKSTRUCT *) lp;
if (nCode==HC_ACTION) { BOOL bCtrlKeyDown = GetAsyncKeyState(VK_CONTROL)>>((sizeof(SHORT) * 8) - 1);
if ((pkh->vkCode==VK_ESCAPE && bCtrlKeyDown) || // Ctrl+Esc (pkh->vkCode==VK_TAB && pkh->flags & LLKHF_ALTDOWN) || // Alt+TAB (pkh->vkCode==VK_ESCAPE && pkh->flags & LLKHF_ALTDOWN)|| // Alt+Esc (pkh->vkCode==VK_LWIN || pkh->vkCode==VK_RWIN) || (pkh->vkCode==0)) { // Start Menu return 1; // gobble it: go directly to jail, do not pass go } }
return CallNextHookEx(g_hHookKbdLL, nCode, wp, lp); } ///
Variable to store the hook pointer:
\\\ HHOOK g_hHookKbdLL = NULL; // hook handle ///
Code to install the hook:
\\\ if (!g_hHookKbdLL) { g_hHookKbdLL = SetWindowsHookEx(WH_KEYBOARD_LL, MyTaskKeyHookLL, hinst, 0); } ///
(where hinst is the HINSTANCE handle to your application instance)
To remove the hook:
\\\ if (g_hHookKbdLL != NULL) { UnhookWindowsHookEx(g_hHookKbdLL); g_hHookKbdLL = NULL; } ///
HTH,
 Signature (O)enone
bz - 01 Oct 2007 16:58 GMT Thank you. Regards
On 1 Oct, 12:18, "\(O\)enone" <oen...@nowhere.com> wrote:
> > I guess they do, since it is possible to interface with API calls > > Please let me know how to do it with low level API keyboard hook, and [quoted text clipped - 65 lines] > > (O)enone
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|