Schau dir nochmal den ersten Link an, den du in deinen Beispielprojekt hast.
Die werkeln da mit CopyAndSkipString rum. Wenn man diese Procedure verwendet geht es:
Delphi-Quellcode:
...
type
UNICODE_STRING =
packed record
Length: Word;
MaximumLength: Word;
Buffer: PWideChar;
end;
PUNICODE_STRING = ^UNICODE_STRING;
procedure RtlInitUnicodeString(DestinationString: PUNICODE_STRING; SourceString: LPWSTR);
stdcall;
external '
ntdll.dll';
procedure RtlRunEncodeUnicodeString(Hash: PUCHAR; Str: PUNICODE_STRING);
stdcall;
external '
ntdll.dll';
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure CopyAndSkipString(
var P : Pointer;
var Str : PWideChar);
var
Len : Cardinal;
begin
Len := (Length(Str) + 1) * SizeOf(Str[0]);
CopyMemory(P, Str, Len);
Str := P;
Inc(Cardinal(P), Len);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Source: PWideChar;
UnicodeString: UNICODE_STRING;
Hash : UCHAR;
P : Pointer;
begin
{
http://www.remkoweijnen.nl/blog/2008/11/26/executing-a-fast-user-switch-programmatically-part-2/
http://doxygen.reactos.org/dc/d4b/lib_2rtl_2encode_8c_source.html
http://forums.codeguru.com/showthread.php?322941-problem-using-RtlRunDecodeUnicodeString
}
Source := '
TestString';
GetMem(P, SizeOf(UnicodeString));
CopyAndSkipString(P, Source);
RtlInitUnicodeString(@UnicodeString, Source);
Hash := Byte(GetTickCount);
RtlRunEncodeUnicodeString(@Hash, @UnicodeString);
end;