none
how to lock the taskbar RRS feed

  • Question

  • hello,

    i need help with c#

    i wrote a program and i want  it when its running to disable the task bar.

    i want it Not  can be shown when i move the courser to it and disable the windows key also.

    but, when i exit the program it is need to back as usual.

     thanks 

    Sunday, January 14, 2018 10:47 AM

All replies

  • Use a fullscreen window.

    Disabling/hiding the taskbar is not a good idea, as Raymond Chen explains at :

    How do I cover the taskbar with a fullscreen window? 


    • Edited by Castorix31 Sunday, January 14, 2018 10:54 AM
    Sunday, January 14, 2018 10:53 AM
  • this is not i meant.

    i want to prevent from the user to use the desktop.

    that because i wanted  to lock the task bar because from their i can open the explorer and another options.

    so, if u have another solution for me i will happy to know 

    thanks

     
    Sunday, January 14, 2018 11:45 AM
  • Then you can use desktop APIs (CreateDesktop, SetThreadDesktop, SwitchDesktop, ...)

    (you can find many samples on Google)


    • Edited by Castorix31 Sunday, January 14, 2018 12:04 PM
    Sunday, January 14, 2018 12:04 PM
  • can you tell how to this exactly?

    thanks 

     
    Sunday, January 14, 2018 12:40 PM
  • Something like this =>

    (I just create an empty Form in a new Desktop to test it (tested on Windows 10))

    public partial class Form1 : Form
    {
        public const int MAXIMUM_ALLOWED = 0x02000000;
    
        [DllImport("User32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
        public static extern IntPtr CreateDesktop(string lpszDesktop, string lpszDevice, IntPtr pDevmode, int dwFlags, int dwDesiredAccess, IntPtr lpsa);
    
        [DllImport("User32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
        public static extern bool SwitchDesktop(IntPtr hDesktop);
    
        [DllImport("User32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
        public static extern bool SetThreadDesktop(IntPtr hDesktop);
    
        [DllImport("User32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
        public static extern bool OpenDesktop(string lpszDesktop, int dwFlags, bool fInherit, int dwDesiredAccess);
    
        [DllImport("User32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
        public static extern bool CloseDesktop(IntPtr hDesktop);
    
        [DllImport("User32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
        public static extern IntPtr GetThreadDesktop(int dwThreadId);
    
        [DllImport("Kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
        public static extern int GetCurrentThreadId();
    
        IntPtr hDefaultDesktop = IntPtr.Zero;
        IntPtr hDesktop = IntPtr.Zero;
    
        public Form1()
        {          
            this.Load += new EventHandler(this.Form1_Load);
        }
    
        private void Form1_Load(object sender, EventArgs e)
        {
            hDefaultDesktop = GetThreadDesktop(GetCurrentThreadId());
            hDesktop = CreateDesktop("NewDesktop", null, IntPtr.Zero, 0, MAXIMUM_ALLOWED, IntPtr.Zero);
            if (hDesktop != IntPtr.Zero)
            {
                SwitchDesktop(hDesktop);
                Task.Factory.StartNew(() =>
                {                   
                    SetThreadDesktop(hDesktop);
                    Form NewForm = new Form();                   
                    NewForm.FormClosing += new FormClosingEventHandler(this.NewForm_FormClosing);
                    Application.Run(NewForm);
                }).Wait();
            }
            this.Close();
        }        
    
        private void NewForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            SetThreadDesktop(hDefaultDesktop);
            SwitchDesktop(hDefaultDesktop);
            if (hDesktop != IntPtr.Zero)
            {
                CloseDesktop(hDesktop);
            }
        }
    }

    Sunday, January 14, 2018 2:44 PM
  • Hello,

     I don't know about the rest of you but anyone that posts asking "How To"

    with words like "prevent", "lock" at User level sound extremely malicious...

     Sorry, OP but what you are asking for is highly suspect.  If you meant

    something else then rephrase your post.

     

     Note: For replies posters, just because they ask does not mean we provide. Sorry

    Sunday, January 14, 2018 9:32 PM
  • hello to you!

    i dont know what is your problem and why do you think that what i was wrote is "extremely malicious"

    im just in the beginning my way to be development.

    and what is the problem with "prevent"? "lock"?

    i just wanted to know how to disable the task bar and win key also.

    a program that i development is for a company that want do prevent the user from exit the software or get a access to the windows desktop.

    so, before you are saying that my asking is so suspect you can ask me directly and not distribute in public.

    have a good day    

    Monday, January 15, 2018 6:27 AM
  • Hello,

     If you had stated, your quote,  "a program that i development is for a

    company that want do prevent the user from exit the software or get

    a access to the windows desktop."  But you did not clearly state your

    intention and was leaning  more to malicious.  If I offended you then

    my bad but take responsability for misleading readers.  Too many times

    users end goals to defeat security measure with their innocent postings.

     Instead of crafty programming to enforce security. Use the Group Policy

    already installed in the OS.  That is what its for.

     Thanks :)

    Monday, January 15, 2018 9:26 PM
  • What it sounds like is that you want Kisok mode.  



    Monday, January 15, 2018 11:00 PM