home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / myshel.exe / MYSHELL.C < prev    next >
C/C++ Source or Header  |  1995-06-08  |  4KB  |  120 lines

  1. /*
  2.          This program is provided as is and carries no warranty
  3.   whatsoever.  Novell disclaims and excludes any and all implied
  4.   warranties of merchantability, title and fitness for a particular
  5.   purpose.  Novell does not warrant that the software will satisfy
  6.   your requirements or that the software is without defect or error
  7.   or that operation of the software will be uninterrupted.  You are
  8.   using the software at your risk.  The software is not a product
  9.   of Novell, Inc. or any of subsidiaries.
  10. */
  11.  
  12. #define NWWIN 1
  13.  
  14. #include <windows.h>
  15. #include <stdio.h>
  16. #include <nwcalls.h>
  17.  
  18. NWCCODE NWAPI (*MyNWCallsInit)(void NWPTR in, void NWPTR out);
  19. NWCCODE NWAPI (*MyNWGetDefaultConnectionID)(NWCONN_HANDLE *);
  20. NWCCODE NWAPI (*MyNWGetFileServerDateAndTime)(NWCONN_HANDLE, BYTE *);
  21.  
  22. long FAR PASCAL WndProc (HWND hwnd, WORD message, WORD wParam, LONG lParam)
  23. {
  24.     static HANDLE    hInstance;
  25.     NWCCODE        ccode;
  26.     NWCONN_HANDLE  conn;
  27.     BYTE           dateTimeBuf[7];
  28.     char           string[256];
  29.  
  30.     switch (message)
  31.     {
  32.         case WM_CREATE:
  33.             ccode = MyNWCallsInit(NULL, NULL);
  34.             sprintf(string, "NWCallsInit returned:  %x",ccode);
  35.             MessageBox(hwnd, (LPSTR)string, (LPSTR)"", MB_ICONINFORMATION);
  36.  
  37.             ccode = MyNWGetDefaultConnectionID(&conn);
  38.             sprintf(string, "NWGetDefaultConnectionID returned:  %x",ccode);
  39.             MessageBox(hwnd, (LPSTR)string, (LPSTR)"", MB_ICONINFORMATION);
  40.  
  41.             ccode = MyNWGetFileServerDateAndTime(conn, dateTimeBuf);
  42.             sprintf(string, "NWGetFileServerDateAndTime returned:  %x",ccode);
  43.             MessageBox(hwnd, (LPSTR)string, (LPSTR)"", MB_ICONINFORMATION);
  44.             return 0;
  45.  
  46.         case WM_DESTROY:
  47.             PostQuitMessage(0);
  48.             return 0;
  49.     }
  50.     return DefWindowProc(hwnd, message, wParam, lParam);
  51. }
  52.  
  53.  
  54. int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance,
  55.                           LPSTR lpszCmdLine, int nCmdShow)
  56. {
  57.     static char    szAppName[] = "MyShell";
  58.     HWND      hwnd;
  59.     MSG       msg;
  60.     WNDCLASS  wndclass;
  61.     HINSTANCE hinstNetware, hinstNWCalls;
  62.  
  63.     if (hPrevInstance)
  64.         return 1;
  65.  
  66.     hinstNetware = LoadLibrary("Netware.drv");
  67.     if (hinstNetware < HINSTANCE_ERROR)
  68.         return 0; /* ERRROR Handle */
  69.  
  70.     hinstNWCalls = LoadLibrary("NWCalls.dll");
  71.     if (hinstNetware < HINSTANCE_ERROR)
  72.         return 0; /* ERRROR Handle */
  73.  
  74.     (FARPROC)MyNWCallsInit = GetProcAddress(hinstNWCalls, "NWCallsInit");
  75.     if (MyNWCallsInit == NULL)
  76.         return 0; /* ERRROR Handle */
  77.  
  78.     (FARPROC)MyNWGetDefaultConnectionID = GetProcAddress(hinstNWCalls,
  79.                                                                           "NWGetDefaultConnectionID");
  80.     if (MyNWGetDefaultConnectionID == NULL)
  81.         return 0; /* ERRROR Handle */
  82.  
  83.     (FARPROC)MyNWGetFileServerDateAndTime = GetProcAddress(hinstNWCalls,
  84.                                                                              "NWGetFileServerDateAndTime");
  85.     if (MyNWGetFileServerDateAndTime == NULL)
  86.         return 0; /* ERRROR Handle */
  87.  
  88.     wndclass.style        = CS_HREDRAW | CS_VREDRAW;
  89.     wndclass.lpfnWndProc    = (WNDPROC)WndProc;
  90.     wndclass.cbClsExtra    = 0;
  91.     wndclass.cbWndExtra    = 0;
  92.     wndclass.hInstance    = hInstance;
  93.     wndclass.hIcon        = NULL;
  94.     wndclass.hCursor    = LoadCursor (NULL, IDC_ARROW);
  95.     wndclass.hbrBackground    = GetStockObject(GRAY_BRUSH);
  96.     wndclass.lpszMenuName    = NULL;
  97.     wndclass.lpszClassName    = szAppName;
  98.  
  99.     RegisterClass (&wndclass);
  100.  
  101.     hwnd = CreateWindow(szAppName, "Test Dynamic Loading of NetWare DLLs",
  102.                               WS_OVERLAPPEDWINDOW, 0, 0,
  103.                               CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL,
  104.                               hInstance, NULL);
  105.  
  106.     ShowWindow (hwnd, nCmdShow);
  107.     UpdateWindow (hwnd);
  108.  
  109.     while ( GetMessage(&msg, NULL, 0, 0) )
  110.     {
  111.         TranslateMessage(&msg);
  112.         DispatchMessage(&msg);
  113.     }
  114.  
  115.     FreeLibrary (hinstNetware);
  116.     FreeLibrary (hinstNWCalls);
  117.  
  118.     return msg.wParam;
  119. }
  120.