Недавно добавленные исходники

•  DeLiKaTeS Tetris (Тетрис)  4 583

•  TDictionary Custom Sort  6 599

•  Fast Watermark Sources  6 369

•  3D Designer  9 319

•  Sik Screen Capture  6 703

•  Patch Maker  7 084

•  Айболит (remote control)  7 088

•  ListBox Drag & Drop  5 955

•  Доска для игры Реверси  97 496

•  Графические эффекты  7 290

•  Рисование по маске  6 584

•  Перетаскивание изображений  5 457

•  Canvas Drawing  5 826

•  Рисование Луны  5 537

•  Поворот изображения  5 058

•  Рисование стержней  3 623

•  Paint on Shape  2 864

•  Генератор кроссвордов  3 750

•  Головоломка Paletto  3 019

•  Теорема Монжа об окружностях  3 828

•  Пазл Numbrix  2 519

•  Заборы и коммивояжеры  3 219

•  Игра HIP  2 186

•  Игра Go (Го)  2 117

•  Симулятор лифта  2 499

•  Программа укладки плитки  2 149

•  Генератор лабиринта  2 633

•  Проверка числового ввода  2 303

•  HEX View  2 635

•  Физический маятник  2 255

 
скрыть

Добавить EXE файл в своё приложение и запустить его



1. Start notepad and create a .rc-file that looks like this:
Starte Notepad und erstelle ein .rc-file, das etwa so aussieht:


TESTFILE EXEFILE C:\Windows\Notepad.exe 

(Make sure that the Path to your Exe-File is correct!)
(Stelle sicher, dass der Pfad zur Exe-Datei korrekt ist!)

2. Save it as myres.rc
Speichere es als myres.rc

3. Compile the file with brcc32.exe
(in your Delphi-bin directory) to get myres.res
Kompiliere die Datei mit brcc32.exe
(Im Delphi-bin Verzeichnis) um die Datei myres.res zu erhalten.

4. Copy myres.res to your Project directory.
Kopiere myres.res in das entsprechende Projekt-Verzeichnis.

5. In your unit write the following:
In der unit, schreibe etwa das folgende:


var 
  Form1: TForm1; 
  NOTEPAD_FILE: string; 

implementation 

{$R *.DFM} 
{$R MYRES.RES} 

function GetTempDir: string; 
var 
  Buffer: array[0..MAX_PATH] of Char; 
begin 
  GetTempPath(SizeOf(Buffer) - 1, Buffer); 
  Result := StrPas(Buffer); 
end; 

// Extract the Resource 
function ExtractRes(ResType, ResName, ResNewName: string): Boolean; 
var 
  Res: TResourceStream; 
begin 
  Result := False; 
  Res := TResourceStream.Create(Hinstance, Resname, PChar(ResType)); 
  try 
    Res.SavetoFile(ResNewName); 
    Result := True; 
  finally 
    Res.Free; 
  end; 
end; 

// Execute the file 
procedure ShellExecute_AndWait(FileName: string); 
var 
  exInfo: TShellExecuteInfo; 
  Ph: DWORD; 
begin 
  FillChar(exInfo, SizeOf(exInfo), 0); 
  with exInfo do 
  begin 
    cbSize := SizeOf(exInfo); 
    fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_DDEWAIT; 
    Wnd := GetActiveWindow(); 
    ExInfo.lpVerb := 'open'; 
    lpFile := PChar(FileName); 
    nShow := SW_SHOWNORMAL; 
  end; 
  if ShellExecuteEx(@exInfo) then 
  begin 
    Ph := exInfo.HProcess; 
  end 
  else 
  begin 
    ShowMessage(SysErrorMessage(GetLastError)); 
    Exit; 
  end; 
  while WaitForSingleObject(ExInfo.hProcess, 50) <> WAIT_OBJECT_0 do 
    Application.ProcessMessages; 
  CloseHandle(Ph); 
end; 

// To Test it 
procedure TForm1.Button1Click(Sender: TObject); 
begin 
  if ExtractRes('EXEFILE', 'TESTFILE', NOTEPAD_FILE) then 
    if FileExists(NOTEPAD_FILE) then 
    begin 
      ShellExecute_AndWait(NOTEPAD_FILE); 
      ShowMessage('Notepad finished!'); 
      DeleteFile(NOTEPAD_FILE); 
    end; 
end; 

procedure TForm1.FormCreate(Sender: TObject); 
begin 
  NOTEPAD_FILE := GetTempDir + 'Notepad_FROM_RES.EXE'; 
end;