Jump to content
Sign in to follow this  

Not getting Buffer on Mainframe Screen with ehllapi.dll

Recommended Posts


I am trying to read the contents in an mainframe terminal that is embedded in an IE window. It is a RUMBA terminal, and I am doing DLLCALLs to the ehllapi32.dll.

I don't get any errors when I try to connect with WD_ConnectPS, and I get no errors when I try to copy the presentation screen with WD_CopyPSToString

but the buffer as far as I can see is empty. Could you go over my code and see if I am missing something?


Global $tPOINT = DllStructCreate("int X;int Y")
    DllStructSetData($tPOINT, 'X', 400); 
    DllStructSetData($tPOINT, 'Y', 400); 
    $hWnd = _WinAPI_WindowFromPoint($tPOINT)
    $mydll = DllOpen("ehlapi32.dll")
    $connect = DllCall($mydll,"word","WD_ConnectPS","hwnd", $hWnd, "str","A")
    If @error Then
        MsgBox(4096, "Error", "Could not find the correct window")
    ElseIf ($connect = 1) Then
        MsgBox(4096, "Error", "Could not connect to PS")
        $buffer = DllStructCreate("char[3564]")
        $position = 1
        $copyfunc = DllCall($mydll, "word", "WD_CopyPSToString", "hwnd", $hWnd, "word",$position, "ptr",DllStructGetPtr($buffer), "word", DllStructGetSize($buffer))
        ;WD_CopyPSToString(hinstance: LongInt; Position: Integer; Buffer: String; Length: Integer): Integer; stdcall; external ehlapi32 name 'WD_CopyPSToString';
        ;Maximum size of buffer is 3564
        If @error Then
            MsgBox(4096, "Error", "Could not copy PS. Return:"&$copyfunc)

Share this post

Link to post
Share on other sites

To start with, DllCall() always returns an array, so $connect and $copyfunc are being used wrong.


Thank you. I see that now. I'll adjust my code and see if I can get the buffer.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.