Can someone tell me how to find the path of a file that is in the same directory where the executable file is? I tried using the GetFullPathName() function but I think I did something wrong. Thanks.
Can someone tell me how to find the path of a file that is in the same directory where the executable file is? I tried using the GetFullPathName() function but I think I did something wrong. Thanks.
getcwd() will tell you the current working directory.
Post your attempt at getting GetFullPathName() to work.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Code:#include <windows.h> char path[100]; GetFullPathName("cliente.html", sizeof(path), path, NULL);
Last edited by dwks; 08-07-2005 at 12:35 PM.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
I'm trying to open a .html file that is located in the same directory where the executable file is with the default browser but this is not working. What am I doing wrong now? Thanks.Code:#include <windows.h> char path[100] = ""; char *filename[100] = {NULL}; FindExecutable("cliente.html", NULL, linha); GetFullPathName("cliente.html", sizeof(path), path, filename); ShellExecute(NULL, "open", linha, filename, NULL, SW_MAXIMIZE);
You can get the path to the current executable with GetModuleFileName. There is no need to call FindExecutable.
Code:#include <windows.h> #include <shlwapi.h> #if defined(_MSC_VER) # pragma comment(lib, "shlwapi.lib") #endif TCHAR szExePath[MAX_PATH]; TCHAR szHtmlPath[MAX_PATH]; GetModuleFileName(NULL, szExePath, MAX_PATH); // eg. C:\test\myprogram.exe PathRemoveFileSpec(szExePath); // eg. C:\test PathCombine(szHtmlPath, szExePath, TEXT("cliente.html")); // eg. C:\test\cliente.html ShellExecute(NULL, TEXT("open"), szHtmlPath, NULL, NULL, SW_MAXIMIZE);
Thank you
Can you please explain the marked line, what does it mean by "module"?
Thank you.
Originally Posted by anonytmouse
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
Module, as in executable file or .dll or something like that, I think.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.