NeedCurrentDirectoryForExePathA function

Determines whether the current directory should be included in the search path for the specified executable.

Syntax

BOOL NeedCurrentDirectoryForExePathA(
  LPCSTR ExeName
);

Parameters

ExeName

The name of the executable file.

Return Value

If the current directory should be part of the search path, the return value is TRUE. Otherwise, the return value is FALSE.

Remarks

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.

Requirements

   
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header processenv.h (include Windows Vista, Windows 7, Windows Server 2008 Windows Server 2008 R2, Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See Also

CreateProcess

Process and Thread Functions