Program launches within Visual Stdui 2005, fails otherwise.

A

AllTheseYrs

Hi all. I recently made a program to retreive the process ID of a
process. It is written in C/C++ and works fine when I launch it from
Visual Studio 2005. However, when i launch it from a command prompt or
from explorer, it only returns a new line for the process ID.
GetLastError() returns 0. I dont understand why this happens seeing as
how it works fine from VS. I would like to know how to fix this.
Thanks in advance.
 
G

Gianni Mariani

Hi all. I recently made a program to retreive the process ID of a
process. It is written in C/C++ and works fine when I launch it from
Visual Studio 2005. However, when i launch it from a command prompt or
from explorer, it only returns a new line for the process ID.
GetLastError() returns 0. I dont understand why this happens seeing as
how it works fine from VS. I would like to know how to fix this.
Thanks in advance.

This is off topic on comp.lang.c++ - try microsoft visual C++ group. As
an aside, what I usually do in a case like the one you described is I
put a sleep for 30 seconds as the first thing in main() and then I start
it and attach the debugger. It should then behave exactly the same but
this time in the debugger.
 
J

Joe Greer

(e-mail address removed) wrote in 19g2000hsx.googlegroups.com:
Hi all. I recently made a program to retreive the process ID of a
process. It is written in C/C++ and works fine when I launch it from
Visual Studio 2005. However, when i launch it from a command prompt or
from explorer, it only returns a new line for the process ID.
GetLastError() returns 0. I dont understand why this happens seeing as
how it works fine from VS. I would like to know how to fix this.
Thanks in advance.

Generally, this is because there is some assumption made about an
uninitialized variable. The IDE tends to initialize things to a known
value, whereas this doesn't happen normally.

joe
 
G

Guest

(e-mail address removed) wrote in 19g2000hsx.googlegroups.com:


Generally, this is because there is some assumption made about an
uninitialized variable. The IDE tends to initialize things to a known
value, whereas this doesn't happen normally.

We are getting off-topic here but I'd just like to point out that the
IDE does not do anything but launch the executable and attach the
debugger. However it might be possible that the executable launched by
the OP is the release version while he/she launched the debug version,
which do initialise variables, from the IDE.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,048
Members
47,650
Latest member
IanTylor5

Latest Threads

Top