An Extended LIBPATH is a path which is searched in conjunction with the system LIBPATH, but which can be changed dynamically, either by the user from the command line, or by an application. There are two Extended LIBPATHs: BeginLIBPATH, which is searched before the system LIBPATH, and EndLIBPATH, which is searched after the system LIBPATH.

Applications can use DosSetExtLIBPATH to set the Extended LIBPATHs. Likewise, they can use DosQueryExtLIBPATH to query the value of either of the Extended LIBPATHs. A flag parameter for the function specifies whether the BeginLIBPATH or the EndLIBPATH is being set or queried. The flag allows two values: BEGIN_LIBPATH (1) which will set or query BeginLIBPATH, or END_LIBPATH (2) which will set or query EndLIBPATH.

Extended LIBPATHs are ASCIIZ strings which are formatted in the same manner as the system LIBPATH, that is, they contains a list of subdirectory paths separated by semicolons. The string argument can be up to 1024 characters and will return an error if longer.

The following example updates the path to be searched before the system LIBPATH, then queries and displays the value.

 #define INCL_DOSMISC
 #define INCL_DOSERRORS
 #include <os2.h>
 #include <stdio.h>

 UCHAR   uchBeginLIBPATH[1024] = "";       /* Begin LIBPATH value returned */
 APIRET  ulrc                  = NO_ERROR; /* Return code                  */

    ulrc = DosSetExtLIBPATH("C:\\TOOL_X\\VERS_20\\DLL",
                            BEGIN_LIBPATH);    /* Add to beginning LIBPATH */

    if (ulrc != NO_ERROR) {
        printf("DosSetExtLIBPATH error: return code = %u\n",
               ulrc);
        return 1;
    }

    ulrc = DosQueryExtLIBPATH(uchBeginLIBPATH,
                              BEGIN_LIBPATH);   /* Query the BeginLIBPATH */

    if (ulrc != NO_ERROR) {
        printf("DosQueryExtLIBPATH error: return code = %u\n",
               ulrc);
        return 1;
    }

    printf(" BeginLIBPATH = %s\n",
           uchBeginLIBPATH);


[Back] [Next]