a exe in c++ boot at windows start but not working, run manually it works

Hello,
I created a small application in C + + with Visual C++ 2010 Express. No error message.
- Started manually: everything is OK (it wrote a text in a txt file)
- To run this application at start of windows, I created a key regedit (HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run), the program starts without problems (I see it in task manager) but it does not work, the text file is not written !!!!!
Where is the problem?
A parameter in the project properties in vc++?
Thank!

Here is the code:

#include <fstream>
#include <windows.h>

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
static std::ofstream g_log("log2.txt");
g_log << "message" << std::endl;
Sleep(INFINITE);
return 0;
}

Hi,
Your program probably is working but the file is written to a different directory.
try using an absolute path eg.

c:\\log2.txt

and check whether it is wriiten to c:\\

hope this helps
Shredded
hi Shredded,
it was indeed a problem of relative path, I put it in absolute and it works now.
Thank you for your answer
Topic archived. No new replies allowed.