Unicode support in madCodeHook
Ok - sounds perfect!
Another question,
I have a routine to get the exe file name from a window handle but I am thinking of using your 'Window(windowHnd).OwnerProcess.ExeFile' instead.
My only question is if the 'Window(windowHnd).OwnerProcess.ExeFile' will support exe-files with Unicode names?
Kind Regards
Thomas
Another question,
I have a routine to get the exe file name from a window handle but I am thinking of using your 'Window(windowHnd).OwnerProcess.ExeFile' instead.
My only question is if the 'Window(windowHnd).OwnerProcess.ExeFile' will support exe-files with Unicode names?
Kind Regards
Thomas
Hehe by the way it seems like it is your code (enumStuff) I am about to add unicode support to: http://www.howtodothings.com/viewarticl ... rticle=343
Was this before the Madshi lib became commercial?
/Thomas
Was this before the Madshi lib became commercial?
/Thomas
Yep, that's an older work from me. It's still available for download under http://madshi.net/enumStuff.zip .
Hi,
I'm sorry but I don't really get how to use your encryption/decryption methods on widestring data. This is what I tried but with not luck when I tried with Unicode chars (it works with ansi though).
//First encrypt the data - let say I have typed in 'ьфвырш рфы ф пкуфе дши'
procedure TForm1.TntButton2Click(Sender: TObject);
var w : widestring;
begin
w := TntEdit1.Text; //uses Tnt controls for Unicode support instead of VCL
Encrypt(PWideChar(w), Length(w), 'sdf');
TntEdit2.Text := Encode(w); //Save the encrypted and encoded data
end;
//Then try to get the original data back
procedure TForm1.TntButton1Click(Sender: TObject);
var w : widestring;
begin
w := Decode(TntEdit2.Text);
Decrypt(PWideChar(w), Length(w), 'sdf');
TntEdit3.Text := w;
end;
Thanks
Thomas
I'm sorry but I don't really get how to use your encryption/decryption methods on widestring data. This is what I tried but with not luck when I tried with Unicode chars (it works with ansi though).
//First encrypt the data - let say I have typed in 'ьфвырш рфы ф пкуфе дши'
procedure TForm1.TntButton2Click(Sender: TObject);
var w : widestring;
begin
w := TntEdit1.Text; //uses Tnt controls for Unicode support instead of VCL
Encrypt(PWideChar(w), Length(w), 'sdf');
TntEdit2.Text := Encode(w); //Save the encrypted and encoded data
end;
//Then try to get the original data back
procedure TForm1.TntButton1Click(Sender: TObject);
var w : widestring;
begin
w := Decode(TntEdit2.Text);
Decrypt(PWideChar(w), Length(w), 'sdf');
TntEdit3.Text := w;
end;
Thanks
Thomas
Thanks but I still don't get it to work. This is what I changed to:
procedure TForm1.TntButton2Click(Sender: TObject);
var w : widestring;
begin
w := TntEdit1.Text;
Encrypt(PWideChar(w), Length(w) * sizeOf(WideChar), 'sdf');
TntEdit2.Text := Encode(w);
end;
procedure TForm1.TntButton1Click(Sender: TObject);
var w : widestring;
begin
w := Decode(TntEdit2.Text);
Decrypt(PWideChar(w), Length(w) * sizeOf(WideChar), 'sdf');
TntEdit3.Text := w;
end;
Kind Regards
Thomas
procedure TForm1.TntButton2Click(Sender: TObject);
var w : widestring;
begin
w := TntEdit1.Text;
Encrypt(PWideChar(w), Length(w) * sizeOf(WideChar), 'sdf');
TntEdit2.Text := Encode(w);
end;
procedure TForm1.TntButton1Click(Sender: TObject);
var w : widestring;
begin
w := Decode(TntEdit2.Text);
Decrypt(PWideChar(w), Length(w) * sizeOf(WideChar), 'sdf');
TntEdit3.Text := w;
end;
Kind Regards
Thomas
When you call Encode like that, Delphi converts the wideString to ansiString. You need to call the other Encode procedure (the one with pointer/len). Also when getting a string back from the Decode function this is not really a string. It's a Delphi dynamic string, but it will contain the wideString data.
Basically stop thinking in string terms. Imagine the wideString would be pure data like bitmap pixels. As a result you can't use the string-variations of the encrypt/encode/decrypt/decode functions, but you need to use the buffer variations instead.
Perhaps it would be easier for you to understand, if you would convert the wideString into a real allocated buffer. It's not really necessary, but it might help you understanding how you need to do it.
Basically stop thinking in string terms. Imagine the wideString would be pure data like bitmap pixels. As a result you can't use the string-variations of the encrypt/encode/decrypt/decode functions, but you need to use the buffer variations instead.
Perhaps it would be easier for you to understand, if you would convert the wideString into a real allocated buffer. It's not really necessary, but it might help you understanding how you need to do it.
Code: Select all
var ws : wideString;
s1 : string;
begin
ws := 'test';
ShowMessage(ws);
Encrypt(pointer(ws), Length(ws) * sizeOf(wideChar), 'password');
s1 := Encode(pointer(ws), Length(ws) * sizeOf(wideChar));
ShowMessage(s1);
s1 := Decode(pointer(s1), Length(s1));
Decrypt(pchar(s1), Length(s1), 'password');
ws := PWideChar(@s1[1]);
ShowMessage(ws);