![]() |
|
#1
|
|||
|
|||
|
Can someone convert this piece of vb code to delphi ?
the find window part just workes fine, somthing goes wrong because vb code use byte array? In delphi i used SendMessage(receiverHandle,WM_COPYDATA, 0, LongInt(PChar('"BEES1113";"ON"'))); between delphi aps this just worked fine but de vb program wont see my command. also tried: DataStruct.dwData := 3; DataStruct.cbData := length(s)+1; DataStruct.lpData := pchar(s); SendMessage(FindWindowExt(apptitle'),WM_CopyData,f orm14.handle,Integer(@DataStruct)); doesnt work either. Someone give some help please? Lars Working vb code: Code:
~ Private Sub Command1_Click()
Dim cds As COPYDATASTRUCT
Dim ThWnd As Long
Dim buf(1 To 255) As Byte
Dim a$
Dim i
' Get the hWnd of the target application
ThWnd = FindWindow(vbNullString, "apptitle")
a$ = "BEES1113;ON"
' Copy the string into a byte array, converting it to ASCII
Call CopyMemory(buf(1), ByVal a$, Len(a$))
cds.dwData = 3
cds.cbData = Len(a$) + 1
cds.lpData = VarPtr(buf(1))
i = SendMessage(ThWnd, WM_COPYDATA, Me.hwnd, cds)
End Sub
this workes but gives only the first char of the string Code:
var
a: pByteArray ;
begin
recievewindow:=FindWindowExt('app title');
s:=edit1.text;
a := @s[1];
DataStruct.dwData := 3;
DataStruct.cbData := length(s)+1;
DataStruct.lpData := a;
SetString(s, PAnsiChar(DataStruct.lpData), 100);
SendMessage(recievewindow,WM_CopyData,form14.handle,Integer(@DataStruct));
Last edited by lars; 06-14-2012 at 02:28 PM. |
| Thread Tools | |
| Display Modes | |
|
|