把exe嵌入到自己的exe中。delphi xe3
下面是一个把exe程序嵌入到我们自己的exe中。开发环境 Delphi XE3 Version 17.0.4625.53395。OS环境WIN7 SP1,由于xe3版本的引用库发生变化。换成其他版本的需要做对应的修改。
unit insexe; interface uses
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 searching
end; function GetProcessWindow(TargetProcessID: Cardinal): HWND;
var
ProcWndInfo: TProcessWindow;
begin
ProcWndInfo.TargetProcessID := TargetProcessID;
ProcWndInfo.FoundWindow := ;
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), );
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, ); // minor delay FhProc := GetProcessWindow(pi.dwProcessID);
if FhProc > then
begin
Winapi.Windows.SetParent(FhProc, pnl1.Handle);
SetWindowPos(FhProc, , , , , , 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 > then
PostMessage(FhProc, WM_CLOSE, , );
end; end.
参考:http://hi.baidu.com/wang_yu_136/item/9c6d0ad877a4fa19d90e44fc
把exe嵌入到自己的exe中。delphi xe3的更多相关文章
- 把任意的EXE嵌入到自己程序中
把任意的EXE嵌入到自己程序中 taoyuan19822008-08-24上传 Delphi把任意的EXE嵌入到自己程序中的程序 资源积分:0分 下载次数:327 资源类型:其他 资源大小:175 ...
- Windows 下 exe 服务注册到 service 服务中
window 下注册 exe 程序.添加到 服务中. window 注册服务方式 一. regsvr 方式 直接在 程序目录执行: Regsvr 32 命令是Windows中控件文件 ( 如扩展名为D ...
- 把EXE可执行文件等作为资源包含在Delphi编译文件中
摘自我自己过去写的一段心得. 1.编辑资源文件 *.RCWave: 资源文件是声音文件:RCDATA: 二进制数据AVI: AVI动画:ICON: 图标文件:BITMAP: 位图文件:CURSOR: ...
- 应用程序启动后修改自身EXE文件或自删除EXE文件(附VC++6.0源码)
在CSDN论坛看到这么一个问题:如何为第三方工具加上使用限制次数?问题的答案很简单,重新做一个应用程序,将第三方程序打包进这个应用程序,启动应用程序时可以检查第三方工具的使用次数,检查通过,可运行第三 ...
- .net做的exe和electron做的exe之间的通信问题
目前工作遇到个问题: .net做的exe和electron做的exe,之间进行数据通信 目前找到两个相对方便的方法: 1.命名管道 ①.net命名管道资料: 进程间通信 - 命名管道实现 ②elect ...
- Fatal error in launcher: Unable to create process using '"c:\python37\python3.exe" "C:\Python37\Scripts\pip3.exe" install opencv-python'
pip3.exe install opencv-python 报错: Fatal error in launcher: Unable to create process using '"c: ...
- python:python2与python3共存时,pip冲突,提示Fatal error in launcher: Unable to create process using '"d:\python27\python2.exe" "D:\Python27\Scripts\pip2.exe" '
问题背景: 机器上同时装了python2.和python3后,导致只能用pip3了,使用pip2时提示:Fatal error in launcher: Unable to create proces ...
- Vue 将一个组件嵌入到另一个组件中
https://github.com/JasmineQian/Vue_Sample App.vue是所有组件的 要嵌入到App.vue组件中, 在script处导入 import xxx from ...
- Visual studio 编译错误 无法将文件obj\Debug\*.exe复制到bin\Debug\*.exe
问题: 错误 未能将“obj\Debug\Server.exe”复制到“bin\Debug\Server.exe”.超出了重试计数 10.失败. Server 错误 无法将文件“obj\Debug\S ...
随机推荐
- for 与 foreach 性能
For 与Foreach 性能 差别在不同的场景下会有不同的差异. 对于不同的目标 , 如 T[] 与 IEnumerable<T> 两个的性能就感觉出来了,对于T[] 都快. ...
- HtmlAgilityPack
http://htmlagilitypack.codeplex.com/wikipage?title=Examples http://nuget.org/packages/HtmlAgilityPac ...
- prtg
prtg http://www.paessler.com/prtg/features prtg的sensor技术 数据库监视 Flexible Alerting 9 notification tech ...
- shell流程控制语句
linux shell有一套自己的流程控制语句,其中包括条件语句(if),循环语句(for,while,until),选择语句(case/select).下面我将通过例子介绍下,各个语句使用方法. 1 ...
- JavaScript中类的实现机制
理解类的实现机制在前面已经讲过,在JavaScript中可以使用function关键字来定义一个“类”.现在介绍如何为类添加成员.其过程很简单,在函数内通过this指针引用的变量或者方法都会成为类的成 ...
- kaptcha随机验证码的使用详解,超实用
效果图: 官方地址:https://code.google.com/p/kaptcha/w/list 1.把下载的kaptcha-2.3.2.jar添加到lib中 2.配置web.xml增加servl ...
- PHP 开发环境配置
使用phpStudy +Zend Studio 使用phpStudy +Zend Studio ,这个组合是我个人使用的比较好的,现在分享出来.一.phpStudy简体中文版 该程序包集成最新的Apa ...
- Servlet Filter 3
11.MD5加密 /** * 使用md5的算法进行加密 */ public static String md5(String plainText) { byte[] secretBytes = nul ...
- 请使用GameBench.jar 文件启动 GameBench服务
请使用GameBench.jar 文件启动 GameBench服务 电脑上安装JAVA JRE:http://www.oracle.com/technetwork/java/javase/downlo ...
- Python基础教程【读书笔记】 - 2016/6/26
希望通过博客园持续的更新,分享和记录Python基础知识到高级应用的点点滴滴! 第一波:第6章 抽象 [总览] 介绍函数.参数parameter.作用于scope概念,以及递归概念. [6.1] 函 ...