Recently I opened a .dll file produced by Visual Studio 9 while compiling a native C++ DLL project and was surprised to see the "This program cannot be run in DOS mode" text near the beginning.

You are watching: This program cannot be run in dos mode

Why have this text in .dll files?


A dll is very much like an executable with a different extension. The text you saw is part of the "standard" executable header on windows. It is (was) used to gracefully abort the attempt to run a windows executable from DOS.


The Portable Executable format specification states the following:

The MS-DOS stub is a valid application that runs under MS-DOS. It is placed at the front of the EXE image. The linker places a default stub here, which prints out the message “This program cannot be run in DOS mode.” when the image is run in MS-DOS. The user can specify a different stub by using the /STUB linker option.

At location 0x3c, the stub has the file offset to the PE signature. This information enables Windows to properly execute the image file, even though it has an MS-DOS stub. This file offset is placed at location 0x3c during linking.


Win32 programs run from DOS mode (ie, single user, no graphics) print that text. DLLs probably print that message too if you try to use them without Windows running.


Thanks for contributing an answer to Stack Overflow!

Please be sure to answer the question. Provide details and share your research!

But avoid

Asking for help, clarification, or responding to other answers.Making statements based on opinion; back them up with references or personal experience.

See more: Motherboard Asus Crosshair V Formula-Z Drivers, Home > Motherboards > Asus > Crosshair V Formula

To learn more, see our tips on writing great answers.

Post Your Answer Dismap

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged windows visual-c++ or ask your own question.


site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev2021.9.23.40291

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.