Problem when starting Blitz Prog from Start Menu

BlitzPlus Forums/BlitzPlus Programming/Problem when starting Blitz Prog from Start Menu

-=Darkheart=-(Posted 2005) [#1]
When my program is started from the start menu it sets it's current directory to the location of the start menu or the users home folder, e.g. c:\Documents and Settings\Username. This causes it not to find any media or assets I need it to use.

There is a simple fix which is to set the "Start in" section of the shortcut however I've not found any way of doing this automatically as part of the install routine. As I don't want to have to screen a message saying, "Dear user please edit your shortcut", I'm not sure what to do.

Is there any way of setting the current directory for the application to the place where the application is installed (i.e. the location of the program executeable) so that when my program starts in c:\program files\my program\myprog.exe it will look in the directory of the program and NOT in any other location? CurrentDIR$ always returns the location of the $HOME for the user (yes I've tested).

I think there must be a way of doing this but I can't find it, any help gratefully recieved.

I know it sounds evil but to me the registry sounds like the answer here...

Thanks,

Darkheart


keyboard(Posted 2005) [#2]
I've never had a problem with starting a program from the start menu, I wonder what is going on? sorry I have no help, just to say that it hasn't happened here...


fredborg(Posted 2005) [#3]
This should do the trick: http://www.blitzbasic.com/codearcs/codearcs.php?code=1276


keyboard(Posted 2005) [#4]
@fredborg can you elaborate? this has not happened to me, can you say why it happens? cheers.


fredborg(Posted 2005) [#5]
It happens because when you start a program from a shortcut on the PC, the program is informed that it is started from the directory of the shortcut instead of the directory where the executable is located.

This means that if your game needs to load some files, it will look for them in the directory where the shortcut is located. This is often not what you want, and if you fail to change the game directory to the real one, it is likely to result in a crash.


-=Darkheart=-(Posted 2005) [#6]
Ah, Fredborg you are my hero! I searched the codearchs and completely missed that.

Thanks a lot, just what I needed.

Darkheart