473,320 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 :

Expand|Select|Wrap|Line Numbers
  1.             Process p = new Process();
  2.             p.StartInfo.FileName = "c:\\windows\\notepad.exe";
  3.             //p.StartInfo.FileName = "c:\\windows\\system32\\RunDll32.exe";
  4.             //p.StartInfo.Arguments = " shell32.dll,Control_RunDLL wscui.cpl";
  5.             p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
  6.             p.Start();
  7.             p.WaitForInputIdle(2000);
  8.             WinAPI.SetWindowPos(p.MainWindowHandle, WinAPI.HWND_TOP, 0, 0, 600, 600, WinAPI.SWP_SHOWWINDOW);
  9.  
But when I want to start the control center with :
RunDll32.exe shell32.dll,Control_RunDLL wscui.cpl

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

I use this :

Expand|Select|Wrap|Line Numbers
  1.             WinAPI.STARTUPINFO si = new WinAPI.STARTUPINFO();
  2.             WinAPI.PROCESS_INFORMATION pi = new WinAPI.PROCESS_INFORMATION();
  3.             //si.cb = (uint)Marshal.SizeOf(si);
  4.             si.dwX = 0;
  5.             si.dwY = 0;
  6.             si.dwXSize = 500;
  7.             si.dwYSize = 500;
  8.             si.dwFlags = (uint)(WinAPI.STARTF.STARTF_USEPOSITION) | (uint)WinAPI.STARTF.STARTF_USESIZE;
  9.              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);
  10.             WinAPI.WaitForInputIdle((int)pi.dwThreadId, int.MaxValue);
  11.             WinAPI.EnumThreadWindows((int)pi.dwThreadId, 0, 0);
  12.             WinAPI.MoveWindow((IntPtr)pi.dwThreadId, 0, 0, 400, 400, true);
  13.  
It start the correct app but don't move and resize it...

How can I do this with this specific window?

Thanks in advance!
Jul 23 '08 #1
0 1316

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: spencer | last post by:
Hello, I have an index page with an autoscroller writen with CSS. The problem is the scrolling content(text and inages)'s position is correct but will off position when the broswer(IE) window...
7
by: Doc | last post by:
I've read in a couple of different places including the archives of this forum that html doesn't allow you to precisely dictate the position of an image, but I found this command (again in the...
4
by: BrianKE | last post by:
I am attempting to create an app that will run "on top" of another app. My app will create a transparent window over the other app for the purpose of displaying information. I am able to create...
19
by: derelicten | last post by:
hello , I have an issue positionating some pics I want to anchor to an existing table cell but I cant just place regular position on the cell because the background is fixed height and the set of...
2
by: rockdale.green | last post by:
Hi, I do not know where should I start to solve this problem. I have a calendar inside a div on my webpage which will show /hide when user click a button. but the button is almost at the...
11
by: garyusenet | last post by:
For this first time today I used the System.Diagnositcs namespace to launch a program from my c# code. The program launches OK but I have something which has completely stumped me. The...
3
by: | last post by:
Is there an automatic way to tell a windows to save its size and position, or do I have to save these parameters to the registry when the form quits and then reload them next time?
5
by: mani1234 | last post by:
Hi Everyone! I need to get the position coordinate (left and top)of a object (any object, lets say image) in browser window. The position should be with respect to browser window's size i.e we...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.