Created On:  25 October 2012

Problem:

In a runtime session, it is easy to obtain TMP / TEMP path by reading environment variables. Is it possible to read client machines paths from within a Thin Client session?

Resolution:

To obtain client machine paths, a Windows API can be used.

This is a brief COBOL program that explains how to call this DLL.

       IDENTIFICATION DIVISION.
PROGRAM-ID. getPATH.
REMARKS.
ENVIRONMENT DIVISION.
SPECIAL-NAMES.
DECIMAL-POINT IS COMMA.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
COPY "ACUCOBOL.DEF".
01 WS-PATH PIC X(200).
LINKAGE SECTION.
SCREEN SECTION.
PROCEDURE DIVISION.
MAIN-LOGIC.
ACCEPT TERMINAL-ABILITIES FROM TERMINAL-INFO
IF IS-REMOTE
SET ENVIRONMENT "DLL_CONVENTION" TO "1"
CALL "@[DISPLAY]:kernel32.dll@WINAPI"
CALL "@[DISPLAY]:GetTempPathA" USING BY VALUE 200
BY REFERENCE WS-PATH
SET ENVIRONMENT "DLL_CONVENTION" TO "0"
ELSE
ACCEPT WS-PATH FROM ENVIRONMENT "TMP"
END-IF
DISPLAY MESSAGE BOX WS-PATH
STOP RUN.

Incident #2283929