home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / SOURCE / STARTUP / WIN / STUBMAIN.AS_ / STUBMAIN.AS
Encoding:
Text File  |  1993-02-08  |  2.5 KB  |  131 lines

  1.     page    ,132
  2.     title    stubmain - Default main() procedure for windows
  3. ;***
  4. ;stubmain.asm - Default main() procedure for windows
  5. ;
  6. ;    Copyright (c) 1990-1992, Microsoft Corporation.  All rights reserved.
  7. ;
  8. ;Purpose:
  9. ;    (see routine description below)
  10. ;
  11. ;*******************************************************************************
  12.  
  13. .xlist
  14. include version.inc
  15. ?WIN = 1
  16. include cmacros.inc
  17. .list
  18.  
  19. ;
  20. ; External code
  21. ;
  22.  
  23. ifdef _WINDLL
  24.  
  25. extrn       pascal __nomain:far        ; Alternate main
  26. extrn       pascal LIBMAIN(__nomain):far ; User's main code
  27.  
  28. else ;!_WINDLL
  29.  
  30. if    sizeC
  31. extrn       pascal __nomain:far        ; Alternate main
  32. extrn       pascal WINMAIN(__nomain):far ; User's main code
  33. else
  34. extrn       pascal __nomain:near     ; Alternate main
  35. extrn       pascal WINMAIN(__nomain):near; User's main code
  36. endif
  37.  
  38. endif ;_WINDLL
  39.  
  40. ;
  41. ; External data
  42. ;
  43.  
  44. sBegin    data
  45. assumes ds,data
  46.  
  47. ifdef _WINDLL
  48. externW _hModule        ; parameters for LIBMAIN
  49. externW _wDataSeg
  50. externW _wHeapSize
  51. externD _lpszCmdLine
  52. else
  53. externW _hPrevInstance        ; parameters for WINMAIN
  54. externW _hInstance
  55. externD _lpszCmdLine
  56. externW _cmdShow
  57. endif
  58.  
  59. sEnd    data
  60.  
  61.  
  62. sBegin    code
  63. assumes cs,code
  64. assumes ds,data
  65.  
  66. page
  67. ;***
  68. ; stubmain - Call the user's procedure
  69. ;
  70. ;Purpose:
  71. ;
  72. ;    Windows programs may have either a main() or a WinMain()/LibMain()
  73. ;    procedure entry point:
  74. ;
  75. ;    (1) main() - If a program has main(), then that routine will be
  76. ;    call.  If not, this routine will be called via a weak extern.
  77. ;
  78. ifdef _WINDLL
  79. ;    (2) LibMain() - If the user's program has LibMain() instead of
  80. ;    main(), then this routine is called which, in turn, calls LibMain().
  81. else
  82. ;    (2) WinMain() - If the user's program has WinMain() instead of
  83. ;    main(), then this routine is called which, in turn, calls WinMain().
  84. endif
  85. ;
  86. ;Entry:
  87. ;    (same as main)
  88. ;Exit:
  89. ;    (returns value passed back from WinMain/LibMain routine).
  90. ;Uses:
  91. ;
  92. ;Exceptions:
  93. ;    If the user has neither a main() or WinMain()/LibMain() procedure,
  94. ;    the app will fail with a runtime error.
  95. ;
  96. ;*******************************************************************************
  97.  
  98. cProc    _stubmain,<PUBLIC>,<>
  99.  
  100.     parmW    argc
  101.     parmDP    argv
  102.     parmDP    envp
  103.  
  104. cBegin    <nolocals>
  105.  
  106. ifdef _WINDLL
  107.  
  108.     push    (_hModule)
  109.     push    (_wDataSeg)
  110.     push    (_wHeapSize)
  111.     push    word ptr (_lpszCmdLine+2)
  112.     push    word ptr (_lpszCmdLine)
  113.     call    LIBMAIN
  114.  
  115. else    ;!_WINDLL
  116.  
  117.     push    (_hInstance)
  118.     push    (_hPrevInstance)
  119.     push    word ptr (_lpszCmdLine+2)
  120.     push    word ptr (_lpszCmdLine)
  121.     push    (_cmdShow)
  122.     call    WINMAIN
  123.  
  124. endif    ;_WINDLL
  125.  
  126. cEnd    <nolocals>
  127.  
  128. sEnd    code
  129.  
  130.     end
  131.