Skip to main content
gamedev.net
🔒 Locked

Windows - startup problem

Started by ver_T_ex 2 replies 950+ views
Original Post
ver_T_ex
ver_T_ex
Hi guys, I have a problem with a program in which I'm loading an option file during program start. I'm using c++ Windows api so the loading process is during the WM_CREATE: Message. Everything works great but when I put the program into windows startup my relativ path doesn't work anymore because the CurrentDirectory is MyDocuments. So I used SetCurrentDirectory in the WinMain function but when the program receives WM_CREATE the CurrentDirectory has already switched back to MyDocuments. What can I do execept using absolute paths ? Thanks for your help and sry for the bad english!
iMalc
iMalc
Your English seems pretty good to me. Can you not call SetCurrentDirectory after your program receives WM_CREATE? I don't know why Windows would change it on you after your program has started, that seems odd.
ver_T_ex
ver_T_ex
The very strange thing is, when I handle WM_CREATE: I use a LoadOptionFile function and this function uses fopen() and fclose().
So I SetCurrentDirectory before the LoadOptionfile Call and after this function the GetCurrentDirectory gives me AGAIN the MyDocuments path meaning that the working directory changed back to MyDirectory. So there must be a way to lock that (I hope so )
ver_T_ex
ver_T_ex
Sorry guys, the problem solved itself.
It put the code that changes the CurrentDirectory after I created the Window and before I enter the message loop. But it seems that the WM_CREATE thing is handled during the Creation of the Window via CreateWindow and not during the MsgPeek thing so the global variable with the path wasn't initialized and WOLA now it works after I put the code at the very beginning of the winmain function.
Anyway thanks for your help!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.