home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VIOREG.ZIP / VIOREG.XMP < prev   
Text File  |  1989-05-21  |  3KB  |  106 lines

  1. Microsoft Customer Support Engineer remarks:
  2. The function VIOREGISTER () is not broken, here is a sample code
  3. which uses the function VIOREGISTER () to register VIOPRTSC (). The
  4. VIOPRTSC () is defined by the user in a .dll file.
  5.  
  6. You have to use 'implib' utility to produce a .lib file for resolving
  7. identifier names. For this example the correct syntax of the command is :
  8.  
  9.               implib test.lib test.def
  10.  
  11.      ------------------------------------------------
  12.  
  13. /* This is a sample program to show the use of function VIOREGISTER ().
  14. The VIOREGISTER () call is used to register the function VIOPRTSC (), which
  15. is defined by the user in dynamic link library.
  16.  
  17. MASK1 enables the mask for VIOPRTSC ()      */
  18.  
  19. #define   MASK1   0x01000000
  20. #define   MASK2   0x00000000
  21.  
  22. #include "subcalls.h"
  23.  
  24. extern unsigned far pascal VIOPRTSC (unsigned);
  25.  
  26. main() {
  27.  
  28. /*  test is the name of dynamic link library file   */
  29.  
  30.         VIOREGISTER ((char far *) "test", (char far *) "test",
  31.               (unsigned long) MASK1, (unsigned long) MASK2) ;
  32.         VIOPRTSC ((unsigned) 1) ;
  33.     }
  34.  
  35. ----------------------------------------------------------------------
  36.  
  37. /*   this is a dynamic link library file to test VIOREGISTER call for
  38.      VIOPRTSC () .*/
  39.  
  40. #define ADDRESSING far
  41. #define CALLING pascal
  42. #define CONVENTION ADDRESSING CALLING
  43. #include "doscalls.h"
  44.  
  45. /*   user defined VIOPRTSC ()   */
  46.  
  47. unsigned CONVENTION VIOPRTSC (j)
  48. unsigned j ;
  49. {
  50. int i ;
  51.  
  52. /*   test message to verify the working of this function   */
  53.  
  54.    DOSWRITE (1, "This is from DLL", sizeof ("This is from DLL"), &i) ;
  55.  
  56. }
  57.  
  58.  
  59. /*   compiler emits _acrtused as an external to pull in crt0.obj that
  60.      defines _astart and calls _main. Add a dummy so crt0 is not pulled
  61.      in.  */
  62.  
  63. #undef CALLING
  64. #define CALLING cdecl
  65.  
  66. int CONVENTION _acrtused(){} ;
  67.  
  68.  
  69. /*   the start up routine must be called _astart and it must return
  70.      success or failure. Return success.  */
  71.  
  72. int CONVENTION _astart() {
  73.     return 1 ;
  74.     }
  75. ------------------------------------------------------------------------
  76.  
  77. This is the make file for simple.c
  78.  
  79. simple.obj : simple.c
  80.      cl -c -AH -G2 -Os -Zp simple.c
  81.  
  82. simple.exe : simple.obj simple.def
  83.      link simple, simple/co, simple/map, test.lib llibc5.lib doscalls.lib, simple.def
  84. ----------------------------------------------------------------------------------
  85.  
  86. This is the make file test.c
  87.  
  88. test.obj : test.c
  89.      cl -c -Alnu -G2s  test.c
  90.  
  91. test.dll : test.obj test.def
  92.      link test.obj, test.dll, test.map/map, llibc5.lib doscalls.lib, test.def
  93. -----------------------------------------------------------------------------
  94. This is test.def file which is used to produce test.lib file using IMPLIB
  95. utility.
  96.  
  97. LIBRARY       test
  98.  
  99. DESCRIPTION     'Test for VioRegister'
  100.  
  101. EXPORTS
  102.         VIOPRTSC @ 1
  103.  
  104. ----------------------------------------------------------------------------
  105.  
  106.