I would like to embed mozilla firefox into my application WITHOUT using any activex control (TWebBrowser wrapper, mozilla ActiveX...). I tried using TWebBrowser (actually bsalsa
You can embed DLLs into your application and "load" then using BTMemoryModule.pas (just google it and you find it).
If this DLL is a COM object it might work to "load" the COM DLL factory and obtaining an instance of the COM interface you want:
var
// Our own method of COM / OLE object loading!
Lib: HMODULE;
Ptr: TDllGetClassObject;
Unl: TDLLCanUnloadNow;
I: IClassFactory;
initialization
Lib := LoadLibrary( 'zkemkeeper.dll' );
Ptr := GetProcAddress( Lib, 'DllGetClassObject' );
Unl := GetProcAddress( Lib, 'DllCanUnloadNow' );
if Assigned( Ptr ) and ( Ptr( CLASS_CZKEM, IClassFactory, I ) <> S_OK ) then I := nil;
finalization
I := nil;
OleInitialize( nil );
// Create a IZKEM interface instance
if not Assigned( I ) then Exit;
if I.CreateInstance( nil, IZKEM, CZ ) <> S_OK then Exit;
if not Assigned( CZ ) then Exit;
I do not know how to embed executables.
I hope this info helps.
You'll need to clean up the code a bit and work out how you'll "talk" to Firefox.
But here is how you can embed any app inside a Delphi form.
DFM File
object frmMain: TfrmMain
Left = 195
Top = 154
Width = 527
Height = 363
Caption = 'Containership Test'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
DesignSize = (
519
329)
PixelsPerInch = 96
TextHeight = 13
object pnlTop: TPanel
Left = 0
Top = 0
Width = 519
Height = 292
Align = alTop
Anchors = [akLeft, akTop, akRight, akBottom]
BevelInner = bvLowered
TabOrder = 0
end
object btnLoadApp: TButton
Left = 172
Top = 297
Width = 75
Height = 25
Anchors = [akLeft, akBottom]
Caption = 'Load'
TabOrder = 1
OnClick = btnLoadAppClick
end
object btnKill: TButton
Left = 260
Top = 297
Width = 75
Height = 25
Anchors = [akLeft, akBottom]
Caption = 'Kill'
TabOrder = 2
OnClick = btnKillClick
end
end
main.pas file
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ShellApi;
type
TfrmMain = class(TForm)
pnlTop: TPanel;
btnLoadApp: TButton;
btnKill: TButton;
procedure btnLoadAppClick(Sender: TObject);
procedure btnKillClick(Sender: TObject);
private
{ Private declarations }
AppWnd : DWORD;
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
{$R *.dfm}
procedure TfrmMain.btnLoadAppClick(Sender: TObject);
var
ExecuteFile : string;
SEInfo: TShellExecuteInfo;
begin
ExecuteFile:='c:\Windows\notepad.exe';
FillChar(SEInfo, SizeOf(SEInfo), 0) ;
SEInfo.cbSize := SizeOf(TShellExecuteInfo) ;
with SEInfo do
begin
fMask := SEE_MASK_NOCLOSEPROCESS;
Wnd := pnlTop.Handle;
lpFile := PChar(ExecuteFile) ;
nShow := SW_HIDE;
end;
if ShellExecuteEx(@SEInfo) then
begin
AppWnd := FindWindow(nil, PChar('Untitled - Notepad'));
if AppWnd <> 0 then
begin
Windows.SetParent(AppWnd, SEInfo.Wnd);
ShowWindow(AppWnd, SW_SHOWMAXIMIZED);
ShowWindow(AppWnd, SW_SHOWMAXIMIZED);
end;
end
else
ShowMessage('Error starting notepad!') ;
end;
procedure TfrmMain.btnKillClick(Sender: TObject);
begin
if (AppWnd <> 0) then
begin
PostMessage(AppWnd, WM_Close, 0, 0);
AppWnd := 0;
end;
end;
end.
I think what the original guy actually wants is a Web browser rendering engine embedded as a control in his application. If so, Gecko (The mozilla rendering part) is available as a plugin for your Application. I don't think you want to run an EXE.
For example, Mozilla Firefox isn't just an EXE file, but requires other stuff including a profiles folder. YOu probably haven't thought about all the problems that would cause.
If you just want a web browser control, this is not the way to do it. Try this instead: http://ftp.newbielabs.com/Delphi%20Gecko%20SDK/ https://sourceforge.net/projects/d-gecko/
The simplest way to embed an EXE into your application is to add it as a resource.
Make a .RC file with something like the following text:
OTHER_EXE_FILE RCDATA "nameofother.exe"
then using brcc32.exe you can compile a .RES file of the same name as the .RC with which you can then include ($I) the new .RES file in your application. The NAMEOFOTHER.EXE has to be in the same folder as the .RC file or be properly pathed, IIRC.
There is supposededly another way of doing this as well. You don't use the command line brcc32.exe compiler and just include ($I) the .RC file into your program and the compiler the compiles the .RC file on the fly.
Can't tell you if the second method works or not as I've never tried it.