LIBPATH LIBPATH attempts to find out the value of the LIBPATH environment variable. This cannot be returned from the regular environment SET command, or a DosQuery...API. Occasionally the LIBPATH variable is a handy thing to know. So, a not-so-clean solution is to find the value of the boot drive, find the CONFIG.SYS file, and attempt to extract the LIBPATH string from that file. This will only work in a case where there have been no previous changes to the CONFIG.SYS file since the system ha been booted, and specifically no direct manipulations of the LIBPATH value. Although this example is a crude kluge, the method can actually be useful on a number of occasions. *********************************************************** * LIBPATH.C * *********************************************************** #define INCL_DOSFILEMGR #define INCL_DOSMISC #include #include #include #include #include #define CONFIG_FILE "?:\\CONFIG.SYS" #define LIBPATH "LIBPATH" #define CR 13 #define LF 10 INT main ( VOID ) { APIRET arReturn ; ULONG ulDrive; PCHAR pchFile ; HFILE hfFile ; ULONG ulAction ; ULONG ulBytesRead ; PCHAR pchBuffer ; PCHAR pchLibpath ; USHORT usIndex ; FILESTATUS3 fsStatus ; pchBuffer = NULL ; arReturn = DosQuerySysInfo ( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulDrive, sizeof ( ulDrive )) ; pchFile = CONFIG_FILE ; pchFile [0] = ulDrive + 'A' - 1 ; arReturn = DosQueryPathInfo ( pchFile, FIL_STANDARD, &fsStatus, sizeof ( fsStatus )) ; pchBuffer = malloc ( fsStatus.cbFile ) ; arReturn = DosOpen ( pchFile, &hfFile, &ulAction, 0, FILE_NORMAL, FILE_OPEN, OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL ) ; arReturn = DosRead ( hfFile, pchBuffer, fsStatus.cbFile, &ulBytesRead ) ; arReturn = DosClose ( hfFile ) ; pchBuffer [fsStatus.cbFile] = 0 ; pchLibpath = strstr ( pchBuffer, LIBPATH ) ; if (pchLibpath == NULL){ /*will only execute this section of code if LIBPATH is NOT all caps*/ for ( usIndex = 0; usIndex < strlen (pchBuffer); usIndex++){ if (toupper(pchBuffer[usIndex]) == 'L') if (toupper(pchBuffer[usIndex+1]) == 'I' && toupper(pchBuffer[usIndex+2]) == 'B' && toupper(pchBuffer[usIndex+3]) == 'P' && toupper(pchBuffer[usIndex+4]) == 'A' && toupper(pchBuffer[usIndex+5]) == 'T' && toupper(pchBuffer[usIndex+6]) == 'H'){ pchLibpath = pchBuffer + usIndex; break; } } } for ( usIndex = 0 ; usIndex < CCHMAXPATHCOMP ; usIndex++ ){ if ( pchLibpath [usIndex] == CR ){ if ( pchLibpath [usIndex + 1] == LF ) break ; } /* endif */ } /* endfor */ pchLibpath [usIndex] = 0 ; printf ( "\n%s\n", pchLibpath ) ; free ( pchBuffer ) ; return arReturn ; } *********************************************************** * LIBPATH.MAK * *********************************************************** LIBPATH.EXE: LIBPATH.OBJ LINK386 @<< LIBPATH LIBPATH LIBPATH OS2386 LIBPATH << LIBPATH.OBJ: LIBPATH.C ICC -C+ -Kb+ -Ss+ LIBPATH.C *********************************************************** * LIBPATH.DEF * *********************************************************** NAME LIBPATH WINDOWCOMPAT NEWFILES DESCRIPTION 'LIBPATH Example Copyright (c) 1993 by Arthur Panov All rights reserved.' PROTMODE +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + NOTICE + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ The LIBPATH example is from The Art of OS/2 C Programming by Kathleen Panov, Arthur Panov, and Larry Salomon, Jr., August 1993, published by QED Publishing Group, ISBN 0-89435-446-9. The example was uploaded by the publisher with the assistance of the authors for use by Forum members. Please address comments to QED at 76620,2720.