A: The difference that you're seeing is the difference in OWL vs. VCL. If BP7 *could* compile a Delphi app (it can't because of language extensions), the executable would be the same size (give or take a hundred bytes) as the Delphi compiled executable. So to answer your question, Delphi already does compile and executable as small as BP7 does.
Program ExitWin;
uses WinProcs;
begin
ExitWindowsExec('', '');
end.
will create a 2816 byte executable with the Delphi compiler. Then, if you run W8LOSS.EXE, it will shrink it down to 2463 bytes!!!
Note: This program will exit and restart windows.
*********************
Here is one that came about as a result of a small competition on compuserve. Here is the essence of the thread:
Hi James,
> The program also iterates through the active tasks looking at module names. If it can go smaller, I'd love to see how but I won't be upset if it stays at 17k. :)
Well, I'm willing to go for half of your size (I love a good challenge before breakfast)...
> This exe makes sure no Office apps are running by looking for specific module names in the task list. If one is found, we throw up that darn message box and quit.
Groetjes,
Dr. "I want
to climb the mountain because it's there!" Bob
**************
You're on! :)
The great way to learn is to see someone do something just a little bit better. So here you go...
MSOFFICE
VB
WINWORD
EXCEL
MSACCESS
PP4
These are the modules names. Basicall, if one of these is running you
got to throw up a message box and then get out. It none are running, you
need to ShellExecute another EXE, passing it any command line arguments
this program receives.
I'm looking forward to your results.
'I have been to the top of the mountain, and it was good." - Beevis and Butthead <g>
James Foxall
**************
Hi James,
You had an executable of 17Kb, right? Well, I've done it in less than 2.5 Kb (in fact, I ended up with 2133 bytes - including on-line help <g>). You'll have to supply the setup routine as command-line arguments, but other than that it'll work just fine.
(It'll probably be somewhat smaller if you hardcode the 'install sequence' but I didn't know what they were, so...)
{$A+,B-,D-,F-,G+,I-,K+,L-,N-,P-,Q-,R-,S-,T-,V-,W-,X+,Y-}
{$M 32768,0}
program NoOffice;
{
File: NOOFFICE.PAS
Author: Bob Swart
Compiler: Borland Pascal 7.01
Purpose: To quit when any MS Office module is loaded,
otherwise run the command-line arguments...
Usage: NOOFFICE Setup /X
Example: NOOFFICE NOTEPAD C:\CONFIG.SYS
Code Size: 1154 Bytes
Data Size: 338 Bytes
.EXE Size: 2560 Bytes (2133 after running W8LOSS.EXE)
}
uses WinTypes, WinProcs;
Const
Run: String[127] = #0;
Const
Office : Array[0..5] of PChar =
('MSOFFICE','VB','WINWORD','EXCEL','MSACCESS','PP4');
var i: Integer;
begin
if ParamCount = 0 then
MessageBox(0,'Usage: NOOFFICE <setup>',
Office[0],
MB_ICONINFORMATION OR MB_OK)
else
begin
for i:=0 to 5 do
begin
if GetModuleHandle(Office[i])
<> 0 then { found? }
begin
MessageBox(0,'MS-Office
is still running!',Office[i],
MB_ICONHAND OR MB_OK);
Halt
end
end;
for i:=ParamCount downto 1 do Run := ParamStr(i)
+ #32 + Run;
WinExec(@Run[1],SW_SHOW)
end
end.