Показать сообщение отдельно
  #5  
Старый 09.12.2010, 16:53
Аватар для BoRoV
BoRoV BoRoV вне форума
Начинающий
 
Регистрация: 08.09.2008
Сообщения: 193
Репутация: 12694
По умолчанию

Создаешь файл, например dll.rc. В него пишешь:
Код:
DLL RCDATA "<путь к длл>"

Далее компилим ресурс при помощи brcc32.exe. Запускаем brcc32.exe через консоль с параметром путь к dll.rc.
Всё. На выходе получим dll.res. Который добавляем проект
Код:
{$R dll.res}

А это ф-ия извлечения длл. Можешь задать так чтоб пользователь сам задавал путь к игре. В path должен быть путь вместе с именем длл.
Код:
var
  hRes, hMod, hFile, dwSize, n: dword;
  pBuffer: pointer;
  path: array[0..255] of char;

begin

  hMod := FindResource(HInstance, 'DLL', RT_RCDATA);
  if (hMod <> 0) then
  begin
    dwSize := SizeofResource(HInstance, hMod);
    hRes := LoadResource(HInstance, hMod);
    if (hRes <> 0) then
    begin
      pBuffer := LockResource(hRes);
      if (pBuffer <> nil) then
      begin
        hFile := CreateFile(path, GENERIC_WRITE, FILE_SHARE_WRITE, 0, CREATE_ALWAYS, 0, 0);
        if (hFile <> INVALID_HANDLE_VALUE) then
        begin
          SetFilePointer(hFile, 0, nil, FILE_BEGIN);
          if not (WriteFile(hFile, pBuffer^, dwSize, n, 0)) then
            MessageBox(0, 'Can''t write to file', 'Error', 16)
          else
            if (dwSize <> n) then
              MessageBox(0, 'Not all bytes write to file', 'Error', 16)
          CloseHandle(hFile);
        end;
      end;
      FreeResource(hRes);
    end;
  end;
end.
Ответить с цитированием