Solved

How do I get createprocess to work?

Posted on 1998-08-04
3
178 Views
Last Modified: 2013-11-19
I am trying to launch a console app hidden.  Here is the code I am using:  

PROCESS_INFORMATION pi;
STARTUPINFO si;
si.wShowWindow =  SW_HIDE;
si.dwFlags = STARTF_USESHOWWINDOW;

ProcessResult = CreateProcess("c:\\winnt\\system32\\write",NULL,NULL,NULL,true,NULL, NULL,NULL,&si,&pi);

Can someone provide me with an example, or a hint to what I am doing wrong?  The code executes, but returns with error code 0 - Nothing happens.

Thanks in advance.
0
Comment
Question by:jerryross
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
trestan earned 100 total points
ID: 1320235
PROCESS_INFORMATION pi={0};
STARTUPINFO si={0};
si.wShowWindow =  SW_HIDE;
si.dwFlags = STARTF_USESHOWWINDOW;

ProcessResult = CreateProcess(NULL, "c:\\winnt\\system32\\write",NULL,NULL,TRUE,NULL, NULL,NULL,&si,&pi);
I think you should set the first para as NULL. Use the second as command line input.
0
 
LVL 8

Expert Comment

by:trestan
ID: 1320236
Also add: si.cb = sizeof(si);
0
 

Author Comment

by:jerryross
ID: 1320237
Thank you!  I really needed that to work.  Now, if I can make sure that I am closing all of the appropriate handles for the newly created process then It'll be working great!  I am closing the thread handle, and the process handle, but I think there is also a window handle to close.  If I can get that and close it that should work.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.NET how to use the Vertical ScrollBar 5 90
Generic progress indicator 6 113
Complete beginner needs help making a cron job 9 109
Use of condition with 'serial' in ansible 2 49
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now