Windows API

ID #1020

How to read from application environment variable?

You need use Windows API function GetEnvironmentVariable. Let see the example for reading of content %TEMP%:
MAP
  MODULE('kernel32.lib')
GetEnvironmentVariable(*CSTRING lpName,*CSTRING lpBuffer,ULONG nSize), |
    ULONG,RAW,PASCAL,PROC,
  END
END
! Data Section
EnvVariable       CSTRING('TEMP')
EnvVariableBuffer CSTRING(255)
EnvVariableSize   ULONG
! Code Section
EnvVariableSize = SIZE(EnvVariableBuffer)
GetEnvironmentVariable(EnvVariable,EnvVariableBuffer,EnvVariableSize)
MESSAGE('Your temporary directory is: ' & EnvVariableBuffer)

Tags: environment

Related entries:

Last update: 2007-07-17 09:30
Author: Aleksey Timkov
Revision: 1.6

Digg it! Print this record Send to a friend Show this as PDF file
Propose a translation for Propose a translation for
Please rate this entry:

Average rating: 5 out of 5 (1 Votes )

completely useless 1 2 3 4 5 most valuable

You can comment on this entry