views:

73

answers:

1

Hello,

I have wrote an application that consists of two projects in a solution, each project contains only 1 .c source file. I was using Visual Studio 2010 Ultimate but due to the University only supporting 2008 I decided to create a blank solution and copy the source files into the new one.

After creating a new solution in VS2008 express, creating two projects and re-creating and adding the source files to the projects I ran the application.

For some reason only one part of the application does not work, I use CreateProcess() to execute "Project1.exe" from Project 2.

This works fine under vs2010 but for some reason it's not working under VS2008 express, GetLastError() is showing an Error 2: File Not Found.

This is an image showing the same code in both IDE's:

Error Image

I'm not using anything special and I've made sure that both solutions/projects are using .Net 3.5.

I can't work out why it would work for one IDE and not the other.

Any suggestions? Thanks!

Edit:

Screenshot of .exe's

.exe location

+2  A: 

You are not passing the full path name of the .exe to CreateProcess(). This usually only works if you are lucky. The .exe files would have to be in the same directory and the working directory has to be set to that directory. First verify that the .exes are where you hope they are.

Avoid the dependency on the working directory by generating the full path to the 2nd .exe. Use GetModuleFileName(), passing NULL, to get the full path of your 1st .exe

Hans Passant
How is luck involved? You either set it up correctly or not.
Kevin Crowell
It worked in VS2010 as both .exe's are in the same folder. I can't specify the paths explicitly as they may be moved. An example being the solution folder is on my desktop now but it may be moved into my documents.
Jamie Keeling
@Jamie, that's why I recommended you use GetModuleFileName(). It makes your code work no matter where the .exes are located and no matter where the current working directory is pointing.
Hans Passant