home *** CD-ROM | disk | FTP | other *** search
- #define INCL_DOSPROCESS
- #include <os2.h>
- #include <string.h>
-
- char *loadpath(void)
- {
- PTIB pptib;
- PPIB pppib;
- char *szPath;
-
- DosGetInfoBlocks(&pptib, &pppib);
- szPath = pppib -> pib_pchenv;
-
- while (*szPath)
- szPath = strchr(szPath, 0) + 1;
-
- return szPath + 1;
- }
-
- char *execpath(char *szProg)
- {
- static char *szLpath;
- static char szPath[CCHMAXPATH];
- char *szPtr;
-
- if (!szLpath)
- szLpath = loadpath();
-
- strcpy(szPath, szLpath);
- szPtr = strrchr(szPath, '\\');
- strcpy(szPtr + 1, szProg);
- szPtr = strrchr(szPath, '.');
- if (szPtr == NULL || stricmp(szPtr, ".exe"))
- strcat(szPath, ".exe");
-
- return access(szPath, 0) == 0 ? szPath : szProg;
- }
-