2011-10-18 19 views
9

Cách tốt nhất để tạo ứng dụng Windows .NET là chương trình duy nhất có thể được sử dụng trên máy tính là gì? Tôi đã gặp bộ tính giờ hoặc sự kiện để chuyển cửa sổ trở lại cửa sổ với văn bản phù hợp và một số cuộc gọi api32 để tạo thành một biểu mẫu nhiều nhất.Tạo một ứng dụng .NET là chương trình duy nhất có thể chạy?

Có thể tạo một ứng dụng như màn hình khóa cửa sổ, nơi không có gì có thể được thực hiện ngoại trừ những gì trên màn hình? Tôi muốn chặn người dùng thực hiện những việc khác và chỉ cho phép quản trị viên truy cập vào máy tính để bàn.

+2

tôi, như một người dùng, sẽ tìm thấy máy tính như khá vô dụng :-) Một máy tính có khả năng chạy một ứng dụng duy nhất. Tôi sẽ cảm thấy buồn chán :-) –

+3

@DarinDimitrov: Tôi nghĩ rằng đây có thể là một số loại phần mềm đăng ký tiền mặt hoặc một thứ gì đó dọc theo các dòng đó. Giống như một kiốt. –

+1

Bạn có ý nghĩa gì đó dọc theo các dòng của [chế độ kiosk] (http://stackoverflow.com/questions/4617303/does-windows-7-have-a-kiosk-mode)? – R0MANARMY

Trả lời

1

Tôi đã tìm cách đơn giản hơn để không sử dụng chế độ kiosk hoặc gpedits hoặc mọi thứ như thế.

Trong đơn đăng ký của tôi, tôi đã thực hiện một nút với hai thứ đơn giản chết tiệt này - không có câu hỏi nào!

Tôi đã sử dụng shell.cmd để bắt đầu nhấp một lần ứng dụng, appref-ms và nó hoạt động hấp dẫn.

'The logged in user has to be administrator or the app run as administrator once. 

My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\IniFileMapping\system.ini\boot", "Shell", "USR:Software\Microsoft\Windows NT\CurrentVersion\Winlogon") 

'This will change the shell to your program for THIS LOGGED IN user- after re logon bye bye exploerer shell hello custom app!    

My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Winlogon", "Shell", appPath & "\shell.cmd")` 

Watch my software boot as if it owns windows!

Want to understand more how it works in the full apscect?

11

Bạn cần chạy ứng dụng của mình ở chế độ kiosk.

phương pháp bên ngoài

[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

//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; 

Phương pháp

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 
    } 
} 

Disable phím nóng

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); 

Ẩn thanh tác vụ

// 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); 

dạng Ví dụ trong chế độ kiosk

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); 

    } 
} 

Dưới đây là một bài báo mà bạn có thể kiểm tra:
http://www.c-sharpcorner.com/UploadFile/scottlysle/KioskCS01292008011606AM/KioskCS.aspx

Dưới đây là một số phần mềm đóng gói để xem xét:
http://www.kioware.com/productoverview.aspx?source=google&gclid=CPeQyrzz8qsCFZFV7Aod6noeMw

+0

Yea đẹp- tôi cho rằng đây là câu trả lời tốt nhất nhưng tôi thực sự sẽ sử dụng liên kết được cung cấp trong các ý kiến ​​để pdf làm thế nào để thay đổi chương trình shell defautl-làm tất cả các mã sẽ không cần thiết và nếu người dùng muốn máy tính để bàn tôi chạy trình thám hiểm vỏ từ ứng dụng "vỏ" của tôi và tất cả là tốt. Cảm ơn câu trả lời tuyệt vời! – ppumkin

4

Nếu ý định của bạn là để ngăn chặn điều này vĩnh viễn cho một người dùng cụ thể, bạn có thể quản lý này thông qua các chính sách nhóm thích hợp.

Ví dụ trong Local Group Policy Editor (menu Startgpedit.msc), đi đến Local Computer PolicyUser ConfigurationAdministrative TemplatesHệ thống. Bạn sẽ tìm thấy hai lựa chọn:

  • Không chạy các ứng dụng Windows quy định
  • Run chỉ định ứng dụng Windows

Tất nhiên, bạn phải làm quản lý tốt của chính sách nhóm để hạn chế những thứ khác cho người dùng được chỉ định, ngăn thay đổi cấu hình, để khởi động lại máy, v.v.và bạn cũng phải làm cho ứng dụng của bạn chặn các khóa đặc biệt thông qua các móc khóa bàn phím.

Hãy nhớ rằng: không chỉ dựa vào móc, chế độ toàn màn hình và những thứ khác ngăn người dùng thoát khỏi ứng dụng của bạn. Nếu bạn làm điều đó, một ngày ứng dụng của bạn sẽ bị lỗi, cấp cho người dùng quyền truy cập không giới hạn vào hệ điều hành, hệ thống tệp cơ bản, v.v.

Các vấn đề liên quan