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.
Printable View
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.
Code:#include <windows.h>
char path[100];
GetFullPathName("cliente.html", sizeof(path), path, NULL);
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.
Quote:
Originally Posted by anonytmouse
Module, as in executable file or .dll or something like that, I think.