Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

DarkEmpire

.com vs .exe

This topic is 5838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Is it possible to create a ".com" executable with Visual C++ 6 ? or can we create only ".exe" executable ? Are ".com" smaller than ".exe" ? Are there advantages ? Thanks for your help

Share this post


Link to post
Share on other sites
Advertisement
.COM''s have max size (data & code) of 64k.
Also I don''t think you can do windows programming with a COM file, although I could be wrong there.

I''m pretty sure MSVC doesn''t make .COM files.

Share this post


Link to post
Share on other sites
If I recall correctly, in COM files you have to use a single segment (CS=DS=ES=SS). This segment has to be < 64K.

Therefore COM files must be written using assembly language, as most compilers use multiple segments. At least, I have never seen a high-level compiler generate code like this (I do remember a BAT2COM utility though).

As a result, I think that COM files have to be 16-bit code (1 16-bit segment...no flat memory model). If this is true, then there is no way MSVC++ can generate them, as VC++ only makes 32-bit Windows EXE files.

And don't let COMMAND.COM fool you (it's actually an EXE in newer versions).

--TheMuuj

[edited by - themuuj on June 25, 2002 5:39:43 PM]

Share this post


Link to post
Share on other sites
Q: Is it possible to create a ".com" executable with Visual C++ 6 ?
A: Not unless it is an undocumented feature. You would more likely use an assembler (e.g. masm)

Q: Are ".com" smaller than ".exe" ? Are there advantages ?
A: By definition, com files are 64kB max... runtime stack and heap included. AFAIK there''s no big advantage anymore.


Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

Share this post


Link to post
Share on other sites
In fact, i try to find tips to have the smallest executable as possible.

In fact, i searched on google and developpment websites, how to create very small exe with VC6 but i did not find the solution.

In fact, with linker options i use, the smallest empty project executable i succeeded to create is a 517 bytes one... But i think it s very big for a application that does nothing ...

Have you got tips to help me ?

Share this post


Link to post
Share on other sites
Intersting trick, you can rename an EXE to a COM and it will still work exactly the same. This is actually usefull because there are some viruses that will make it impossible to run EXE''s (including virus scanner), so you rename the EXE to COM.
You can also use this trick on some NT based systems that have REGEDIT locked. if you rename REGEDIT.EXE to REGEDIT.COM you can usually get around the lockout. Of course, it the sysadmins are smart enough, they''ll lock renaming REGEDIT.

Share this post


Link to post
Share on other sites
"In fact"? What, you think they''re lying to you. Like 3 people said the same thing. One of them has to be right. Or maybe I''m lying...

Even if a program does nothing, it has to link to certain libraries in order for it to even have a minimal amount of capability (for instance, starting up through a main function). "In Fact", if you use the MFC libraries, your program will ALWAYS be huge. This has to do with all the background linking it does. 517 bytes for a program seems about small even if you link to at least a standard library (iostream). When you start using DirectX or OpenGL or any nice API out there (Graphics or whatever), that size will substantially grow no matter what. If you wanted to enter one of those demo scene competitions the way to go is by creating your own librarys, using procederal geometry and textures, and compressing your .exe. A .com file is not a solution to anything anymore really (''cept for viruses or maybe drivers).

What help do you want? Their answer was no you can''t make com files in Visual C++ 6 and they are limnited to 64k...

Btw, with just a void main() {} in Visual C++ 7.0 with a retail build optimized for size, my file was 20.5 KB. Good job with your 517 bytes.



"Love all, trust a few. Do wrong to none." - Shakespeare

Dirge - Aurelio Reis
www.CodeFortress.com

Share this post


Link to post
Share on other sites
quote:
Original post by DarkEmpire
In fact, i searched on google and developpment websites, how to create very small exe with VC6 but i did not find the solution.


At MSDN search on "tinycrt" - Matt Pietrek has written three columns on the subject over the years. Also take a look here: http://www.hailstorm.net/papers/smallwin32.htm. There is an article "Small Windows Executables" at CFXWeb with details in Hugi21 - that is all asm though.


quote:
Original post by DarkEmpire
In fact, with linker options i use, the smallest empty project executable i succeeded to create is a 517 bytes one... But i think it s very big for a application that does nothing ...



That''s pretty damn small if you ask me. Especially considering the file alignment sets the PE file headers to 512 bytes. If you''re getting down to that size, then you are breaking new ground, I think and you''re not likely to find much more help on the www.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!