Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why won't my WINVER 4 .exe run under W98SE?

Tags:

windows

I need to build my application for a legacy system running Windows 98SE. (The system involves special hardware and an OS upgrade is not a possibility.) My development environment is Visual C++; the application is vanilla ANSI C, and the result is a WIN32 console application.

I am aware that in Visual Studio 2008 support for older version of Windows was dropped completely, so I am using instead Visual Studio 2005 (which I still have on my last-generation Windows XP laptop). I have conditional compilation to avoid calling API functions not available under W98SE, and I know about not using Unicode.

n.b. This all used to work. I have successfully built W98SE executables in the past. Somehow.

The application I have built fails with the "Expects a newer version of Windows. Upgrade your Windows version".

I have examined the .exe file with a hex editor, and the WINVER value (which in this case is at offset 288 decimal) is 4, as it should be. On the normal build, i.e. for modern Windows versions, the WINVER value (which in this case is at offset 296 decimal) is 5. So how is it possible for the WINVER=4 version to cause the "Expects a newer version" error to be reported?

like image 900
Patrick Wallace Avatar asked Oct 03 '12 20:10

Patrick Wallace


1 Answers

Most likely you have linked it with more recent runtime library MSVCRT.DLL. Try following:

dumpbin /dependents myfile.exe

If it shows MSVCRTnn.DLL, you are in trouble. If it shows MSVCRT.DLL (no numbers), you should be good, but still cautious.

Probably easiest solution is to link runtime library statically: in project properties, under C/C++, Code generation, set Runtime Library to /MT or /MTd. If you use /MD or /MDd or default, it will link to runtime dynamically and may cause trouble.

After changing this, "dumpbin /dependents myfile.exe" should no longer list dependency on MSVCRT.DLL and it should just work.

like image 142
mvp Avatar answered Oct 21 '22 20:10

mvp