I am launching Reader 10.0 to send a PDF file to a printer from a C# program on a Win 7 system. Here's what I am doing now:
startInfo.FileName = adobeReaderPath;
string args = String.Format("/t \"{0}\" \"{1}\"", this.pdfFileName, this.printerName);
startInfo.Arguments = args;
startInfo.CreateNoWindow = true;
startInfo.ErrorDialog = false;
startInfo.UseShellExecute = false;
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process process = Process.Start(startInfo);
I noticed that launching Reader like this (or from command prompt) actually starts 2 AcroRd32.exe executables. Neither of them is minimized. I also tried ProcessWindowStyle.Hidden with the same result.
Is there a way of forcing Reader to start minimized?
Thanks!
After launching the process, you can get the MainWindowHandle of it and use P/Invoke to minimize it:
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
//..
ShowWindow(process.MainWindowHandle, 11); //11 is ForceMinimized
Try it with inclduding /h
in your command line. This launches an Adobe Reader instance minimized to the taskbar. There is however no "nice" option to hide it completly (To my knowledge). Other than hack some unpredictable stuff with the Win32 API
. The more generic approach to start some app minimized is over the API. See Steve's post.
This should do:
string args = String.Format("/h /t \"{0}\" \"{1}\"", this.pdfFileName, this.printerName);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With