PDA

View Full Version : C to Delphi [OFF]



arthurprs
23-12-2007, 04:53 AM
C 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 =(

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?

Pyrogine
23-12-2007, 05:09 AM
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.

arthurprs
23-12-2007, 12:58 PM
I have made the changes, but still don't working :cry:

savage
23-12-2007, 02:16 PM
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 \


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;

Pyrogine
23-12-2007, 02:54 PM
Also try this:

msndata.lpData := Pointer(@utf16buffer[1]);

arthurprs
23-12-2007, 02:55 PM
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 \


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;


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

arthurprs
23-12-2007, 03:09 PM
sorry guys, i was trying with wrong parameters :oops:

the correct:

SendMessage(msnwindow, WM_COPYDATA, 0, Integer(@msndata));

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