Tuesday, July 28, 2009

C++ program launches from VS 2005, not from prompt?

Hey all. I have made a program to get the process ID of a process and display it. When i use "Start without debugging" within Visual Studio 2005, it runs fine, but when I run the .exe file from the prompt, it just prints a new line, then a 0, then a newline. And this is with no changes whatsoever. Here is the code:








int main()


{


char Target[100] = "PINBALL.EXE";


HANDLE hProcess = GetProcessByName(Target);


DWORD PID = GetProcessId(hProcess);


cout %26lt;%26lt; PID %26lt;%26lt; endl;


}

C++ program launches from VS 2005, not from prompt?
Is PINBALL.EXE in the same folder as the executable? If not, do so. The IDE runs the executable in a different path environment, so that it doesn't have to worry about moving the files from debug to release versions. So the program will run in the IDE, but not in any other environment, including command-line or double-clicking it from explorer


No comments:

Post a Comment