Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Blinker 5.10 Online Reference - <b> generic shared windows and dos extended dll example</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 Generic shared Windows and DOS extended DLL example
------------------------------------------------------------------------------
 The example programs in the \C\DLL\STC subdirectory of the Blinker
 installation directory show how to create a Windows program and a DOS
 extended program which both load and execute the same Windows DLL. Please
 refer to the make file for more details, but to use Microsoft Visual C++ 1.5
 as an example, the compile lines would resemble the following:

 CL -c -AL t.c              Normal compile for main program
 CL -c -AL -GD d.c          Compile for a DLL

 Now create a link script file for the DLL, including an export definition
 for the function to be exported, and link the DLL using the Windows DLL run
 time libraries, in this case LDLLCEW and LIBW.

 Although most compilers automatically create an export definition within the
 .OBJ file when a function is declared with the __export keyword in the
 source code, specifying the function name in the EXPORTS section of the DLL
 module definition file gives the programmer more control over how the symbol
 is exported. Now use an import librarian such as BLILIB (see the section
 `The BLILIB import librarian' in Chapter 4) to create an import library
 which can be linked with the calling program:

 # DW.LNK to create Windows D.DLL
 OUTPUT d                   # The output file name
 FILE d                     # List OBJ files here
 DEFBEGIN                   # Module definition commands
    LIBRARY  'd'            # Indicate a DLL and its name
    EXETYPE  WINDOWS 3.1    # It is for Windows 3.1 and above
    HEAPSIZE 1024           # It requires a local heap of 1 Kb
    EXPORTS                 # Export the following symbols
       _test                # Export _test by name
 DEFEND                     # End module definition commands
 LIB LDLLCEW                # Windows DLL runtime library
 LIB LIBW                   # Windows import library
 NODEF                      # No default libraries
 BLINKER @dw                # Link the .DLL
 BLILIB /ID d /OL d         # Create the import library

 Finally, create the main link file to use the generated import library
 instead of linking the D.OBJ file directly:

 # T.LNK to create T.EXE
 BLI EXECUTABLE EXTENDED    # Create DOS extended program
 OUTPUT t                   # The output file name
 FILE t                     # List OBJ files here
 LIB D                      # The import library just created
 LIB BLXMVC15               # Blinker protected mode library
 BLINKER @T                 # Link the .EXE

 This should now have created T.EXE which will load and execute the code in
 D.DLL. A similar program demonstrating the dynamic linking and loading of
 DLLs is also included in the \C\DLL\DYN subdirectory.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson