is there a way to get a running exe to find out where it is in the file system?
is there a way to get a running exe to find out where it is in the file system?
"If you tell the truth, you don't have to remember anything"
-Mark Twain
no as far as far is normalality goes. but u can probally find a way using 8 million lines of code for it to do that. well not 8 million but you get the point. something like this isnt usualy done. because where the exe is in is like its root directory and it cant put files in directories under its location unless u do something special. you can do almost anything in programming of most languages. its just some things arent normaly done. for instance cout is known worlwide to c++ programmers and used a lot. but its not very ocasanial that the program has to know its location
in windows it's GetModuleFileName(). This gives you the full path to the module. on other systems I can't help youOriginally posted by CodeMonkey
is there a way to get a running exe to find out where it is in the file system?
.... and a Unix way
[edit] Nope that's not what you asked for, I don't think. This will get you the current working directory, not the location of the program itself. Which is it you want?
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
are you talking in a console app or windows?
To get the working directory of the Current Process you can use GetCurrentDirectory API from Kernel32, or if you wish to enumerate the working directories of other processes you can use GetModuleFileName API(like FillYourBrain said). PSAPI can be found in psapi.h and you'll probably have to link psapi.lib, if you are missing those dependencies then you can find them from the Platform SDK: Performance Monitoring section. Microsoft has well written samples on how to enumerate running processes and their directories so MSDN should be beneficial, so give that a try and if you require further help on an API from psapi then just post your question. Good luck.
getcwd(buffer, max_bufflen);
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }