把exe嵌入到自己的exe中。delphi xe3
来源:互联网 发布:如何对待网络语言暴力 编辑:程序博客网 时间:2024/05/21 06:49
下面是一个把exe程序嵌入到我们自己的exe中。开发环境 Delphi XE3 Version 17.0.4625.53395。OS环境WIN7 SP1,由于xe3版本的引用库发生变化。换成其他版本的需要做对应的修改。
unit insexe;interfaceuses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls;type TForm1 = class(TForm) pnl1: TPanel; btn1: TButton; dlgOpen1: TOpenDialog; procedure btn1Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); private { Private declarations } FhProc: HWND; public { Public declarations } end; PProcessWindow = ^TProcessWindow; TProcessWindow = record TargetProcessID: Cardinal; FoundWindow: HWND; end;var Form1: TForm1;implementation{$R *.dfm}function EnumWindowsProc(Wnd: HWND; ProcWndInfo: PProcessWindow): BOOL; stdcall;var WndProcessID: Cardinal;begin GetWindowThreadProcessId(Wnd, @WndProcessID); if WndProcessID = ProcWndInfo^.TargetProcessID then begin ProcWndInfo^.FoundWindow := Wnd; Result := False; // stop enumerating since a window found. end else Result := True; // Keep searchingend;function GetProcessWindow(TargetProcessID: Cardinal): HWND;var ProcWndInfo: TProcessWindow;begin ProcWndInfo.TargetProcessID := TargetProcessID; ProcWndInfo.FoundWindow := 0; EnumWindows(@EnumWindowsProc, Integer(@ProcWndInfo)); Result := ProcWndInfo.FoundWindow;end;procedure TForm1.btn1Click(Sender: TObject);var si: STARTUPINFO; pi: TProcessInformation; bRet: Boolean;begin if not dlgOpen1.Execute then Exit; FillChar(si, SizeOf(si), 0); si.cb := SizeOf(si); si.dwFlags := STARTF_USESHOWWINDOW; // MUST, otherwise, wShowWindow won't work. si.wShowWindow := SW_HIDE; // Hide the process Windows, otherwise could be trouble. bRet := CreateProcess(nil, PChar(dlgOpen1.FileName), nil, nil, True, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil, si, pi); if not bRet then Exit; // Wait until child process exits. WaitForSingleObject(pi.hProcess, 100); // minor delay FhProc := GetProcessWindow(pi.dwProcessID); if FhProc > 0 then begin Winapi.Windows.SetParent(FhProc, pnl1.Handle); SetWindowPos(FhProc, 0, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOZORDER); ShowWindow(FhProc, SW_SHOW); end; // Clear up CloseHandle(pi.hProcess); CloseHandle(pi.hThread);end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);begin if FhProc > 0 then PostMessage(FhProc, WM_CLOSE, 0, 0);end;end.
参考:http://hi.baidu.com/wang_yu_136/item/9c6d0ad877a4fa19d90e44fc
- 把exe嵌入到自己的exe中。delphi xe3
- exe嵌入到自己的程序中
- Dll嵌入到exe中
- C#将exe运行程序嵌入到自己的winform窗体中
- C#将exe运行程序嵌入到自己的winform窗体中
- C#将exe运行程序嵌入到自己的winform窗体中
- 把Google地图嵌入到自己的网页中
- 游戏大厅原理:将其它exe界面程序嵌入自己的程序界面中运行
- c++实现嵌入.exe文件到程序中
- c++实现嵌入.exe文件到程序中
- 将MP3文件嵌入到exe中并播放
- XP中被嵌入到可信进程(如:Explorer.exe)的木马dll文件
- C# 以嵌入到窗体的方式打开外部exe
- delphi把窗体嵌入到dll中。实现方法
- 由电脑缺扫雷游戏想到的: 如何把自己的.exe放到系统中?
- 由电脑缺扫雷游戏想到的: 如何把自己的.exe放到系统中?
- Delphi 把现有的EXE工程转成DLL工程(EXE文件转成DLL文件)
- winform将图片嵌入到exe
- 奋斗——在毕业的边缘
- 工作总结
- 基于FMC接口的DSP TMS320C6455子卡模块
- 两步实现个人电脑上server-u搭建FTP服务器
- beans 的default-autowire属性
- 把exe嵌入到自己的exe中。delphi xe3
- windows server 2003 mysql 经常连接不上
- 感悟dota 成就人生
- 杭电ACM 2009 求数列的和
- 长恨歌 白居易
- Win7中,修改SVN客户端的认证用户名和密码
- VMware 7.1 安装openstack
- Error: Missing language pack for 'Adobe-GB1' mapping
- android 根据IP获取天气情况 详细讲解