Click to See Complete Forum and Search --> : How does MAX_PATH work?


eviltoylet
April 17th, 2003, 12:51 PM
I was wondering how the following segment worked. there was no definition of MAX_PATH anywhere. Is it some internal definition that I'm not aware of?

[QUOTE]
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "";

//Some structure definitions are here
...
ofn.nMaxFile = MAX_PATH;

I was wondering if there was anyway to do the same thing to get the maximum length of the filename , without the path?

thanks.

fellowDeveloper
April 17th, 2003, 01:31 PM
MAX_PATH is just an identifier that is defined as the integer constant 256 (or 260 in some cases). It's defined as:

#define MAX_PATH 256

Therefore, when you declare a character array of size MAX_PATH, you are declaring a character array of size 256.

The maximum length of a filename is MAX_FNAME which is equal to 64.

eviltoylet
April 17th, 2003, 01:33 PM
gotcha. thanks. I thought it might have been some dynamic thing i was unaware of :D

eviltoylet
April 17th, 2003, 01:35 PM
'nother question. anyone know what header file it's defined in? MAX_FNAME doesn't work for me.

fellowDeveloper
April 17th, 2003, 01:49 PM
Use _MAX_PATH and _MAX_FNAME. These are both defined in stdlib.h.