Syntax
#include <stdlib.h> void _searchenv(char *name, char *env_var, char *path);Description
The routine first searches for the file in the current working directory. If it does not find the file, it next looks through the directories specified by the environment variable.
If the target file is found in one of the directories, the fully-qualified file name is copied into the buffer that path points to. You must ensure sufficient space for the constructed file name. If the target file is not found, path contains an empty null-terminated string.
There is no return value.
This example searches for the files searchen.c and cmd.exe.
#include <stdio.h> #include <stdlib.h> int main(void) { char path_buffer[_MAX_PATH]; _searchenv("cmd.exe", "PATH", path_buffer); printf("path: %s\n", path_buffer); _searchenv("_searche.c", "DPATH", path_buffer); printf("path: %s\n", path_buffer); return 0; /**************************************************************************** The output should be similar to: path: C:\OS2\cmd.exe path: C:\src\_searche.c ****************************************************************************/ }Related Information