NeedCurrentDirectoryForExePathA function (processenv.h)
Determines whether the current directory should be included in the search path for the specified executable.
BOOL NeedCurrentDirectoryForExePathA( [in] LPCSTR ExeName );
The name of the executable file.
If the current directory should be part of the search path, the return value is TRUE. Otherwise, the return value is FALSE.
This function should only be called in instances where the caller must explicitly resolve a relative executable name to an absolute name. If CreateProcess is called with a relative executable name, it will automatically search for the executable, calling this function to determine the search path.
Most system functions perform their own path resolution, therefore, this function should only be called if you are attempting to resolve a search path for the specified executable based on the current directory.
The value of the NoDefaultCurrentDirectoryInExePath environment variable determines the value this function returns. However, you should call this function rather than checking the environment variable directly, as the registry location of this environment variable can change.
If the value of the ExeName parameter contains a backslash (\), this function will always return TRUE. If it does not contain a backslash, the existence of the NoDefaultCurrentDirectoryInExePath environment variable is checked, and not its value.
An example of an instance when this function should be called instead of relying on the default search path resolution algorithm in CreateProcess is the "cmd.exe" executable. It calls this function to determine the command search path because it does its own path resolution before calling CreateProcess. If this function returns TRUE, cmd.exe uses the path ".;%PATH%" for the executable search. If it returns FALSE, cmd.exe uses the path "%PATH%" for the search.
The processenv.h header defines NeedCurrentDirectoryForExePath as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
|Minimum supported client||Windows Vista [desktop apps only]|
|Minimum supported server||Windows Server 2003 [desktop apps only]|
|Header||processenv.h (include Windows Vista, Windows 7, Windows Server 2008 Windows Server 2008 R2, Windows.h)|