Created
April 4, 2014 14:42
-
-
Save orzFly/9976088 to your computer and use it in GitHub Desktop.
very simple "which" alternative for Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <windows.h> | |
int main(int argc, char **argv) | |
{ | |
if (argc == 2) | |
{ | |
char path[MAX_PATH]; | |
HINSTANCE ret = FindExecutable(argv[1], 0, path); | |
if ((int)ret > 32) | |
puts(path); | |
else | |
{ | |
fprintf(stderr, "WHICH: cannot found %s (FindExecutable returned %d)\n", argv[1], ret); | |
return 1; | |
} | |
} | |
else | |
{ | |
printf("Finds first or all executables on path, or which executable is associated with a document file or extension.\n\nWHICH command\n\n command - Command name.\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment