0

Hi , ppl,

I want to get the absolute file path of my c++ app,

I tried searching through io.h, but alas , I don't know what the function is.:sad:

I am using Dev C++ under Windows.


Thanks a lot,

Ishwar

3
Contributors
4
Replies
5
Views
12 Years
Discussion Span
Last Post by ishwar
0
int main(int argc, char *argv[])
{
   printf("%s\n", argv[0]);
   return 0;
}

Cool , that works in a dos box,

but i am making a windows app , and
the program's main entry point is something like this:

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

Thanks ,

Ishwar

1

You can either use

char filename[MAX_PATH];
    GetModuleFileName(NULL, filename, MAX_PATH);

or
the command line passed to WinMain

int WINAPI WinMain(HINSTANCE instance, HINSTANCE prev_instance, char* command_line, int show_command)
0

Thanks ppl,

I used

GetModuleFileName(NULL, filename, MAX_PATH);

,

and it works now

Ishwar

This topic has been dead for over six months. 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.