How to have Common Source Code for both 16/32-bit Platforms
Keywords: winmetrics
Both WinBatch and WinBatch + Compiler come with both 16 and 32 bit versions, allowing you to program on any 16 or 32 bit platform. During installation, WinBatch autodetects what version of Windows we're on, and installs the appropriate one for your platform. If you want to install the 16-bit Compiler on a 32-bit platform, then you need to check that option during installation.
If you will be running a WinBatch EXE on Windows for WorkGroups or Windows 3.1, then you must compile with the 16 bit version of the Compiler. With the 16 bit version, you can use the various network extenders: Netware 3, Netware 4, Multinet and the Basic Network extender. You cannot use the Win32 network extender with the 16 bit version; use that for 32-bit compiled EXEs.
If you are running your WinBatch EXEs on Windows NT or Win95 you should use the 32 bit version. The 32 bit platforms do have the capability to run 16 bit programs, so 16 bit WinBatch scripts will conceivably run. However, not all functionality will be supported. Especially the networking and Sendkeys functions. To get network functions to work, you must run in "native" mode with the appropriate extenders. We have 32 bit extenders for WinNT/95 MS Clients, Netware 3 and 4, and a special Internet extender (available on the Web site) for Winsock functions (32-bit only).
If you need to write scripts for both types of platforms, WinBatch can determine what platform you are using. The function names are the same regardless of which version of WinBatch you are using. You just need to compile your code with the appropriate Compiler, 16 or 32. If you need to decide on the fly which version of a program should be run, you can test for this by adding some additional code to the 16 bit EXE.
You will need two versions of your script. One compiled with the 32 bit compiler and a 16 bit version. The 16-bit version will determine what platform you're on, and launch the appropriate EXE. This example requires 3 EXEs: The sample script below to detect the platform, compiled in 16-bit, and then the 2 EXEs:
;Verify version of Windows and that we know what we are doing ;0=??? 1=Win 2=Win4Wkg 3=Win32S 4=WinNT 5=Win95 if WinMetrics(-4) >= 4 Run("Winbatch.exe", "") ;;or the 32 bit version of your compiled WinBatch script. exit else Run("wbat16i.exe", "") ;;or the 16 bit version of your compiled WinBatch Script. endifAbout 2/3 of the time you will need 2 EXE files (one compiled in 16-bit and the other, 32-bit). Just tell your users about the 16 bit exe, which acts like a loader program, and they don't need to know about the two EXEs.Here's a slightly different variation:
;Common Source code for both 16 and 32 bit exe's ; compiled as myprog.exe (16 bit version) and myprog32.exe (32) if WinMetrics(-2)==1 then go to code16 if WinMetrics(-4)>=4 ; EEK running 16 bit code on a 32 bit operating system Run("myprog32.exe","") ; launch 32 bit version and exit out of here exit ; exit endif :CODE16 ; 16 bit code goes here Message("Hello","Running 16 bit code") exit ;contents of myprog32.exe.... ;32 bit code goes here Message("Hello","Running 32 bit code") exitNote: WinMetrics(-2) tells you how the WinBatch script was compiled (for common source code), NOT what platform you are running on. Use WinMetrics(-4) to tell what platform you are running on.
Article ID: W12723Filename: How to have common source code for 16 and 32 bit.txt