On 21 Apr 2004 16:32:14 -0700, provo1234@hotmail.com (Shashi)
[quoted text, click to view] wrote:
>Hi All,
>
>Environment: Windows XP; Visual Studio .NET 2003 Edition
>
>Problem: Calling CreateProcess Function from a Windows Service
>
>Ultimate Aim: To print a pdf file using the command
>AcroRd32.exe /t "c:\myfile.pdf" "\\PRINTERS\printer1" from a Windows
>Service Program
>
>
>I need to call the Win32 Function, CreateProcess, from a VB.NET
>program using .NET Interoperabilty (PInvoke)
>
>For more info about CreateProcess...
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createprocess.asp
>
>CreateProcess takes 10 parameters and I have no idea how to go about
>it. I would be ever thankful to you if you can provide me with a code
>snippet that can launch an executible using CreateProcess.
>
>Thanks in advance
>Shashi
Shashi
I use this to start an app from C#:
public void JStartProcess(string strCommand, string strWD)
{
ProcessStartInfo psi = new ProcessStartInfo();
// Initialize the ProcessStartInfo structure
psi.FileName = strCommand;
psi.Arguments = "";
psi.WorkingDirectory = strWD;
psi.RedirectStandardInput = false;
psi.RedirectStandardOutput = false;
psi.UseShellExecute = false;
Process proc = new Process();
Process.Start(psi);
}
If you translated that to VB.NET would it work for you? It
avoids using the API.
You would need to pass in the parameters for psi.Arguments:
public void JStartProcess(string strCommand, string
strARguments, string strWD)
And call it so:
JStartProcess("AcroRd32.exe", @" /t c:\myfile.pdf
\\PRINTERS\printer1", strWD);
You would need to pass in the full path to the Acrobat Reader.
--
Jeff Gaines - Damerham Hampshire UK