Highlighted
Absent Member.
Absent Member.
814 views

[archive] Get My Dcouments / Documents folder

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

I recently needed to set the default directory for c$opensavebox to the users local personal data folder(my documents or documents on vista). One approach was to retrieve the USERPROFILE environment variable and append "my documents" to it, but I decided this may not be reliable. Instead, I used the SHGetFolderPath windows api function. Here's a sample for anyone who might also find it useful. Thin-client is detected in the TERMINAL-ABILITIES. I'm not sure if this api call will trigger a UAC warning in Vista.

**Note: For thin-client compatability compile with the -Zm switch so that pointers are passed with memory size(this seems to work better than using CALL "WITH MEMORY SIZE" - see section 6.5.6.3 Passing pointers in DLL calls in the AcuConnect user Guide). Also, remember the "@[DISPLAY]:" prefix before the DLL and function name.

In Working Storage:

77 NULL-HANDLE      UNSIGNED-INT VALUE NULL.
77 WS-BUFFER        PIC X(255) VALUE NULL.
77 PTR-WS-BUFFER    USAGE POINTER VALUE NULL.
77 FUNCTION-NAME    PIC X(50) VALUE SPACES.
COPY "ACUCOBOL.DEF".


In Procedure Division:

           SET ENVIRONMENT "DLL-CONVENTION" TO 1.

           ACCEPT TERMINAL-ABILITIES FROM TERMINAL-INFO.
           IF IS-REMOTE
              CALL "@[DISPLAY]:SHELL32.DLL"
              MOVE "@[DISPLAY]:SHGetFolderPathA" TO FUNCTION-NAME
           ELSE
              CALL "SHELL32.DLL"
              MOVE "SHGetFolderPathA" TO FUNCTION-NAME
           END-IF.
           MOVE NULL TO WS-BUFFER.
           SET PTR-WS-BUFFER TO ADDRESS OF WS-BUFFER.
           CALL FUNCTION-NAME USING
               BY VALUE NULL-HANDLE
               BY VALUE 5 |CSIDL_PERSONAL = &H5
               BY VALUE NULL-HANDLE
               BY VALUE 0
               BY VALUE PTR-WS-BUFFER
               ON EXCEPTION CONTINUE
               NOT ON EXCEPTION
                   STRING WS-BUFFER DELIMITED BY NULL
                       INTO OPNSAV-DEFAULT-DIR
           END-CALL.

           IF IS-REMOTE
              CANCEL "@[DISPLAY]:SHELL32.DLL"
           ELSE
              CANCEL "SHELL32.DLL"
           END-IF.
0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Get My Dcouments / Documents folder

Thank you for posting this Dan!

Gisle
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Get My Dcouments / Documents folder

This is a handy API call, and it works fine under 6.1.0 using both wrun32.exe and acuthin.exe. AND it works fine using wrun32.exe using 8.1.1 but it just explodes with an error using authin.exe with the standard Acucobol-GT Thin Client error:

ACUCOBOL-GT Thin Client has encountered a problem and needs to close. We are sorry for the inconvenience.

If you were in the middle of something the information you were working on might be lost.


Anyone using this call and have it working under 8.1.1 thin client? I may have to submit to support.
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.