Skip to content

Instantly share code, notes, and snippets.

@iwadon
Created March 23, 2011 01:20
Show Gist options
  • Select an option

  • Save iwadon/882452 to your computer and use it in GitHub Desktop.

Select an option

Save iwadon/882452 to your computer and use it in GitHub Desktop.
PathFindOnFile() sample.
/* cl pfop_sample.c shlwapi.lib */
#include <stdio.h>
#include <shlwapi.h>
int main()
{
BOOL bOk;
char buf[MAX_PATH] = {0};
/* (A) Set path as relative filename */
strcpy(buf, ".\\pfop_sample.exe");
bOk = PathFindOnPath(buf, NULL);
printf("(A) bOk=%s\n", bOk ? "TRUE" : "FALSE"); /* => bOk=FALSE */
/* (B) Set separated path */
strcpy(buf, "pfop_sample.exe");
{
const char *other_dirs[] = {".", NULL};
bOk = PathFindOnPath(buf, other_dirs);
}
printf("(B) bOk=%s\n", bOk ? "TRUE" : "FALSE"); /* => bOk=TRUE */
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment