0

Hello guys. How can i get my file path? I konw my program's name but i don't know where it will be put. How can i get file path during program's execution?
Thank you

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by William Hemsworth
1

Try a WinAPI call to GetModuleFileName()

Edited by nbaztec: n/a

0

If you're using windows, try:

#include <windows.h>
#include <iostream>
using namespace std;

int main() {
  char szFileName[MAX_PATH];
  HINSTANCE hInstance = GetModuleHandle(NULL);
  GetModuleFileName(hInstance, szFileName, MAX_PATH);
  cout << szFileName;
  cin.ignore();
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.