Thread: RE: [GD-Windows] Program directory
Brought to you by:
vexxed72
From: Jacob T. (C. D. Ltd) <Ja...@Co...> - 2002-06-11 12:26:29
|
Isn't argument 0 to main the full path for the executable. I think you can still get at the command line even if you are a windows = app and not a console app. -----Original Message----- From: Ignacio Casta=F1o [mailto:cas...@ya...] Sent: 11 June 2002 13:27 To: gam...@li... Subject: [GD-Windows] Program directory Hi, I would like to know how to retrieve the path where the program being executed is. Usually it's the current working directory, that you can = get with getcwd, but in some cases that's not true. For example, when the program is in the path or when you simply do: folder\program.exe Is there any safe way of doing this? I could save the name of the directory during installation or something = like that, but actually my program doesn't have any installation, so I would prefer another option. Ignacio Casta=F1o cas...@ya... _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com _______________________________________________________________ Don't miss the 2002 Sprint PCS Application Developer's Conference August 25-28 in Las Vegas - http://devcon.sprintpcs.com/adp/index.cfm?source=3Dosdntextlink _______________________________________________ Gamedevlists-windows mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=3D555 |
From: Aaron B. <aar...@po...> - 2002-06-11 16:29:11
|
> > I think you can still get at the command line even if you are > a windows app > and not a console app. > Yep, GetCommandLine() will do that. Aaron. __________________________________________________________________ Aaron Burton PowerVR Developer Relations Engineer PowerVR Technologies A Division of Imagination Technologies Ltd Home Park Estate, ph:+44 1923 260511 Kings Langley, Herts, WD4 8LZ, UK www.powervr.com www.pvrdev.com __________________________________________________________________ |
From: Andrew G. <ag...@cl...> - 2002-06-11 16:44:36
|
This way is unreliable, don't do it. Under an NT kernel the presence of a path on the command line depends on how your program was started. Ditto using argv[0] as someone suggested.. Andrew Grant- Climax Brighton > -----Original Message----- > From: Aaron Burton [mailto:aar...@po...] > Sent: 11 June 2002 17:29 > To: gam...@li... > Subject: RE: [GD-Windows] Program directory > > > > > > I think you can still get at the command line even if you are > > a windows app > > and not a console app. > > > > Yep, GetCommandLine() will do that. > > Aaron. > > |
From: Gareth L. <GL...@cl...> - 2002-06-12 10:06:39
|
Yes, the define _MAX_PATH and it's friends are well worth using in = cases like this. Sadly GetModuleFileName doesn't return the length if the buffer you = give is too small, unlike other API calls. Regards, Gareth Lewin -----Original Message----- From: Ignacio Casta=F1o [mailto:cas...@ya...] Sent: 11 June 2002 21:00 To: gam...@li... Subject: Re: [GD-Windows] Program directory Javier Arevalo wrote: > > I would like to know how to retrieve the path where the program = being > > executed is. > > TCHAR szExeFilename[300]; > ::GetModuleFileName(NULL, szExeFilename, > sizeof(szExeFilename)/sizeof(szExeFilename[0])); That works fine, thanks! BTW, I once had problems with those hardcoded string names when one = client installed my application under a very long file path... Ignacio Casta=F1o cas...@ya... _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com _______________________________________________________________ Multimillion Dollar Computer Inventory Live Webcast Auctions Thru Aug. 2002 - http://www.cowanalexander.com/calendar _______________________________________________ Gamedevlists-windows mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=3D555 |
From: <cas...@ya...> - 2002-06-12 21:39:39
|
Interestingly _MAX_PATH is defined to 260, and my max path was longer than that, so it seems that I was doing something else wrong. Ignacio Castaño cas...@ya... Gareth Lewin wrote: Yes, the define _MAX_PATH and it's friends are well worth using in cases like this. Sadly GetModuleFileName doesn't return the length if the buffer you give is too small, unlike other API calls. _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com |
From: Weston F. <we...@ml...> - 2002-06-13 04:29:59
|
I've always used: char Path[512]; not say that you can't have a path that long... But it fairly unlikely... ----- Original Message ----- From: "Ignacio Castaño" <cas...@ya...> To: "Gareth Lewin" <GL...@cl...>; <gam...@li...> Sent: Wednesday, June 12, 2002 3:34 PM Subject: Re: [GD-Windows] Program directory > Interestingly _MAX_PATH is defined to 260, and my max path was longer than > that, so it seems that I was doing something else wrong. > > > Ignacio Castaño > cas...@ya... > > > Gareth Lewin wrote: > Yes, the define _MAX_PATH and it's friends are well worth using in cases > like this. > > Sadly GetModuleFileName doesn't return the length if the buffer you give is > too small, unlike other API calls. > > > > _________________________________________________________ > Do You Yahoo!? > Get your free @yahoo.com address at http://mail.yahoo.com > > > _______________________________________________________________ > > Sponsored by: > ThinkGeek at http://www.ThinkGeek.com/ > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 |