Position and size of a process window

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • guilabonte
    New Member
    • Jul 2008
    • 1

    Position and size of a process window

    How can I set the position and the size of a process like the security center.

    (I use visual studio .net 2005 and c#)

    If I use this code for notepad that work fine :

    Code:
                Process p = new Process();
                p.StartInfo.FileName = "c:\\windows\\notepad.exe";
                //p.StartInfo.FileName = "c:\\windows\\system32\\RunDll32.exe";
                //p.StartInfo.Arguments = " shell32.dll,Control_RunDLL wscui.cpl";
                p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
                p.Start();
                p.WaitForInputIdle(2000);
                WinAPI.SetWindowPos(p.MainWindowHandle, WinAPI.HWND_TOP, 0, 0, 600, 600, WinAPI.SWP_SHOWWINDOW);
    But when I want to start the control center with :
    RunDll32.exe shell32.dll,Con trol_RunDLL wscui.cpl

    by default this window is centered with a default size. I can't resize it.

    I use this :

    Code:
                WinAPI.STARTUPINFO si = new WinAPI.STARTUPINFO();
                WinAPI.PROCESS_INFORMATION pi = new WinAPI.PROCESS_INFORMATION();
                //si.cb = (uint)Marshal.SizeOf(si);
                si.dwX = 0;
                si.dwY = 0;
                si.dwXSize = 500;
                si.dwYSize = 500;
                si.dwFlags = (uint)(WinAPI.STARTF.STARTF_USEPOSITION) | (uint)WinAPI.STARTF.STARTF_USESIZE;
                 WinAPI.CreateProcess("c:\\windows\\system32\\rundll32.exe", " shell32.dll,Control_RunDLL wscui.cpl", IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero, null, ref si, out pi);
                WinAPI.WaitForInputIdle((int)pi.dwThreadId, int.MaxValue);
                WinAPI.EnumThreadWindows((int)pi.dwThreadId, 0, 0);
                WinAPI.MoveWindow((IntPtr)pi.dwThreadId, 0, 0, 400, 400, true);
    It start the correct app but don't move and resize it...

    How can I do this with this specific window?

    Thanks in advance!
Working...