Highlighted
Absent Member.
Absent Member.
536 views

[archive] Computer Name

[Migrated content. Thread originally posted on 26 June 2008]

This should be an easy one. How do you pull in the computer name for use in a program?

Thanks:confused:
0 Likes
1 Reply
Highlighted
Absent Member.
Absent Member.

RE: [archive] Computer Name


       ...
      *Make a variable to hold the name.
       77  USER-NAME                PIC X(40).
       77  COMPUTER-NAME            PIC X(40).
       77  VAR-SIZE                 PIC X(4) COMP-N.
       PROCEDURE DIVISION.
       MAIN-LOGIC.
           INITIALIZE               USER-NAME.
           PERFORM GET-USER.
           INITIALIZE               COMPUTER-NAME.
           PERFORM GET-COMPUTER.
           GOBACK.
       GET-USER.
           CALL    "[EMAIL="ADVAPI32.DLL@WINAPI"]ADVAPI32.DLL@WINAPI[/EMAIL]".
           SET     VAR-SIZE         TO SIZE OF USER-NAME.
           CALL    "GetUserNameA"   USING
                   BY REFERENCE     USER-NAME
                   BY REFERENCE     VAR-SIZE.
           INSPECT USER-NAME        REPLACING ALL LOW-VALUES BY SPACE.
           CANCEL  "ADVAPI32.DLL".
           EXIT    PARAGRAPH.
       GET-COMPUTER.
           CALL    "[EMAIL="KERNEL32.DLL@WINAPI"]KERNEL32.DLL@WINAPI[/EMAIL]".
           SET     VAR-SIZE         TO SIZE OF COMPUTER-NAME.
           CALL    "GetComputerNameA" USING
                   BY REFERENCE     COMPUTER-NAME
                   BY REFERENCE     VAR-SIZE.
           INSPECT COMPUTER-NAME    REPLACING ALL LOW-VALUES BY SPACE.
           CANCEL  "KERNEL32.DLL".
           EXIT    PARAGRAPH.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.