среда, 19 марта 2014 г.

Delphi: Загрузка строки из ресурса

Предварительно идем в Project->Resources and images и загружаем из файла текст.

procedure TForm1.Button1Click(Sender: TObject);

var

ResHandle:HRSRC;
hGlob:THandle;
thestring:AnsiString;
eu:PAnsiChar;

begin

// Resource_1    - Имя ресурса
// RT_RCDATA - Тип ресурса
ResHandle:=FindResource(hInstance,'Resource_1',RT_RCDATA);
hglob:=LoadResource(hInstance,ResHandle);   // Returns a handler to the data of a resource
eu:=LockResource(hGlob);                                   // Returns a pointer to a resource
theString:=eu;
Memo1.Lines.Text:=theString;
//ShowMessage(thestring);

end;


http://stackoverflow.com/questions/6547696/how-can-my-program-read-a-string-from-a-res-file

Комментариев нет:

Отправить комментарий