Solved

CreateProcess()

Posted on 1999-01-10
7
261 Views
Last Modified: 2012-05-04
I am doing a project and need to call another program to open a data file that created by the current program. I try with Notepad to open a file and most of the parameters are NULL the exercuteable notepad is in project directory and debug directory but cannot make it work, no compile error nor any error message, the process just doesnt run

CreateProcess("Notpad", "data.txt", NULL, NULL, TRUE ... NULL);
0
Comment
Question by:ahTri
  • 4
  • 3
7 Comments
 
LVL 6

Accepted Solution

by:
thresher_shark earned 50 total points
ID: 1181838
Use this instead:

ShellExecute (NULL, "open", "data.txt", NULL, NULL, NULL);

If you have additional questions, please feel free to ask.  Thanks!
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1181839
Note that if it still doesn't work, make sure the "data.txt" file is in the correct directory, because I can guarentee it will work if that is the case.  If you run your program from within DevStudio, make sure data.txt is in the project directory.  If you run your program from the "debug" directory, make sure data.txt is also in the debug directory.
0
 

Author Comment

by:ahTri
ID: 1181840
this is what your answer:
Use this instead:

   ShellExecute (NULL, "open", "data.txt", NULL, NULL, NULL);

   If you have additional questions, please feel free to ask.  Thanks!

------------
but doesnt work at all, no compile error, but nothing happen ! what u mean by "open" is it the string name of the execute file ?
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:ahTri
ID: 1181841
Ohh sorry I find out how to use ShellExecute but what I need is to run an application and tell it some parameter

with ShellExecute I can only "open" and "notepad.exe" and no place for parameter

thanks
0
 

Author Comment

by:ahTri
ID: 1181842
this is what I write:
ShellExecute(NULL, "open", "notepad.exe", NULL, NULL, NULL);
      
and it doesnt do anything, please help thanks
0
 

Author Comment

by:ahTri
ID: 1181843
thanks I figure it out at last
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1181844
Sorry for not responding, I was not on the internet :-) I am glad you got it working.
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

770 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