How to find the path of my current running application
-
vov, hamid, i tried it. it gave me the filename which iam running, like, d:\myapp\debug\myapp.exe. this will do for me. what all i want from this string is upto debug. may be i can do some parsing logic here to remove the myapp.exe. i would be pleased if you can suggest that for me. got my 5? thank you.
See
PathRemoveFileSpec()
Real men drive manual transmission.
-
vov, hamid, i tried it. it gave me the filename which iam running, like, d:\myapp\debug\myapp.exe. this will do for me. what all i want from this string is upto debug. may be i can do some parsing logic here to remove the myapp.exe. i would be pleased if you can suggest that for me. got my 5? thank you.
Yeah you can use of CString::Left for get full string of some strings of left. (one thing that it doesnt relative to your answer see my thread on the lonuge I saw a good site with nice wallpaper of milky way )
-
vov, hamid, i tried it. it gave me the filename which iam running, like, d:\myapp\debug\myapp.exe. this will do for me. what all i want from this string is upto debug. may be i can do some parsing logic here to remove the myapp.exe. i would be pleased if you can suggest that for me. got my 5? thank you.
_splitpath[^] in the CRT lib.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown -
Yeah you can use of CString::Left for get full string of some strings of left. (one thing that it doesnt relative to your answer see my thread on the lonuge I saw a good site with nice wallpaper of milky way )
-
Im sorry but I dont understand what you said?
-
Here you go, this should do what you want.
TCHAR szBuffer[_MAX_PATH] = {'\0'};
DWORD dwLen = _MAX_PATH;GetModuleFileName(GetModuleHandle(NULL), szBuffer, dwLen);
Jonathan Wilkes Darka[Xanya.net]
-
Im sorry but I dont understand what you said?
-
_splitpath[^] in the CRT lib.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown -
no boss i'm still getting the recent selected file's folder by the user. thanks for your concern.
is you application is executable or dll!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
hai friends, my problem is like this. in my program, (say for example) i will allow the user to select a file, any where in the computer. now after file selection, i have to create one file in the folder, where my program is available. i donot give any path while creation. i will simply use open(file1,write). but this file is created, in the folder, where the selected file is available. is there any api, which can fetch me the path of the current working folder, such that, i can save my folder there? thanks for your views.
Try with...
CString m_szNewFileName = "";
char FileName[MAX_PATH];
GetModuleFileName(NULL, FileName, MAX_PATH);
m_szNewFileName = FileName;
m_szNewFileName = m_szNewFileName.Left(m_szNewFileName.ReverseFind('\\'));
m_szNewFileName += "DesiredNewName.ext"CFile f (m_szNewFileName, CFile::modeCreate | CFile::modeWrite);
it worked good for me. This would create the new file in the forlder where the App.exe is. And afterwards you can delete the file with:
if (f.Open (m_szNewFileName, CFile::modeRead))
{ f.Close ();
f.Remove (m_szNewFileName);
}EDIT: Nice, my post is the newest one, but has the answers of the post just above (older than mine):doh: :P -- modified at 5:21 Monday 29th October, 2007 -- modified at 5:22 Monday 29th October, 2007
Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)