Archived

This topic is now archived and is closed to further replies.

NoLoGiC

Program starting with windows error

Recommended Posts

Hey everyone! I have a program which starts with windows, and upon startup is supposed to read a config file and take action depending on what is in there. The crazy thing that is happening is upon windows startup, my program runs, but the input from the file it receives seems to be garbage. When I run the program manually, it reads the config file without problem. Windows''s registry key points to the same executable, and my error checking would let me know if the file weren''t accessable. Anyone run into any similar problems? Thanks for reading this, NoLoGiC

Share this post


Link to post
Share on other sites
I encountered something similar a while back on a project, it would compile and run fine in debug mode (vb interpreter) but would crash in release mode. It turned out to be a leak from going past the end of a lump of allocated memory.

Not sure if that''s any help, but....

Jay

Share this post


Link to post
Share on other sites
Maybe it has something to do with your working directory; when you run the program from within your IDE, it doesn''t set it appropriately, and is loading the wrong file.

Share this post


Link to post
Share on other sites
Posting this in case it benefits anyone else running into similar problems:

My windows program would edit the registry and add itself to the list of items to run at startup (its an organizer, nothing malicious )

When the program was run manually, it would find its config in the same path as the executable and life was good. Knowing it ran this way, I used dataFile = fopen("configFileName", "r") to access it.

However, when windows ran it at startup, it wouldn''t read the config file. It turns out that the working path in this case wasn''t the same as the executable, but Drive:\Documents and Settings\user .

To remedy the problem, I use GetModuleFileName to get the path and filename of the executable, PathRemoveFileSpec to remove the executable filename, and strcat to add my config filename to it.

While there is probably an easier way, it works beautifully now!

Hope this helps anyone who runs into a similar problem,
NoLoGiC

Share this post


Link to post
Share on other sites