By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,087 Members | 1,508 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,087 IT Pros & Developers. It's quick & easy.

How to prevent Start menu to open (disable it)

P: n/a
bz
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

Sep 27 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
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

Sep 28 '07 #2

P: n/a
bz
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,

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
Sep 28 '07 #3

P: n/a
"bz" <bz*****@gmail.comschrieb
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)
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
Sep 28 '07 #4

P: n/a
bz wrote:
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?

--

(O)enone
Sep 28 '07 #5

P: n/a
bz
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?
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

Sep 30 '07 #6

P: n/a
bz 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
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,

--

(O)enone
Oct 1 '07 #7

P: n/a
bz
Thank you.
Regards

On 1 Oct, 12:18, "\(O\)enone" <oen...@nowhere.comwrote:
bz 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
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,

--

(O)enone

Oct 1 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.