home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ukma!gatech!swrinde!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!uicvm.uic.edu!u09046
- Organization: University of Illinois at Chicago
- Date: Sun, 24 Jan 1993 11:45:03 CST
- From: Bob Jackiewicz <U09046@uicvm.uic.edu>
- Message-ID: <93024.114503U09046@uicvm.uic.edu>
- Newsgroups: comp.os.os2.programmer
- Subject: Help with DosScanEnv/DosSearchPath
- Lines: 53
-
- Am I going nuts? The small file enclosed below is the one which is listed
- in the online reference (CP Reference). However, when I try to run it,
- it says that the environment variable is not found. How can it not find
- PATH? I also tried with LIBPATH, DPATH, and others. I'm using CSD 28 (CSet/2)
- and GA+SP. Is there some call I need to make before I run this?? I've tried
- this with DosScanEnv and DosSearchPath, and with just DosSearchPath with
- the proper vector set (I think). I've also tried putting the ENVVARNAME and
- FILENAME into regular strings, with no better luck. Any help is appreciated.
-
- #define INCL_DOSFILEMGR
- #include <os2.h>
- #include <stdio.h>
-
- #define ENVVARNAME "PATH" /* Environment variable name */
- #define FILENAME "test.c" /* File for which to search */
-
- main() {
- PSZ ResultPointer; /* Environment scan result
- pointer (returned) */
- BYTE ResultBuffer[128]; /* Path search result
- (returned) */
- APIRET rc; /* Return code */
-
- /** Scan environment segment for PATH; notice the far-string **/
- /** pointer specification ("%Fs") used to print. **/
-
- if(!(rc=DosScanEnv(ENVVARNAME, /* Environment variable name */
- ResultPointer))) /* Scan result pointer
- (returned) */
- printf("%s is %Fs\n", ENVVARNAME, ResultPointer);
-
- /* This comes out as 203, environment variable not found */
- printf("RC 1 = %d\n", rc);
- /** Search current directory + PATH variable for "test.c" **/
- if(!(rc=DosSearchPath(SEARCH_CUR_DIRECTORY, /* Search control
- vector */
- ENVVARNAME, /* Search path reference
- string */
- FILENAME, /* File name string */
- ResultBuffer, /* Search result
- (returned) */
- sizeof(ResultBuffer)))) /* Length of search
- result */
- printf("Found desired file -- %s\n", ResultBuffer);
-
- /* This comes out as 2, file not found */
- printf("RC 2 = %d\n", rc);
- }
-
- Brought to you by the sick mind of University of Illinois at Chicago
- Bob Jackiewicz, writer of wrongs, BITNET: U09046@UICVM
- wronger of rights; not UIC. InterNet: U09046@uicvm.uic.edu
- "640K ought to be enough for anybody." - Bill Gates, 1981
-