首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

做过exe集成的朋友请进,该如何解决

2012-03-26 
做过exe集成的朋友请进问题描述:有几个exe程序(jxjh.exe,xueji.exe...delphi5.0开发),现在需要开发一个集

做过exe集成的朋友请进
问题描述:
      有几个exe程序(jxjh.exe,xueji.exe...delphi5.0开发),现在需要开发一个集成的界面,要求新建一个窗体,在窗体左面是功能按钮,如jxjh,xueji,点击jxjh按钮调用jxjh.exe,把jxjh.exe的内容显示到新建窗体的右面,原来窗体保持不变,jxjh在新窗体右边能够实现原来exe文件的所有操作。
      如果大家对我的描述不清楚,加qq:3245104
      谢谢

[解决办法]
function WinExecAndWait32_v1(FileName: string; Visibility: integer): Cardinal;
var
zAppName: array[0..512] of char;
zCurDir: array[0..255] of char;
WorkDir: string;
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
begin
StrPCopy(zAppName, FileName);
GetDir(0, WorkDir);
StrPCopy(zCurDir, WorkDir);
FillChar(StartupInfo, Sizeof(StartupInfo), #0);
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := Visibility;
if not CreateProcess(nil,
zAppName,
nil,
nil,
true,
CREATE_NEW_CONSOLE or
NORMAL_PRIORITY_CLASS,
nil,
nil,
StartupInfo,
ProcessInfo)
then Result := INFINITE
else
begin
WaitforSingleObject(ProcessInfo.hProcess, INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess, Result);
CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);
end;
end;


var
ExecuteFile:string;
begin
inherited;
if self.rbServer.Checked then
begin
ExecuteFile:=ExtractFilePath(paramstr(0))+ 'bin\ProjServerConfig.exe ';
end;
if self.rbClient.Checked then
begin
ExecuteFile:=ExtractFilePath(paramstr(0))+ 'bin\ProjClientConfig.exe ';
end;
self.Hide;
Tools.WinExecAndWait32_v1(ExecuteFile,SW_SHOWNORMAL);
self.Show;
end;
[解决办法]
用ShellExecute或者WinExe直接运行exe就可以了
例如打开本目录下的jxjh.exe

var
FileName:string;
begin
FileName:=ExtractFilePath(Application.ExeName)+ 'jxjh.exe ';
ShellExecute(0, 'OPEN ',PChar(FileName), ' ', ' ',SW_SHOW);
{ 或者 WinExec(PChar(FileName),SW_SHOW); }
end;

[解决办法]
var
ExecuteFile:string;
begin
inherited;
if self.rbServer.Checked then
begin
ExecuteFile:=ExtractFilePath(paramstr(0))+ 'bin\ProjServerConfig.exe ';
end;
if self.rbClient.Checked then
begin
ExecuteFile:=ExtractFilePath(paramstr(0))+ 'bin\ProjClientConfig.exe ';
end;
self.Hide;
WinExecAndWait32_v1(ExecuteFile,SW_SHOWNORMAL);
self.Show;
end;
[解决办法]
library ProjectDll;

{ Important note about DLL memory management: ShareMem must be the
first unit in your library 's USES clause AND your project 's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }

uses
Windows,
Messages,
SysUtils,


Classes,
Graphics,
Controls,
Forms,
Dialogs,
UnitDll in 'UnitDll.pas ' {Form1};


procedure ProvaChild(ParentApplication: TApplication; ParentForm: TForm); export; stdcall;
var
Form1: TForm1;
DllProc: Pointer; { Called whenever DLL entry point is called }

begin
Application:=ParentApplication;

Form1:=TForm1.Create(ParentForm);
Form1.MyParentForm:=ParentForm;
Form1.MyParentApplication:=ParentApplication;
// windows.SetParent(Form1.Handle,ParentForm.Handle);
// Form1.FormStyle:=fsMDIChild;
Form1.Show;
end;

procedure DLLUnloadProc(Reason: Integer); register;
begin
if Reason = DLL_PROCESS_DETACH then Application:=DllApplication;
end;

exports
ProvaChild;

begin
DllApplication:=Application;
DLLProc := @DLLUnloadProc;
end.
unit UnitDll;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
TForm1 = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
MyParentForm: TForm;
MyParentApplication: TApplication;
end;

var
DllApplication: TApplication;

implementation

{$R *.DFM}

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
// Application:=DllApplication;
end;

end.


[解决办法]
可以把一个进程窗口放进另一个窗口上的,我做过.
不过前提是要加入一些代码,被嵌入和嵌入的窗口都是用DELPHI做的

我做的程序是一个主程序,一个进程外DCOM服务器,用来显示主程序的调试信息.
觉得两个窗口不好看,就把DCOM窗口像一个TPANEL一样弄进主程的窗口了.

如果楼主有兴趣就跟一下贴,我继续回答
[解决办法]
用API函数SetParent来实现,我曾经把一个记事本程序嵌入到了我的一个系统中!

VB声明
Declare Function SetParent Lib "user32 " Alias "SetParent " (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
说明
指定一个窗口的新父(在vb里使用:利用这个函数,vb可以多种形式支持子窗口。例如,可将控件从一个容器移至窗体中的另一个。用这个函数在窗体间移动控件是相当冒险的,但却不失为一个有效的办法。如真的这样做,请在关闭任何一个窗体之前,注意用SetParent将控件的父设回原来的那个)
返回值
Long,前一个父窗口的句柄
参数表
参数 类型及说明
hWndChild Long,子窗口的句柄
hWndNewParent Long,hWndChild的新父
注解
可用这个函数在运行期将vb控件置入容器控件内部(比如将一个按钮设成图象或窗体控件的子窗口),或者将控件从一个容器控件移至另一个。控件移至另一个父后,它的位置将由新父的坐标系统决定。这样一来,有必要重新规定控件的位置,使其能在目标位置显示出来



[解决办法]
setparent
[解决办法]
或者 用虚拟桌面CreateDesktop
[解决办法]
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;

type
TForm1 = class(TForm)
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
HWnd: THandle;
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);


begin
WinExec( 'C:\WINDOWS\system32\calc.exe ',0);
HWnd := FindWindow(PChar( 'SciCalc '), nil);
if HWnd <> 0 then
begin
Windows.SetParent(HWnd, Panel1.Handle);
SetWindowPos(Hwnd, 0, 0, 0, Panel1.ClientWidth, Panel1.ClientHeight, 0);
SetWindowLong(hwnd,GWL_STYLE,GetWindowLong(hwnd,GWL_STYLE) and not WS_CAPTION);

end;
end;


procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
PostMessage(HWnd,WM_CLOSE,0,0);
CanClose := True;
end;

end.
[解决办法]
HWnd := FindWindow(PChar( 'SciCalc ')

'SciCalc ' 就是 可执行程序运行后程序标题。。

热点排行