 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Chau Chee Yang Guest
|
Posted: Tue Mar 20, 2007 8:45 pm Post subject: How to extract required runtime package from Win32 .EXE comp |
|
|
Hi,
I have an VCL win32 application build with runtime packages. I wish to
write a simple application extract the required runtime packages (.bpl
files) from the .exe. Can someone give me some hints on how to do so?
I have tried GetPackageInfo but it can only return required packages for
..BPL file but not .EXE file.
Dr. Bob has a neat command line tool called REQUIRED.EXE that does the
job:
http://www.drbob42.com/tools/index.htm
I have tried this utility and heard that it try to scan PE information.
However, there is no source code from there and I don't know how it
get the required .BPL from the .EXE
Please advice. Thank you.
The following are the source I wrote to try getting the required packages:
procedure ShowInfoProc (const Name: string;
NameType: TNameType; Flags: Byte; Param: Pointer);
var
FlagStr: string;
begin
FlagStr := ' ';
if Flags and ufMainUnit <> 0 then
FlagStr := FlagStr + 'Main Unit ';
if Flags and ufPackageUnit <> 0 then
FlagStr := FlagStr + 'Package Unit ';
if Flags and ufWeakUnit <> 0 then
FlagStr := FlagStr + 'Weak Unit ';
if Flags and ufImplicitUnit <> 0 then
FlagStr := FlagStr + 'Implicit Unit ';
if FlagStr <> ' ' then
FlagStr := ' (' + FlagStr + ')';
Form5.Memo1.Lines.Add(Name + FlagStr);
end;
procedure TForm5.Button1Click(Sender: TObject);
var s: string;
NeedFreeLibrary: boolean;
ResModule: HModule;
Flags: integer;
begin
s := 'G:\Project\output.d10\mars\sqlpay.exe';
s := 'c:\windows\system32\tee100.bpl';
NeedFreeLibrary := True;
ResModule := LoadResourceModule(PChar(s));
if ResModule = 0 then begin
ResModule := GetModuleHandle(PChar(s));
if ResModule = 0 then
ResModule := LoadLibraryEx(PChar(s), 0, LOAD_LIBRARY_AS_DATAFILE
+ DONT_RESOLVE_DLL_REFERENCES)
else
NeedFreeLibrary := False;
if ResModule = 0 then
begin
raise Exception.Create('Error');
end;
end;
try
GetPackageInfo(ResModule, nil, Flags, ShowInfoProc);
finally
if NeedFreeLibrary then
FreeLibrary(ResModule);
end;
end;
--
Best regards,
Chau Chee Yang
E Stream Software Sdn Bhd
URL: www.sql.com.my
SQL Financial Accounting |
|
| Back to top |
|
 |
Bob Swart Guest
|
Posted: Tue Mar 20, 2007 9:58 pm Post subject: Re: How to extract required runtime package from Win32 .EXE |
|
|
Hi Chau Chee Yang,
| Quote: | Dr. Bob has a neat command line tool called REQUIRED.EXE that does the
job:
http://www.drbob42.com/tools/index.htm
I have tried this utility and heard that it try to scan PE information.
|
You heard wrong.
| Quote: | However, there is no source code from there and I don't know how it get
the required .BPL from the .EXE
Please advice. Thank you.
|
You could just ask me for the source code, of course ;-)
I've sent the source to your mailbox (a console application of less than
4 KB source, parsing through the binary file searching for .BPL and .DPL
strings).
I believe this was also documented in an article for The Delphi
Magazine, issue #23, way back in July 1997 (wow, and it still works).
Groetjes,
Bob Swart
--
Bob Swart Training & Consultancy (eBob42.com) Forever Loyal to Delphi
Blog: http://www.drbob42.com/blog - RSS: http://drbob42.com/weblog.xml
New Delphi 2006 Courseware e-books at http://www.eBob42.com/courseware |
|
| Back to top |
|
 |
Chau Chee Yang Guest
|
Posted: Wed Mar 21, 2007 7:22 am Post subject: Re: How to extract required runtime package from Win32 .EXE |
|
|
Hi Bob Swart,
Thank you for your source code. I just wondering why the GetPackageInfo
can't extract the required runtime packages (.bpl) from .exe file.
I have an application of size 15MB built without runtime packages. It
took about 10-12 seconds to compile + linking each time I press F9.
However, if I try to compile it with runtime packages, it spend only
about 3-4 seconds and the .exe file size get reduce to 6-7MB. That's
great for development stage. I may further reduce the compilation time
if I partition my application into modules (or runtime package).
After explore more on runtime packages, I learned that we can use
runtime packages for pluggable modular design. As our application
features get complicated, the file size is growing and the time spent to
compile the application is getting slower. If I able to partition the
application into modules, then I don't always compile the whole
application in development process. It seems like runtime package win
the job. I don't prefer the .DLL approach as it doesn't work together
with the main application's space nor it's OO design.
However, I use quite a number of third party component. The total
runtime packages are about 40-50 files (VCL + 3rd party) in my
application. It is a problem to manage that number of files during
deployment compare to single .exe file deployment.
I may classified the problem into 2 stages:
A. Development Stage:
- built with runtime package to save compile and linking time
- design application function in runtime packages and plug into main
application during runtime. We will save a lot of compilation time.
B. Deployment Stage:
- Easy deployment, less files is better
- Ideal deployment files: one .exe + few .bpl runtime packages
- Use LoadPackage at runtime to save the resources consume at startup time.
I don't mind build the application with 40-50 runtime packages at
development stage but it is a headache on deployment stage. I am
thinking to repackage the runtime packages into the following:
1. Delphi RTL+VCL package (repackage delphi's runtime packages into one
file)
2. 3rd party component package (repackage 3rd party runtime packages
into one file)
3. Application module runtime package (one module per .bpl file)
4. Application .EXE (should be very small in size)
Please advice if you have any good solution to manage both the situation
in development and deployment stage.
Thank you.
| Quote: | Hi Chau Chee Yang,
Dr. Bob has a neat command line tool called REQUIRED.EXE that does the
job:
http://www.drbob42.com/tools/index.htm
I have tried this utility and heard that it try to scan PE information.
You heard wrong.
However, there is no source code from there and I don't know how it
get the required .BPL from the .EXE
Please advice. Thank you.
You could just ask me for the source code, of course ;-)
I've sent the source to your mailbox (a console application of less than
4 KB source, parsing through the binary file searching for .BPL and .DPL
strings).
I believe this was also documented in an article for The Delphi
Magazine, issue #23, way back in July 1997 (wow, and it still works).
Groetjes,
Bob Swart
|
--
Best regards,
Chau Chee Yang
E Stream Software Sdn Bhd
URL: www.sql.com.my
SQL Financial Accounting |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|