Sunday, November 25, 2012

Windows - Removing AutoPlay items from the Options list

AutoRun dialog pops up each time you connect an USB storage device or insert a CD/DVD/BRay disc. You can remove unwanted items by changing the registry Handlers.

1. Go to Start and click Run, in the dialog box type regedit and hit Enter.
2. Navigate to HKEY_LOCAL_MACHINE \ Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ AutoplayHandlers \ Handlers and remove unwanted items by deleting them from the registry.

handler

Source

Cheers!


Friday, November 2, 2012

Winforms/C# - Overriding default minimize and maximize form events

Overriding the default system behavior is simple. Just need to capture machine events and modify them as we wish.


//overrides minimize and maximize default behavior
        private const int WM_SYSCOMMAND = 0x0112;
        private const int SC_MINIMIZE = 0xf020;
        private const int SC_MAXIMIZE = 0xf030;

        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_SYSCOMMAND)
            {
                if (m.WParam.ToInt32() == SC_MINIMIZE)
                {
                    m.Result = IntPtr.Zero;
                    //my code for the minimize event
                    return;
                }
                else if (m.WParam.ToInt32() == SC_MAXIMIZE)
                {
                    //my code for the maximize event
                    return;
                }
            }
            base.WndProc(ref m);


Cheers!