Jump to content
Sign in to follow this  
LDericher

Translating AutoIt to Delphi - Problem!

Recommended Posts

LDericher

So, I've seen the material following this LINK:

http://www.autoitscript.com/forum/index.php?showtopic=77979

and the Module can be seen here: http://www.autoitscript.com/forum/index.ph...st&id=22855

Now, I have to translate the "_SendData"-Function to Delphi-Code.

Here the original Func:

Func _SendData($vData,$ReceiverTitle)
    Local $strLen,$CDString,$vs_cds,$pCDString,$pStruct,$hwndRec
    
    If StringLen($ReceiverTitle) = 0 then Return SetError(1,1,0);Make sure the user has specified a title
    $ReceiverTitle&= $MHAdditionalIdentifier
    
    $strLen = StringLen($vData)
    $CDString = DllStructCreate("char var1[" & $strLen +1 & "]");the array to hold the string we are sending
    DllStructSetData($CDString,1,$vData)
    
    $pCDString = DllStructGetPtr($CDString);the pointer to the string
    
    $vs_cds = DllStructCreate($StructDef_COPYDATA);create the message struct
    DllStructSetData($vs_cds,"count",$strLen + 1);tell the receiver the length of the string +1
    DllStructSetData($vs_cds,"pointer",$pCDString);the pointer to the string

    $pStruct = DllStructGetPtr($vs_cds)
    
    $hwndRec = WinGetHandle($ReceiverTitle)
    If $hwndRec = "" then 
        $vs_cds = 0;free the struct
        $CDString = 0;free the struct
        Return SetError(1,2,0)
    EndIf
    

    DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hwndRec, "int", $WM_COPYDATA_MH, "wparam", 0, "lparam", $pStruct)
    If @error then 
        $vs_cds = 0;free the struct
        $CDString = 0;free the struct
        return SetError(1, 3, 0) ;return 0 no data sent
    EndIf
    
    
    $vs_cds = 0;free the struct
    $CDString = 0;free the struct
    Return $strLen 
EndFunc

Can someone please help me?

Thx in advance,

The LDer


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.