Annotation of mstools/win32s/ut/samples/utsample/utsamp16.c, revision 1.1.1.1

1.1       root        1: /*++
                      2: 
                      3: Copyright (c) 1985-93, Microsoft Corporation
                      4: 
                      5: Module Name:
                      6: 
                      7:     utsamp16.c
                      8: 
                      9: Abstract:
                     10: 
                     11:     Win32s sample code of Universal Thunk (UT) -
                     12:     This is the main source file of utsamp16.DLL.
                     13: 
                     14: --*/
                     15: #ifndef APIENTRY
                     16: #define APIENTRY
                     17: #endif
                     18: #define W32SUT_16
                     19: 
                     20: #include <windows.h>
                     21: #include <w32sut.h>
                     22: #include "utsamp.h"
                     23: 
                     24: int FAR PASCAL WEP (int bSystemExit)
                     25:  {
                     26:   return (1);
                     27:  } // WEP()
                     28: 
                     29: int FAR PASCAL LibMain (HANDLE hLibInst, WORD wDataSeg,
                     30:                         WORD cbHeapSize, LPSTR lpszCmdLine)
                     31:  {
                     32:   return (1);
                     33:  } // LibMain()
                     34: 
                     35: DWORD FAR PASCAL
                     36: UTInit( UT16CBPROC lpfnUT16CallBack,
                     37:         LPVOID lpBuf )
                     38:  {
                     39:   return(1); // Return Success
                     40:  } // UTInit()
                     41: 
                     42: 
                     43: /*
                     44:  * Call the appropriate Win16 API based on the dwFunc parameter.  Extract any
                     45:  * necessary parameters from the lpBuf buffer.
                     46:  *
                     47:  * This function must be exported.
                     48:  *
                     49:  */
                     50: 
                     51: DWORD FAR PASCAL
                     52: UTProc( LPVOID lpBuf,
                     53:         DWORD dwFunc)
                     54:  {
                     55: 
                     56:   /*
                     57:    * Call appropriate 16 bit API based on the dwFunc.  Extract any necessary
                     58:    * parameters from lpBuf.
                     59:    *
                     60:    */
                     61: 
                     62:   switch (dwFunc)
                     63:    {
                     64: 
                     65:     case MYGETFREESPACE:
                     66: 
                     67:       return( GetFreeSpace( (UINT) 0 ) );
                     68: 
                     69:     case MYWNETGETUSER:
                     70:      {
                     71:        // Windows for Workgroups supports multiple networks.
                     72:        // to get WNetGetUser to function properly on that
                     73:        // NOS, we must call MNetSetNextTarget passing the
                     74:        // handle returned from MNetGetLastTarget
                     75: 
                     76:       HINSTANCE hWfwNet = 0;
                     77:       FARPROC   pMNetSetNextTarget = NULL;
                     78:       FARPROC  pMNetGetLastTarget = NULL;
                     79:       DWORD    Temp;
                     80: 
                     81:       SetErrorMode(SEM_NOOPENFILEERRORBOX);
                     82: 
                     83:       hWfwNet = LoadLibrary( "WFWNET.DRV" );
                     84: 
                     85:       SetErrorMode( 0 );
                     86: 
                     87:       if (hWfwNet > HINSTANCE_ERROR)
                     88:        {
                     89:         pMNetGetLastTarget = GetProcAddress( hWfwNet, "MNetGetLastTarget" );
                     90:         pMNetSetNextTarget = GetProcAddress( hWfwNet, "MNetSetNextTarget" );
                     91: 
                     92:         if ( pMNetGetLastTarget && pMNetSetNextTarget )
                     93:           (*pMNetSetNextTarget) ( (HANDLE)(*pMNetGetLastTarget) () );
                     94: 
                     95:        } // if (hWfwNet > HINSTANCE_ERROR)
                     96:       else
                     97:        hWfwNet = 0;
                     98: 
                     99:       Temp = WNetGetUser( (LPSTR)  ((LPDWORD)lpBuf) [0],
                    100:                          (LPWORD) ((LPDWORD)lpBuf) [1] );
                    101: 
                    102:       if (hWfwNet)
                    103:         FreeLibrary( hWfwNet );
                    104: 
                    105:       return( Temp );
                    106: 
                    107:     } // case MYWNETGETUSER:
                    108: 
                    109:    } // switch (dwFunc)
                    110: 
                    111:   return( (DWORD)-1L ); // We should never get here.
                    112: 
                    113:  } // UTProc()

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.