Einzelnen Beitrag anzeigen

Benutzerbild von LDericher
LDericher

Registriert seit: 29. Jan 2007
Ort: Erkelenz
224 Beiträge
 
Delphi 7 Enterprise
 
#12

Re: Suche einen Fehlerfinder!

  Alt 29. Apr 2009, 17:03
Cool! Die Glaskugel will ich auch!

Nur Leider gibt es jetzt Schwachsinn^^

Meine Senderfunktion:
Delphi-Quellcode:
function _SendData(vData, ReceiverTitle:string):boolean;
type
  TStringRecord=record
    var1:string;
  end;
  TlParamRecord=record
    none,
    count:DWord;
    Pointer:Pointer;
  end;
var
  CDString:TStringRecord;
  vs_cds:TlParamRecord;
  pCDString,
  pStruct:Pointer;
  strLen:integer;
  hwndRec:HWND;
const
  MHAdditionalIdentifier='_CAL987qwerty2468';
  WM_COPYDATA_MH=$4A;
begin
Result:=true;
if(Length(ReceiverTitle)=0)
  then Result:=false
  else begin
  ReceiverTitle:=ReceiverTitle+MHAdditionalIdentifier;
  strLen:=Length(vData);
  SetLength(CDString.var1, strLen);
  CDString.var1:=vData;
  pCDString:=@CDString;
  vs_cds.count:=strLen+1;
  vs_cds.Pointer:=pCDString;
  pStruct:=@vs_cds;
  hwndRec:=FindWindow('AutoIt v3 GUI', PAnsiChar(ReceiverTitle));
  if(hwndRec=0)
    then Result:=false
  else if(SendMessage(hWndRec, WM_COPYDATA_MH, 0, DWord(pStruct))<>0)
    then Result:=false;
  end;
end;
Die Original-Senderfunktion:
Code:
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
   ;$CDString = DllStructCreate("char var1[255]");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
Ja, wenn ich jetzt die Senderfunktion aufrufe und sage, er soll bitte "test" senden, wird nur "|)E" ausgegeben...
Also, ich probier jetz dann auch weiter, das Problem muss ja zu knacken sein

LDer
  Mit Zitat antworten Zitat