Console Minimize not happening for MSDE Install

  • Thread starter Mike Oliszewski
  • Start date
M

Mike Oliszewski

I am attempting to install the MSDE (SQL 2000) as a part of our application.
This requires that you run the MSDE setup.exe program from a Console mode
application, it just hangs forever part way through if executed from a
standard application.

My question is:

How can I make my console mode install application resize it's window or
minimize. The code below is what I'm currently trying which doesn't work...
the Console BOX stays full size.

Process ThisProcess;

ProcessStartInfo SetupProcess = new ProcessStartInfo();
SetupProcess.FileName = "setup.exe";
SetupProcess.Arguments = "INSTANCENAME=\"FBSQL\" /qb";

SetupProcess.WindowStyle = ProcessWindowStyle.Minimized;

ThisProcess = Process.Start(SetupProcess);
ThisProcess.WaitForExit();
 
M

Mike Oliszewski

OK, so I'm a dummy, my code below requests the new process to be minimized,
which isn't what I want. What I need to know is how do I minimize or resize
my currently executing Console mode application.
 
J

Jeffrey Tan[MSFT]

Hi Mike,

Thanks for posting in this group.
Based on my understanding, your install application is a console
application. In it, you wanted to invoke setup.exe to install MSDE.
And when invoke setup.exe, you want to minimize your install application's
console window.

Actually, you can P/invoke GetConsoleWindow() to get your console window's
handle, then you can use MoveWindow() to change its size and position.
Use ShowWindow() to minize or maximize your console window.

Sample code snippet like this:
[DllImport("user32.dll")]
public static extern bool MoveWindow(IntPtr hwnd,int x,int y,int
nWidth,int nHeight,bool bRepaint);

[DllImport("kernel32.dll")]
public static extern IntPtr GetConsoleWindow();

[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hwnd,int nCmdShow);

private const int SW_MINIMIZE=6;

//in main function
IntPtr hwnd=GetConsoleWindow();
MoveWindow(hwnd,0,0,200,200,true); //Change console window's position and
size

ShowWindow(hwnd,SW_MINIMIZE);//Minimize the console window

These all works well on my machine.
Btw: SW_MINIMIZE const can be got from VB 6.0 API viewer.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top