3

I have a 32 bit exe file compiled with Turbo Pascal. I need to launch it. It worked well when I had Windows 7 32 bit, but now I'm on Windows 7 64 bit, and I get the following exception:

The specified executable is not a valid application for this OS platform.

To make sure it works on 32 bit systems, I launched the C# program in a 32 bit platform - it works.

So how can I launch a 32 bit exe file in 64 bit OS?

Thanks

Alex
  • 34,581
  • 26
  • 91
  • 135

4 Answers4

12

Turbo Pascal could only generate 16-bit code, there was never a version that could create 32-bit executables. Running 16-bit code requires a virtual machine that uses the real-mode emulation support in the CPU (virtual 8086 mode). This emulation is not available if the processor is running in 64-bit mode.

You cannot run 16-bit processes on a 64-bit operating system. You may have a shot at getting it going with the DOSBox emulator.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • But I could launch it on a 32 bit system. – Alex Sep 28 '10 at 16:25
  • 4
    @Alex - Yes of course, that one isn't running a 64-bit operating system. – Hans Passant Sep 28 '10 at 16:27
  • 1
    I agree with Hans, double check that your progam is not really 16 Bit, Windows 64 dropped support for 16 bit. You can check it with a program like [EXE Explorer](http://www.mitec.cz/exe.html) – Scott Chamberlain Sep 28 '10 at 18:43
  • You are right. The pascal program was indeed 16 bit. I recompiled it with Free Pascal (I have the sources), so now it works fine. Thank you! – Alex Oct 01 '10 at 08:02
2

If you're launching the 32 bit exe from within a .NET (C#) application, then you'll need to set the target for your .NET app to x86. If it's set as Any CPU, then it will run as a 64 bit process on a 64 bit OS and therefore won't be able to launch the 32 bit process.

Edit: This MSDN article explains how to modify this setting: http://msdn.microsoft.com/en-us/library/5b4eyb0k.aspx

Edit 2: As Gabe points out, there shouldn't be a reason why the 64 bit app could not start a 32 bit exe. I know you can't use a 32-bit DLL from within a 64-bit app. Just thought it would be worth trying since the documentation doesn't specify if that same restriction exists when using System.Diagnostics.Process to launch an exe.

CoderDennis
  • 13,642
  • 9
  • 69
  • 105
2

You can launch 32bit application from 64bit application.

C# Example 1:

var processStartInfo = new ProcessStartInfo("C:\MyApp.exe");
var process = new Process { StartInfo = processStartInfo };
process.Start();
process.WaitForExit();

C# Example 2:

System.Diagnostics.Process.Start("C:\MyApp.exe");
Paulius Zaliaduonis
  • 5,059
  • 3
  • 28
  • 23
1

I don't think there is a 64 bit compiler for Turbo Pascal so I think your only choice is to compile your app targeting a 32 bit enviornment.

bigtang
  • 261
  • 1
  • 6