home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / snapx2.exe / SPMENU.EXE / SNAPMENU.C next >
C/C++ Source or Header  |  1995-02-03  |  8KB  |  173 lines

  1. /*-------------------------------------------------------------------------*/
  2. /* snapmenu.c                                                              */
  3. /*                                                                         */
  4. /* (c) Copyright 1992-1995 Novell, Inc.  All rights reserved.              */
  5. /*                                                                         */
  6. /* The following source code is provided to aid in the development of      */
  7. /* NetWare (TM) compatible products and is provided "AS IS" AND WITHOUT    */
  8. /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING WITHOUT LIMITATION ANY     */
  9. /* IMPLIED WARRANTIES OF MERCHANTABILITY, TITLE AND FITNESS FOR A          */
  10. /* PARTICULAR PURPOSE.  Some states do not allow limitations on how long   */
  11. /* an implied warranty lasts, so the above limitation may not apply to     */
  12. /* You.  This warranty gives you specific legal rights which vary from     */
  13. /* state to state.  Some states do not allow the exclusion or limitation   */
  14. /* of incidental or consequential damages, so the above limitation or      */
  15. /* exclusion may not apply to You.                                         */
  16. /*                                                                         */
  17. /*-------------------------------------------------------------------------*/
  18. #include <windows.h>
  19. #include <toolhelp.h>
  20. #include <string.h>
  21. #include <stdio.h>
  22. #include <nwsnapin.h>
  23.  
  24. /*------------------------------------------------------------------------*/
  25. /*  Function Prototypes                                                   */
  26. /*------------------------------------------------------------------------*/
  27.  
  28. #ifdef __cplusplus
  29. extern "C"
  30. {
  31. #endif
  32.  
  33. N_EXTERN_LIBRARY (void)
  34. PlainMenuAction (void);
  35.  
  36. N_EXTERN_LIBRARY (void)
  37. PlainMenuValid (pnuint16 pFlags);
  38.  
  39. N_EXTERN_LIBRARY (void)
  40. ChildMenuAction (void);
  41.  
  42. N_EXTERN_LIBRARY (void)
  43. ChildMenuValid (pnuint16 pFlags);
  44.  
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48.  
  49. HINSTANCE hDLL;
  50.  
  51. /*-------------------------------------------------------------------------*/
  52. /*    DLL Entry Point                                                      */
  53. /*-------------------------------------------------------------------------*/
  54. int FAR PASCAL LibMain (HINSTANCE hInstance, WORD wDataSeg, 
  55.                         WORD cbHeapSize, LPSTR lpCmdLine)
  56. {
  57.    hDLL = hInstance;
  58.    if (cbHeapSize != 0)
  59.       UnlockData (0);
  60.    return 1;
  61. };
  62.  
  63. /*-------------------------------------------------------------------------*/
  64. /* Function : InitSnapin (void)                                            */
  65. /* Description :                                                           */
  66. /*    Every Snapin DLL must provide this function. In this function,       */
  67. /*    snapin menu items (under Tools) are registered. Also, object procs   */
  68. /*    are registered.                                                      */
  69. /*                                                                         */
  70. /*-------------------------------------------------------------------------*/
  71. int _export FAR PASCAL InitSnapin ()
  72. {
  73.    nuint16 menuIDPlain = 0;
  74.    nuint16 menuIDHierarchical = 0;
  75.    nuint16 menuIDChild = 0;
  76.  
  77.    /*----------------------------------------------------------*/
  78.    /* Registering Menu Item                                    */
  79.    /*----------------------------------------------------------*/
  80.    NWARegisterMenu (NWA_VIEW_CONSOLE,                             /*   #   */
  81.                     0,                                            /*  # #  */
  82.                     NULL,                                         /* #   # */
  83.                     MF_STRING,                                    /* ##### */
  84.                     &menuIDPlain,                                 /* #   # */
  85.                     "P&lain Menu",
  86.                     "This is a plain menu", 
  87.                     PlainMenuAction, PlainMenuValid,   
  88.                     NWA_SNAPIN_VERSION);
  89.  
  90.    NWARegisterMenu (NWA_VIEW_CONSOLE,      
  91.                     0,
  92.                     NULL,
  93.                     MF_STRING | MF_POPUP, 
  94.                     &menuIDHierarchical,        
  95.                     "&Hierarchical Menu",       
  96.                     "This is a hierarchical menu",  
  97.                     NULL, NULL, 
  98.                     NWA_SNAPIN_VERSION);   
  99.  
  100.    NWARegisterMenu (NWA_VIEW_CONSOLE,      
  101.                     menuIDHierarchical,
  102.                     "List Objects",
  103.                     MF_STRING, 
  104.                     &menuIDChild,        
  105.                     "Child Menu",       
  106.                     "This is a child of the hierarchical menu",  
  107.                     ChildMenuAction, ChildMenuValid, 
  108.                     NWA_SNAPIN_VERSION);   
  109.  
  110.    return NWA_RET_SUCCESS;
  111. }
  112.  
  113. /*-------------------------------------------------------------------------*/
  114. /* Function : ShutDown (void)                                              */
  115. /* Description :                                                           */
  116. /*-------------------------------------------------------------------------*/
  117. void FAR PASCAL ShutDown (void)
  118. {
  119. }
  120.  
  121.  
  122. /*-------------------------------------------------------------------------*/
  123. /* Function : PlainMenuAction (void)                                       */
  124. /* Description :                                                           */
  125. /*    Menu Action Callback Proc for PlainMenu Menu                         */
  126. /*-------------------------------------------------------------------------*/
  127. N_GLOBAL_LIBRARY (void) _export
  128. PlainMenuAction (void)
  129. {
  130.    // MessageBox (NULL, "Plain Menu selected.", "Menu Action", MB_OK);
  131. //   WinExec("COMMAND /C \"NLISTBAT SERVER PM402A\"", SW_SHOW);
  132. //   WinExec("NLISTBAT.BAT SERVER PM402As", SW_SHOW);
  133.    WinExec("SOL.EXE", SW_SHOW);
  134. }
  135.  
  136. /*-------------------------------------------------------------------------*/
  137. /* Function : PlainMenuValid (void)                                        */
  138. /* Description :                                                           */
  139. /*   Menu Valid Callback Proc for PlainMenu Menu                           */
  140. /*-------------------------------------------------------------------------*/
  141. N_GLOBAL_LIBRARY (void) _export
  142. PlainMenuValid (pnuint16 pFlags)
  143. {
  144.    *pFlags = MF_ENABLED;
  145. }
  146.  
  147. /*-------------------------------------------------------------------------*/
  148. /* Function : ChildMenuValid (void)                                        */
  149. /* Description :                                                           */
  150. /*   Menu Valid Callback Proc for Child Menu                               */
  151. /*-------------------------------------------------------------------------*/
  152. N_GLOBAL_LIBRARY (void) _export                                   /* ####  */
  153. ChildMenuValid (pnuint16 pFlags)                                  /* #   # */
  154. {                                                                 /* ####  */
  155.    *pFlags = MF_ENABLED;                                          /* #   # */
  156. }                                                                 /* ####  */
  157.  
  158. /*-------------------------------------------------------------------------*/
  159. /* Function : ChildMenuAction (void)                                       */
  160. /* Description :                                                           */
  161. /*   Menu Action Callback Proc for Child Menu                              */
  162. /*-------------------------------------------------------------------------*/
  163. N_GLOBAL_LIBRARY (void) _export                                   /*  #### */
  164. ChildMenuAction                                                   /* #     */
  165. (                                                                 /* #     */
  166.   void                                                            /* #     */
  167. )                                                                 /*  #### */
  168. {                                                               
  169.    MessageBox (NULL, "Child of Hierarchical Menu selected.", "Menu Action", 
  170.                MB_OK);
  171. }
  172.  
  173.