05300538.txt 30-May-00

Subject: A tip for convert DOS application to Windows version
From: nswong@maxis.net.my (Wong)

Hi All,


This is the result of the reply to Bod at CLIPPER NG(News
Group), I think it may help somebody who are going to
convert their DOS application to Windows version, so I
posted here.

F:\HRSOURCE\TODO\WONG>external.exe

Running Win32 application: getcomna.exe
Value return by Win32 application: PKCS
Value return by NETNAME(): PKCS

F:\HRSOURCE\TODO\WONG>

Above is a screen output of CLIPPER program, that is created
to show one of the ways to accept return value from an
external 32bit Windows application.

Calling an external 32bit Windows application having some
advantage:

32bit Windows application does not sharing memory address
space with CLIPPER program, so CLIPPER program will NOT have
"Memory Low" problem.

Provide some functionality which does not directly available
to DOS program.

Allow to do incremental convertion of application, and
slowly port our application to Windows version. In the
transition period, our client are running mixed
version(Windows and DOS at the same time) of our product,
this will save our trouble of maintain two set(DOS and
Windows) of source code, whenever Windows version are
completed, DOS equivalent can be scrap off.

I have included File Version Information Structure and Icon
in the VO program, just to show how easy to include these
feature in a 32bit application.

The Icon is what you see on the Windows, you can switch
between
View->Large Icons and View->Small Icons to see the effect.

Right click on the getcomna.exe, chose Properties->Version
and you will see information about File Version Information
Structure.

This just to show Windows development are not really as
tough as some people think. :-)

But anyway, I still prefer Unix development: simple and
reliable. <g>

No, Geoff! I will not going to argue with you which OS are
better, I just let you win. <bg>

This is the ZIP file available from my personal web site,
this ZIP file will be remove about one week later:

GETCOMNA ZIP       428,640  05-18-00  1:54p GETCOMNA.ZIP

http://members.xoom.com/n_s_wong/getcomna.zip
http://www.angelfire.com/ns/nswong/getcomna.zip

This is the list of the files contain in GetComNa.zip:

GETCOMNA PRG         1,648  05-17-00  5:27a getcomna.prg
GETCOMNA EXE        36,864  05-17-00  5:29a getcomna.exe
GETCOMNA TXT         1,051  05-17-00  5:29a getcomna.txt
CAVORT20 DLL       456,704  01-06-99  2:02a CAVORT20.DLL
EXTERNAL EXE         5,120  05-18-00  1:49p EXTERNAL.EXE
EXTERNAL PRG           830  05-18-00  1:49p EXTERNAL.PRG
CYBASE52 PLL       432,128  11-04-98  5:03p CYBASE52.PLL

Both External.exe and GetComNa.exe are using external
runtime library, since the EXE file size are so small, this
will help when we need to update our customer through E-
mail.

External.exe are DOS/CLIPPER program and depend on runtime
library CYBase52.PLL.

GetComNa.exe are Windows/VO program and depend on runtime
library CAVORT20.DLL.

This is CLIPPER source code:

PROCEDURE External()
  LOCAL nCount,cComputerName
  LOCAL cApp:="getcomna.exe"
  LOCAL cCrLf:=CHR(13)+CHR(10)
  LOCAL cFile:="getcomna.log"
  //Output of OUTSTD can by redirect, eg:
  //C:\>External > External.log
  //This will redirect the screen output to a text file
  //  External.log
  OUTSTD("Running Win32 application: "+cApp+cCrLf)
  RUN (cApp)
  nCount:=1
  cComputerName:=MEMOREAD(cFile)
  DO WHILE cComputerName=='' .AND. nCount<=60
    INKEY(1)
    cComputerName:=MEMOREAD(cFile)
    ++nCount
  ENDDO
  OUTSTD("Value return by Win32 application: "+;
    cComputerName+cCrLf)
  OUTSTD("Value return by NETNAME(): "+NETNAME()+cCrLf)
RETURN

This is VO source code:

PROCEDURE Start()
  LOCAL DIM abBuffer[MAX_COMPUTERNAME_LENGTH + 1] AS BYTE
  LOCAL dwSize AS DWORD
  dwSize:=MAX_COMPUTERNAME_LENGTH + 1
  GetComputerName(@abBuffer, @dwSize)
  MemoWrit("GetComNa.log", Psz2String(@abBuffer))
RETURN


RESOURCE PK ICON pk.ico

RESOURCE VS_VERSION_INFO VERSIONINFO
  FILEVERSION    2,0,0,__VERSION__
  PRODUCTVERSION 2,0,0,__VERSION__
  FILEFLAGSMASK  0x3fL
  FILEFLAGS      VS_FF_SPECIALBUILD
  FILEOS         VOS__WINDOWS32
  FILETYPE       VFT_APP
  FILESUBTYPE    0x0L
BEGIN
  BLOCK "StringFileInfo"
  BEGIN   BLOCK "040904b0"
    BEGIN
      VALUE "Comments", "The GetComputerName ";
        "function retrieves the computer name ";
        "of the current system. This name is ";
        "established at system startup, when it ";
        "is initialized from the registry.\0"
      VALUE "CompanyName", "PK COMPUTER SERVICES\0"
      VALUE "E-mail", "pkcs@tm.net.my\0"
      VALUE "Fax", "603-6379414\0"
      VALUE "FileDescription", ;
        "EXE to demonstrate VS_VERSION_INFO\0"
      VALUE "FileVersion", "17-May-00\0"
      VALUE "InternalName", "VS_VERSION_INFO EXE\0"
      VALUE "LegalCopyright", ;
        "Copyright PKCS\251 1988 - 2000\0"
      VALUE "LegalTrademarks", ;
        "HRMAS\256 is a trademark of PKCS\0"
      VALUE "OriginalFilename", "getcomna.exe\0"
      VALUE "ProductName", "HRMAS\0"
      VALUE "ProductVersion", "2.0b-4\0"
      VALUE "SpecialBuild", "For Bob Predaina\0"
      VALUE "Tel", "603-6378648\0"
    END
  END
  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0x409, 1200
  END
END

Regards,
Wong