Guten Abend liebe Community
Ich habe ein Problem mit "
FindResource" und Delphi XE.
Bei Delphi 2007 funktioniert es noch ganz normal. Jedoch gibt es Problem mit Delphi XE und PWideChar, PChar und PAnsiChar.
Mein Code sieht folgendermassen aus:
Code:
program Project2;
{$APPTYPE CONSOLE}
uses
SysUtils,
Windows;
function GetResources(pSectionName: PChar; out ResourceSize: LongWord): Pointer;
var
ResourceLocation: HRSRC;
ResourceHandle: HGLOBAL;
begin
ResourceLocation :=
FindResource(hInstance, PAnsiChar(pSectionName), RT_RCDATA);
ResourceSize := SizeofResource(hInstance, ResourceLocation);
ResourceHandle := LoadResource(hInstance, ResourceLocation);
Result := LockResource(ResourceHandle);
end;
function GetResourceAsString(pSectionName: pchar): string;
var
ResourceData: PChar;
SResourceSize: LongWord;
begin
ResourceData := GetResources(pSectionName, SResourceSize);
SetString(Result, ResourceData, SResourceSize);
end;
begin
try
Writeln(GetResourceAsString('a'));
Readln;
except
on E:
Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
Ich bekomme folgenden Fehler:
http://img6.imagebanana.com/img/ujh0sygd/1.png
http://img6.imagebanana.com/img/iaom3ct8/3.png
Wenn ich allerdings PAnsiChar in PWideChar ändere, ist die Ausgabe:
http://img6.imagebanana.com/img/5k6lillb/2.png
Könnte mir da jemand helfen damit das auch mit Delphi XE funktioniert?
Ich bin über jede hilfreiche Antwort dankbar.
Mit freundlichen Grüssen,
Herbert Kuhn