Results 1 to 7 of 7

Thread: C to Delphi [OFF]

  1. #1

    C to Delphi [OFF]

    C code
    Code:
    void clear_msn_title()
    {
    	HWND msnui = NULL;
    	string_utf16_from_utf8 utf16buffer("\\0Music\\00\\0{0} - {1}\\0\\0\\0\\0\\0");
    	msndata.dwData = 0x547;
    	msndata.lpData = (void*)utf16buffer.get_ptr();
    	msndata.cbData = (utf16buffer.length()*2)+2;
    
    	while (msnui = FindWindowEx(NULL, msnui, "MsnMsgrUIManager", NULL))
    	{
    		SendMessage(msnui, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&msndata);
    	}
    }
    this is what i have did, but does not work =(
    Code:
    var
      msndata: CopyDataStruct;
      msnwindow: HWND;
      utf16buffer: WideString;
    begin
      utf16buffer := '\\0Music\\00\\0{0} - {1}\\0\\0\\0\\0\\0';
      msndata.dwData := StrToInt('0x547');
      msndata.cbData := Length(utf16buffer) * 2 + 2;
      msndata.lpData := Pointer(utf16buffer);
      msnwindow := 0;
    
      repeat
        msnwindow := FindWindowEx(0, msnwindow, 'MsnMsgrUIManager', nil);
        SendMessage(msnwindow, WM_CLOSE, WM_CLOSE,Integer(@msndata));
      until msnwindow = 0;
    end;
    :cry: What im doing wrong?
    From brazil (:

    Pascal pownz!

  2. #2

    C to Delphi [OFF]

    Try

    msndata.dwData := $547;

    and

    msndata.cbData := (Length(utf16buffer) * 2) + 2;

    and you need to make sure the msg is only sent if the result is not zero.

    and finally, check the way your defining that widestring, it maybe be some differences in Delphi.
    Jarrod Davis
    Technical Director @ Piradyne Games

  3. #3

    C to Delphi [OFF]

    I have made the changes, but still don't working :cry:
    From brazil (:

    Pascal pownz!

  4. #4

    C to Delphi [OFF]

    Are you getting any error messages?

    You may want to try the following as \\ in C is usually used for escaping sequences, so in Pascal you should only need 1 \

    [pascal]
    var
    msndata: CopyDataStruct;
    msnwindow: HWND;
    utf16buffer: WideString;
    begin
    utf16buffer := '\0Music\00\0{0} - {1}\0\0\0\0\0';
    msndata.dwData := $547;
    msndata.cbData := ( Length(utf16buffer) * 2 ) + 2;
    msndata.lpData := Pointer(utf16buffer);
    msnwindow := 0;

    repeat
    msnwindow := FindWindowEx(0, msnwindow, 'MsnMsgrUIManager', nil);
    SendMessage(msnwindow, WM_CLOSE, WM_CLOSE,Integer(@msndata));
    until msnwindow = 0;
    end;
    [/pascal]
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  5. #5

    C to Delphi [OFF]

    Also try this:

    msndata.lpData := Pointer(@utf16buffer[1]);
    Jarrod Davis
    Technical Director @ Piradyne Games

  6. #6

    C to Delphi [OFF]

    Quote Originally Posted by savage
    Are you getting any error messages?

    You may want to try the following as \\ in C is usually used for escaping sequences, so in Pascal you should only need 1 \

    [pascal]
    var
    msndata: CopyDataStruct;
    msnwindow: HWND;
    utf16buffer: WideString;
    begin
    utf16buffer := '\0Music\00\0{0} - {1}\0\0\0\0\0';
    msndata.dwData := $547;
    msndata.cbData := ( Length(utf16buffer) * 2 ) + 2;
    msndata.lpData := Pointer(utf16buffer);
    msnwindow := 0;

    repeat
    msnwindow := FindWindowEx(0, msnwindow, 'MsnMsgrUIManager', nil);
    SendMessage(msnwindow, WM_CLOSE, WM_CLOSE,Integer(@msndata));
    until msnwindow = 0;
    end;
    [/pascal]
    no error messages,

    im starting to think that the problem is in the widestring, whem i send the message to msn with delphi, the C version does not anymore too, only works after i restart the live messenger
    From brazil (:

    Pascal pownz!

  7. #7

    C to Delphi [OFF]

    sorry guys, i was trying with wrong parameters ops:

    the correct:
    Code:
    SendMessage&#40;msnwindow, WM_COPYDATA, 0, Integer&#40;@msndata&#41;&#41;;
    but savage was right one / only

    now it works

    thanks a lot for the attention



    ps: pyro, i was looking in pyroscript yesterday, you just turned shit into cheese xD
    From brazil (:

    Pascal pownz!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •