Re: [Dev-C++] How to get application directory?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <or...@vp...> - 2004-03-09 21:06:05
|
Josep Subirana wrote: > Do you know how to get the directory where your c++ application is runn= ing > in? > This should be a simple question for most experienced c++ programmers! __argv[0] has the entire path to your application binary. For example: "C:\Programs\MyProg.exe" All you need to do, is to strip off "MyProg.exe" (your app name). I suspect you wish to save config files, eh? :) (Well, at least that was why I needed to search for a solution a few=20 years ago, and that's what I found). One last note: I used __argv because if you have a WinMain in you=20 program, then you don't have argv simply. But __argv is always present=20 (as well as __argc), it is global, and has the same contents as argv and=20 argc would (at least in MinGW). -- Greetings, Bal=E1zs |