Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使.NET应用程序成为唯一可以运行的程序?_.net_Vb.net_Kiosk Mode - Fatal编程技术网

使.NET应用程序成为唯一可以运行的程序?

使.NET应用程序成为唯一可以运行的程序?,.net,vb.net,kiosk-mode,.net,Vb.net,Kiosk Mode,让Windows.NET应用程序成为计算机上唯一可以使用的程序的最佳方法是什么? 我遇到过将窗口切换回具有匹配文本的窗口的计时器或事件,以及一些api32调用,以使窗体最顶层 有没有可能让一个像windows锁屏这样的应用程序除了屏幕上的内容之外什么都做不了?我想阻止用户做其他事情,只让管理员进入桌面。您需要在kiosk模式下运行应用程序 外部方法 [DllImport("user32.dll")] private static extern int FindWindow(string cls,

让Windows.NET应用程序成为计算机上唯一可以使用的程序的最佳方法是什么? 我遇到过将窗口切换回具有匹配文本的窗口的计时器或事件,以及一些api32调用,以使窗体最顶层


有没有可能让一个像windows锁屏这样的应用程序除了屏幕上的内容之外什么都做不了?我想阻止用户做其他事情,只让管理员进入桌面。

您需要在kiosk模式下运行应用程序

外部方法

[DllImport("user32.dll")]
private static extern int FindWindow(string cls, string wndwText);

[DllImport("user32.dll")]
private static extern int ShowWindow(int hwnd, int cmd);

[DllImport("user32.dll")]
private static extern long SHAppBarMessage(long dword, int cmd);

[DllImport("user32.dll")]
private static extern int RegisterHotKey(IntPtr hwnd, int id, int fsModifiers, int vk);

[DllImport("user32.dll")]
private static extern int UnregisterHotKey(IntPtr hwnd, int id);
//constants for modifier keys
private const int USE_ALT = 1;
private const int USE_CTRL = 2;
private const int USE_SHIFT = 4;
private const int USE_WIN = 8;

//hot key ID tracker
short mHotKeyId = 0;
private void RegisterGlobalHotKey(Keys hotkey, int modifiers)
{
    try
    {
        // increment the hot key value - we are just identifying
        // them with a sequential number since we have multiples
        mHotKeyId++;

        if (mHotKeyId > 0)
        {
            // register the hot key combination
            if (RegisterHotKey(this.Handle, mHotKeyId, modifiers, Convert.ToInt16(hotkey)) == 0)
            {
                // tell the user which combination failed to register -
                // this is useful to you, not an end user; the end user
                // should never see this application run
                MessageBox.Show("Error: " + mHotKeyId.ToString() + " - " +
                    Marshal.GetLastWin32Error().ToString(),
                    "Hot Key Registration");
            }
        }
    }
    catch
    {
        // clean up if hotkey registration failed -
        // nothing works if it fails
        UnregisterGlobalHotKey();
    }
}


private void UnregisterGlobalHotKey()
{
    // loop through each hotkey id and
    // disable it
    for (int i = 0; i < mHotKeyId; i++)
    {
        UnregisterHotKey(this.Handle, i);
    }
}

protected override void WndProc(ref Message m)
{
    base.WndProc(ref m);

    // if the message matches,
    // disregard it
    const int WM_HOTKEY = 0x312;
    if (m.Msg == WM_HOTKEY)
    {
        // Ignore the request or each
        // disabled hotkey combination
    }
}
RegisterGlobalHotKey(Keys.F4, USE_ALT);

// Disable CTRL+W - exit
RegisterGlobalHotKey(Keys.W, USE_CTRL);

// Disable CTRL+N - new window
RegisterGlobalHotKey(Keys.N, USE_CTRL);

// Disable CTRL+S - save
RegisterGlobalHotKey(Keys.S, USE_CTRL);

// Disable CTRL+A - select all
RegisterGlobalHotKey(Keys.A, USE_CTRL);

// Disable CTRL+C - copy
RegisterGlobalHotKey(Keys.C, USE_CTRL);

// Disable CTRL+X - cut
RegisterGlobalHotKey(Keys.X, USE_CTRL);

// Disable CTRL+V - paste
RegisterGlobalHotKey(Keys.V, USE_CTRL);

// Disable CTRL+B - organize favorites
RegisterGlobalHotKey(Keys.B, USE_CTRL);

// Disable CTRL+F - find
RegisterGlobalHotKey(Keys.F, USE_CTRL);

// Disable CTRL+H - view history
RegisterGlobalHotKey(Keys.H, USE_CTRL);

// Disable ALT+Tab - tab through open applications
RegisterGlobalHotKey(Keys.Tab, USE_ALT);
常数

[DllImport("user32.dll")]
private static extern int FindWindow(string cls, string wndwText);

[DllImport("user32.dll")]
private static extern int ShowWindow(int hwnd, int cmd);

[DllImport("user32.dll")]
private static extern long SHAppBarMessage(long dword, int cmd);

[DllImport("user32.dll")]
private static extern int RegisterHotKey(IntPtr hwnd, int id, int fsModifiers, int vk);

[DllImport("user32.dll")]
private static extern int UnregisterHotKey(IntPtr hwnd, int id);
//constants for modifier keys
private const int USE_ALT = 1;
private const int USE_CTRL = 2;
private const int USE_SHIFT = 4;
private const int USE_WIN = 8;

//hot key ID tracker
short mHotKeyId = 0;
private void RegisterGlobalHotKey(Keys hotkey, int modifiers)
{
    try
    {
        // increment the hot key value - we are just identifying
        // them with a sequential number since we have multiples
        mHotKeyId++;

        if (mHotKeyId > 0)
        {
            // register the hot key combination
            if (RegisterHotKey(this.Handle, mHotKeyId, modifiers, Convert.ToInt16(hotkey)) == 0)
            {
                // tell the user which combination failed to register -
                // this is useful to you, not an end user; the end user
                // should never see this application run
                MessageBox.Show("Error: " + mHotKeyId.ToString() + " - " +
                    Marshal.GetLastWin32Error().ToString(),
                    "Hot Key Registration");
            }
        }
    }
    catch
    {
        // clean up if hotkey registration failed -
        // nothing works if it fails
        UnregisterGlobalHotKey();
    }
}


private void UnregisterGlobalHotKey()
{
    // loop through each hotkey id and
    // disable it
    for (int i = 0; i < mHotKeyId; i++)
    {
        UnregisterHotKey(this.Handle, i);
    }
}

protected override void WndProc(ref Message m)
{
    base.WndProc(ref m);

    // if the message matches,
    // disregard it
    const int WM_HOTKEY = 0x312;
    if (m.Msg == WM_HOTKEY)
    {
        // Ignore the request or each
        // disabled hotkey combination
    }
}
RegisterGlobalHotKey(Keys.F4, USE_ALT);

// Disable CTRL+W - exit
RegisterGlobalHotKey(Keys.W, USE_CTRL);

// Disable CTRL+N - new window
RegisterGlobalHotKey(Keys.N, USE_CTRL);

// Disable CTRL+S - save
RegisterGlobalHotKey(Keys.S, USE_CTRL);

// Disable CTRL+A - select all
RegisterGlobalHotKey(Keys.A, USE_CTRL);

// Disable CTRL+C - copy
RegisterGlobalHotKey(Keys.C, USE_CTRL);

// Disable CTRL+X - cut
RegisterGlobalHotKey(Keys.X, USE_CTRL);

// Disable CTRL+V - paste
RegisterGlobalHotKey(Keys.V, USE_CTRL);

// Disable CTRL+B - organize favorites
RegisterGlobalHotKey(Keys.B, USE_CTRL);

// Disable CTRL+F - find
RegisterGlobalHotKey(Keys.F, USE_CTRL);

// Disable CTRL+H - view history
RegisterGlobalHotKey(Keys.H, USE_CTRL);

// Disable ALT+Tab - tab through open applications
RegisterGlobalHotKey(Keys.Tab, USE_ALT);
方法

[DllImport("user32.dll")]
private static extern int FindWindow(string cls, string wndwText);

[DllImport("user32.dll")]
private static extern int ShowWindow(int hwnd, int cmd);

[DllImport("user32.dll")]
private static extern long SHAppBarMessage(long dword, int cmd);

[DllImport("user32.dll")]
private static extern int RegisterHotKey(IntPtr hwnd, int id, int fsModifiers, int vk);

[DllImport("user32.dll")]
private static extern int UnregisterHotKey(IntPtr hwnd, int id);
//constants for modifier keys
private const int USE_ALT = 1;
private const int USE_CTRL = 2;
private const int USE_SHIFT = 4;
private const int USE_WIN = 8;

//hot key ID tracker
short mHotKeyId = 0;
private void RegisterGlobalHotKey(Keys hotkey, int modifiers)
{
    try
    {
        // increment the hot key value - we are just identifying
        // them with a sequential number since we have multiples
        mHotKeyId++;

        if (mHotKeyId > 0)
        {
            // register the hot key combination
            if (RegisterHotKey(this.Handle, mHotKeyId, modifiers, Convert.ToInt16(hotkey)) == 0)
            {
                // tell the user which combination failed to register -
                // this is useful to you, not an end user; the end user
                // should never see this application run
                MessageBox.Show("Error: " + mHotKeyId.ToString() + " - " +
                    Marshal.GetLastWin32Error().ToString(),
                    "Hot Key Registration");
            }
        }
    }
    catch
    {
        // clean up if hotkey registration failed -
        // nothing works if it fails
        UnregisterGlobalHotKey();
    }
}


private void UnregisterGlobalHotKey()
{
    // loop through each hotkey id and
    // disable it
    for (int i = 0; i < mHotKeyId; i++)
    {
        UnregisterHotKey(this.Handle, i);
    }
}

protected override void WndProc(ref Message m)
{
    base.WndProc(ref m);

    // if the message matches,
    // disregard it
    const int WM_HOTKEY = 0x312;
    if (m.Msg == WM_HOTKEY)
    {
        // Ignore the request or each
        // disabled hotkey combination
    }
}
RegisterGlobalHotKey(Keys.F4, USE_ALT);

// Disable CTRL+W - exit
RegisterGlobalHotKey(Keys.W, USE_CTRL);

// Disable CTRL+N - new window
RegisterGlobalHotKey(Keys.N, USE_CTRL);

// Disable CTRL+S - save
RegisterGlobalHotKey(Keys.S, USE_CTRL);

// Disable CTRL+A - select all
RegisterGlobalHotKey(Keys.A, USE_CTRL);

// Disable CTRL+C - copy
RegisterGlobalHotKey(Keys.C, USE_CTRL);

// Disable CTRL+X - cut
RegisterGlobalHotKey(Keys.X, USE_CTRL);

// Disable CTRL+V - paste
RegisterGlobalHotKey(Keys.V, USE_CTRL);

// Disable CTRL+B - organize favorites
RegisterGlobalHotKey(Keys.B, USE_CTRL);

// Disable CTRL+F - find
RegisterGlobalHotKey(Keys.F, USE_CTRL);

// Disable CTRL+H - view history
RegisterGlobalHotKey(Keys.H, USE_CTRL);

// Disable ALT+Tab - tab through open applications
RegisterGlobalHotKey(Keys.Tab, USE_ALT);
隐藏任务栏

// hide the task bar - not a big deal, they can
// still CTRL+ESC to get the start menu; for that
// matter, CTRL+ALT+DEL also works; if you need to
// disable that you will have to violate SAS and 
// monkey with the security policies on the machine

ShowWindow(FindWindow("Shell_TrayWnd", null), 0);

信息亭模式下的示例表单

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

public partial class frmKioskStarter : Form
{                
    #region Dynamic Link Library Imports

    [DllImport("user32.dll")]
    private static extern int FindWindow(string cls, string wndwText);

    [DllImport("user32.dll")]
    private static extern int ShowWindow(int hwnd, int cmd);

    [DllImport("user32.dll")]
    private static extern long SHAppBarMessage(long dword, int cmd);

    [DllImport("user32.dll")]
    private static extern int RegisterHotKey(IntPtr hwnd, int id, int fsModifiers, int vk);

    [DllImport("user32.dll")]
    private static extern int UnregisterHotKey(IntPtr hwnd, int id);

    #endregion

    #region Modifier Constants and Variables

    // Constants for modifier keys
    private const int USE_ALT = 1;
    private const int USE_CTRL = 2;
    private const int USE_SHIFT = 4;
    private const int USE_WIN = 8;

    // Hot key ID tracker
    short mHotKeyId = 0;

    #endregion

    public frmKioskStarter()
    {
        InitializeComponent();

        // Browser window key combinations
        // -- Some things that you may want to disable --
        //CTRL+A           Select All
        //CTRL+B           Organize Favorites
        //CTRL+C           Copy
        //CTRL+F           Find
        //CTRL+H           View History
        //CTRL+L           Open Locate
        //CTRL+N           New window (not in Kiosk mode)
        //CTRL+O           Open Locate
        //CTRL+P           Print
        //CTRL+R           Refresh
        //CTRL+S           Save
        //CTRL+V           Paste
        //CTRL+W           Close
        //CTRL+X           Cut
        //ALT+F4           Close

        // Use CTRL+ALT+DEL to open the task manager,
        // kill IE and then close the application window
        // to exit

        // Disable ALT+F4 - exit
        RegisterGlobalHotKey(Keys.F4, USE_ALT);

        // Disable CTRL+W - exit
        RegisterGlobalHotKey(Keys.W, USE_CTRL);

        // Disable CTRL+N - new window
        RegisterGlobalHotKey(Keys.N, USE_CTRL);

        // Disable CTRL+S - save
        RegisterGlobalHotKey(Keys.S, USE_CTRL);

        // Disable CTRL+A - select all
        RegisterGlobalHotKey(Keys.A, USE_CTRL);

        // Disable CTRL+C - copy
        RegisterGlobalHotKey(Keys.C, USE_CTRL);

        // Disable CTRL+X - cut
        RegisterGlobalHotKey(Keys.X, USE_CTRL);

        // Disable CTRL+V - paste
        RegisterGlobalHotKey(Keys.V, USE_CTRL);

        // Disable CTRL+B - organize favorites
        RegisterGlobalHotKey(Keys.B, USE_CTRL);

        // Disable CTRL+F - find
        RegisterGlobalHotKey(Keys.F, USE_CTRL);

        // Disable CTRL+H - view history
        RegisterGlobalHotKey(Keys.H, USE_CTRL);

        // Disable ALT+Tab - tab through open applications
        RegisterGlobalHotKey(Keys.Tab, USE_ALT);

        // hide the task bar - not a big deal, they can
        // still CTRL+ESC to get the start menu; for that
        // matter, CTRL+ALT+DEL also works; if you need to
        // disable that you will have to violate SAS and 
        // monkey with the security policies on the machine
        ShowWindow(FindWindow("Shell_TrayWnd", null), 0);
    }

    /// <summary>
    /// Launch the browser window in kiosk mode
    /// using the URL keyed into the text box
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void button1_Click(object sender, EventArgs e)
    {
        System.Diagnostics.Process.Start("iexplore", "-k " + txtUrl.Text);
    }


    private void RegisterGlobalHotKey(Keys hotkey, int modifiers)
    {
        try
        {
            // increment the hot key value - we are just identifying
            // them with a sequential number since we have multiples
            mHotKeyId++;

            if(mHotKeyId > 0)
            {
                // register the hot key combination
                if (RegisterHotKey(this.Handle, mHotKeyId, modifiers, Convert.ToInt16(hotkey)) == 0)
                {
                    // tell the user which combination failed to register -
                    // this is useful to you, not an end user; the end user
                    // should never see this application run
                    MessageBox.Show("Error: " + mHotKeyId.ToString() + " - " +
                        Marshal.GetLastWin32Error().ToString(),
                        "Hot Key Registration");
                }
            }
        }
        catch 
        {
            // clean up if hotkey registration failed -
            // nothing works if it fails
            UnregisterGlobalHotKey();
        }
    }


    private void UnregisterGlobalHotKey()
    {
        // loop through each hotkey id and
        // disable it
        for (int i = 0; i < mHotKeyId; i++)
        {
            UnregisterHotKey(this.Handle, i);
        }
    }

    protected override void WndProc(ref Message m)
    {
        base.WndProc(ref m);

        // if the message matches,
        // disregard it
        const int WM_HOTKEY = 0x312;
        if (m.Msg == WM_HOTKEY)
        {
            // Ignore the request or each
            // disabled hotkey combination
        }
    }

    private void Form1_FormClosed(object sender, FormClosedEventArgs e)
    {
        // unregister the hot keys
        UnregisterGlobalHotKey();

        // show the taskbar - does not matter really
        ShowWindow(FindWindow("Shell_TrayWnd", null), 1);

    }
}
使用系统;
使用系统集合;
使用系统组件模型;
使用系统数据;
使用系统图;
使用系统文本;
使用System.Windows.Forms;
使用System.Runtime.InteropServices;
公共部分类frmKioskStarter:表单
{                
#区域动态链接库导入
[DllImport(“user32.dll”)]
私有静态外部程序int FindWindow(字符串cls,字符串wndwText);
[DllImport(“user32.dll”)]
私有静态外部显示窗口(inthwnd,intcmd);
[DllImport(“user32.dll”)]
私有静态外部long-SHAppBarMessage(long-dword,int-cmd);
[DllImport(“user32.dll”)]
私有静态外部内部寄存器hotkey(IntPtr hwnd、intid、intfsmodifiers、intvk);
[DllImport(“user32.dll”)]
私有静态外部int unregister热键(IntPtr hwnd,int id);
#端区
#区域修改器常量和变量
//修改器键的常量
私有常量int USE_ALT=1;
私有常量int USE_CTRL=2;
私有常量int USE_SHIFT=4;
私用const int USE_WIN=8;
//热键ID跟踪器
短mHotKeyId=0;
#端区
公共frmKioskStarter()
{
初始化组件();
//浏览器窗口键组合
//--一些您可能想要禁用的功能--
//CTRL+A全选
//按CTRL+B组合键组织收藏夹
//CTRL+C复制
//CTRL+F查找
//CTRL+H查看历史记录
//CTRL+L打开定位
//CTRL+N新窗口(不在Kiosk模式下)
//CTRL+O打开定位
//CTRL+P打印
//CTRL+R刷新
//CTRL+S保存
//CTRL+V粘贴
//CTRL+W关闭
//CTRL+X剪切
//ALT+F4关闭
//使用CTRL+ALT+DEL打开任务管理器,
//杀死IE,然后关闭应用程序窗口
//退出
//禁用ALT+F4-退出
RegisterGlobalHotKey(key.F4,使用_ALT);
//禁用CTRL+W-退出
RegisterGlobalHotKey(key.W,使用\u CTRL);
//禁用CTRL+N-新建窗口
RegisterGlobalHotKey(key.N,使用\ CTRL);
//禁用CTRL+S-保存
RegisterGlobalHotKey(key.S,使用\u CTRL);
//禁用CTRL+A-全选
RegisterGlobalHotKey(key.A,使用_-CTRL);
//禁用CTRL+C-复制
RegisterGlobalHotKey(key.C,使用_-CTRL);
//禁用CTRL+X-cut
RegisterGlobalHotKey(key.X,使用\ CTRL);
//禁用CTRL+V-粘贴
RegisterGlobalHotKey(key.V,使用_-CTRL);
//禁用CTRL+B-组织收藏夹
RegisterGlobalHotKey(键.B,使用\u CTRL);
//禁用CTRL+F-查找
RegisterGlobalHotKey(key.F,使用_-CTRL);
//禁用CTRL+H-查看历史记录
RegisterGlobalHotKey(key.H,使用\u CTRL);
//通过打开的应用程序禁用ALT+Tab-Tab
RegisterGlobalHotKey(Keys.Tab,使用ALT);
//隐藏任务栏-没什么大不了的,他们可以
//仍然按住CTRL+ESC键以获取“开始”菜单;为此
//重要的是,CTRL+ALT+DEL也可以工作;如果需要的话
//禁用您将不得不违反SAS和
//在计算机上使用安全策略
显示窗口(FindWindow(“Shell\u TrayWnd”,null),0);
}
/// 
///在kiosk模式下启动浏览器窗口
///使用键入文本框的URL
/// 
/// 
/// 
私有无效按钮1\u单击(对象发送者,事件参数e)
{
系统.诊断.过程.启动(“iexplore”,“-k”+txtrl.Text);
}
私有void注册表全局热键(键热键、int修饰符)
{
尝试
{
//增加热键值-我们只是识别
//因为我们有倍数,所以它们有一个序列号
mHotKeyId++;
如果(mHotKeyId>0)
{
//注册热键组合
if(RegisterHotKey(this.Handle,mHotKeyId,modifiers,Convert.ToInt16(热键))=0)
{
//告诉用户注册失败的组合-
//这对您有用,而不是最终用户;最终用户
//不应该看到此应用程序运行
MessageBox.Show(“错误:+mHotKeyId.ToString()+”-“+
Marshal.GetLastWin32Error().ToString(),
“热键注册”);
}
}
}
抓住
{
//如果热键注册失败,请进行清理-
//如果失败了,什么都不起作用
取消注册全局热键();
}
}
私有void UnregisterGlobalHotKey()
{
//循环检查每个热键id和
//禁用它
for(int i=0;i