| | |
can i get the full file path from specified file name (.exe)
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
...but that is not guaranteed. It is usually a safe bet that it contains at least the simple name of the executable ("foo.exe"). It may also contain either an absolute path or a relative path.
On POSIX systems (Unix, Linux, Mac OS X, etc), use getcwd() and combine the result with argv[0].
On Win32, use GetModuleFileName().
Hope this helps.
On POSIX systems (Unix, Linux, Mac OS X, etc), use getcwd() and combine the result with argv[0].
On Win32, use GetModuleFileName().
Hope this helps.
>>but that is not guaranteed
Yes I know, which is why I made the qualified statement. Only some compilers do that.
getcwd() only gets the current working directory, which is also available in MS-Windows. If the program changes directories before calling getcwd() itt will not give you what you are looking for, assuming you want the path to the *.exe file.
I don't know if there is a POSIX equivalent to GetModueFileName(), but getcwd() is not it.
Yes I know, which is why I made the qualified statement. Only some compilers do that.
getcwd() only gets the current working directory, which is also available in MS-Windows. If the program changes directories before calling getcwd() itt will not give you what you are looking for, assuming you want the path to the *.exe file.
I don't know if there is a POSIX equivalent to GetModueFileName(), but getcwd() is not it.
Last edited by Ancient Dragon; Jul 5th, 2008 at 6:48 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- .exe Troubles. Help Needed. (Viruses, Spyware and other Nasties)
- getting rid of Admilliserve log file (Viruses, Spyware and other Nasties)
- About;Blank Please Help, Hijack Log File (Viruses, Spyware and other Nasties)
- Hijack this log - TAPIAP.EXE (Viruses, Spyware and other Nasties)
- "MiCr0s0ft.exe", "Microsoftx.exe" & "ns.exe" viruses?Please Help (Viruses, Spyware and other Nasties)
- HiJackThis log........JUGS BODY.EXE (Viruses, Spyware and other Nasties)
Other Threads in the C++ Forum
- Previous Thread: Size of array passed as parameter.
- Next Thread: Couldn't pass variable values to another form
| Thread Tools | Search this Thread |
api array beginner bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion count database delete desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






