This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

using user32.dll in acuCobol

Hi,

I want to use user32.dll in acucobol, but only for the GetClipboardData function.

I tired this but it doesn't return anything:

      

           call    user32.dll@WINAPI ON EXCEPTION DISPLAY "err start".

           CALL    "GetClipboardData" USING

                   by REFERENCE DATA-LINK

                   BY               VALUE BUF-SIZE

                   ON EXCEPTION DISPLAY "err call".

 

           DISPLAY DATA-LINK        AT 0101 ERASE EOL.

           display "end"         AT 1001 ERASE EOL.

           ACCEPT  k at 2480.

           CANCEL  "user32".

currently using clipacu.dll but that only supports win 32 bit

Thanks,

Bart Pelgrims

  • 0

    I don't recognize the   user32.dll@WINAPI syntax  As long as user32.dll in in the PATH or other environment variables that the Acu runtime uses, call "user32" should work.   www.microfocus.com/.../BKITITWINDS012.html

    SW Engineering(QA)  

    Although I am an OpenText employee, I am speaking for myself and not for OpenText.
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button

  • 0 in reply to 

    I just need a small example how to call this dll, clearly I'm doing something wrong here. This code doesn't give an error, but it neither returns the clipboard data.

  • 0 in reply to 

      This is an older example which uses a dll called clipacu.dll. I hope this helps.

    SW Engineering(QA)  

    Although I am an OpenText employee, I am speaking for myself and not for OpenText.
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button

  • 0 in reply to 

    That is the thing we need to replace as clipacu.dll doesn't work on 64-bit.... (and the link doesn't seem to work)

  • 0 in reply to 

    Based on the code you were using, I didn't see that you actually sent any data to the clipboard. This seems to work for me: 

    STRING "This is a sample transmission to clipboard"
    LOW-VALUES DELIMITED BY SIZE INTO DATA-LINK.
    call "user32.dll@WINAPI" ON EXCEPTION DISPLAY "err start".

    Typically, there is a Set and Get function. I would use the Set - to send data, then use a different COBOL data item and use Get to see if you receive the data you've placed on the clipboard

    SW Engineering(QA)  

    Although I am an OpenText employee, I am speaking for myself and not for OpenText.
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button

  • 0 in reply to 

    This code is incomplete, I actually need the call "GetClipboardData" to do the actual call. The ones I tried don't do anything.

    Something like this (but this code doesn't do anything)

    CALL "SetClipboardData" USING BY REFERENCE DATA-LINK

    BY VALUE BUF-SIZE

    Or something like that.

  • 0 in reply to 

    Yes, the user32 functions are quite different from the clipacu example. I don't have a working example, but I noticed that user32 and clipboard functions on the internet shows that OpenClipboard needs to be called. call "user32"  then call "OpenClipboard" giving my-handle.  The SetClipboardData and other functions use handles. 

    SW Engineering(QA)  

    Although I am an OpenText employee, I am speaking for myself and not for OpenText.
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button

  • 0 in reply to 

    Too bad there isn't even an example on how to use handles/user32.dll in the manual...

  • 0 in reply to 

    The examples I've seen seem to include calls to kernel32, it appear you need to provide memory space for using the clipboard. I'm not sure how best to test this, as I don't know if placing data on the clipboard makes that data to other processes / applications.

    id division.
    program-id. testclip.
    special-names.

    working-storage section.
    78 GMEM-MOVEABLE value 2.
    78 CF-TEXT value 1.
    01 hWndNewOwner pic x(4) comp-5 value zeroes.
    01 retCode pic x(4) comp-5 value zeroes.
    01 any-key pic x.
    01 myHandle pointer.
    01 myPointer pointer.
    linkage section.
    01 datatocopy pic x(30).
    procedure division.
    call "kernel32".
    call "user32".

    call "GlobalAlloc"
    using by value GMEM-MOVEABLE
    by value length of datatocopy
    returning myHandle
    end-call
    call "GlobalLock"
    using by value myHandle
    returning myPointer
    end-call
    set address of datatocopy to myPointer
    STRING "This is a sample transmission to clipboard"
    LOW-VALUES DELIMITED BY SIZE INTO
    datatocopy
    call "GetActiveWindow"
    returning hWndNewOwner
    end-call

    call "OpenClipboard"
    using by value hWndNewOwner
    returning retCode
    end-call
    if retCode = 0
    display "error"
    else
    call "EmptyClipboard"
    call "SetClipboardData"
    using by value CF-TEXT
    by reference datatocopy
    end-call
    call "CloseClipboard"
    end-if
    call "GlobalUnlock"
    using by value myHandle
    returning retCode
    end-call
    call "GlobalFree" using by value myHandle
    cancel "user32".
    cancel "kernel32".
    stop run.

    SW Engineering(QA)  

    Although I am an OpenText employee, I am speaking for myself and not for OpenText.
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button

  • 0 in reply to 

    This is great, and it works, but I'm looking for the GetClipboardData, not the Set. I tried to adapt it to do this, but so far failed to do so. If you have an example to do that it would be great.