File:  [OS/2 SDKs] / os2sdk / demos / examples / getenv / getenv.c
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 12:26:13 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: os2sdk-1988, HEAD
Microsoft OS/2 SDK 03-01-1988

/*
 * Example of DosGenEnv usage
 *
 * This call gets the addresses of the environment strings and command
 * line arguments belonging to the current process
 *
 * Compile as: cl -AL -Lp -G0 getenv.c
 *
 * Created by Microsoft Corp. 1986
 */

#define INCL_DOSMISC

#include <os2def.h>
#include <bsedos.h>

main()
{
	USHORT EnvSegment;	/* Segment handle to the env strings */
	USHORT CmdOffset;	/* Offset within EnvSegment where the
				   command line arguments can be found */
	char *arg;		/* Pointer to data */

	DosGetEnv(&EnvSegment,&CmdOffset); /* Get environment information */

	/* Set arg to point to the environment strings */
	arg = (char *)((long)EnvSegment << 16);

	/* Print first environment string */
	printf("Environment parameter #1: %s\n",arg);

	/* Set arg to point to the command line arguments */
	arg = (char *)(((long)EnvSegment << 16) + CmdOffset);

	/* Print first command line argument */
	printf("Command line argument #1: %s\n",arg);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.