- int WINAPI  
- WinMain( HINSTANCE hInstance,  
-          HINSTANCE hPrevInstance,  
-          LPSTR lpCmdLine,  
-          int nCmdShow ) 
- /*++ 
- This is our apps entry point.  It calls the open layers functions 
- to execute the required operation. 
- --*/ 
- { 
-    DBL  freq; 
-    UINT size,dma,gainsup,samplesize; 
-    int i; 
-   
-    UINT channel = 0; 
-    UINT numberADs = 0; 
-    UINT currentAD = 0; 
-    DBL gain = 1.0; 
-    HBUF  hBuffer = NULL; 
-    ECODE ec=OLNOERROR; 
-   
-   
-    board.hdrvr = NULL; 
-   
-     // Get cmdline board 
-     if (lpCmdLine[0]!=0) 
-     { 
-      CHECKERROR( olDaInitialize(lpCmdLine,&board.hdrvr) ); 
-     } 
-     else 
-     { 
-    /* Get first available Open Layers board */ 
-    CHECKERROR (olDaEnumBoards(GetDriver,(LPARAM)(LPBOARD)&board)); 
-     } 
-    /* check for error within callback function */ 
-   
-    CHECKERROR (board.status); 
-   
-    /* check for NULL driver handle - means no boards */ 
-   
-    if (board.hdrvr == NULL){ 
-       MessageBox(HWND_DESKTOP, " No Open Layer boards!!!", "Error", 
-             MB_ICONEXCLAMATION | MB_OK); 
-       return ((UINT)NULL); 
-    } 
-   
-    /* get handle to first available ADC sub system */ 
-    CHECKERROR(olDaGetDevCaps(board.hdrvr,OLDC_ADELEMENTS,&numberADs)); 
-   
-     while(1)    // Enumerate through all the A/D subsystems and try and select the first available one... 
-    { 
-         ec=olDaGetDASS(board.hdrvr,OLSS_AD,currentAD,&board.hdass); 
-         if (ec!=OLNOERROR) 
-         { 
-         // busy subsys etc... 
-         currentAD++; 
-         if (currentAD>numberADs) 
-         { 
-             MessageBox(HWND_DESKTOP,"No Available A/D Subsystems!","Error",MB_ICONEXCLAMATION|MB_OK); 
-               return ((UINT)NULL); 
-         } 
-   
-         } 
-         else 
-         break; 
-   
-    } 
-   
-    /* 
-       Set up the ADC - multiple wrap so we can get buffer reused 
-       window messages. 
-    */ 
-   
-    CHECKERROR (olDaGetSSCapsEx(board.hdass,OLSSCE_MAXTHROUGHPUT,&freq)); 
-    CHECKERROR (olDaGetSSCaps(board.hdass,OLSSC_NUMDMACHANS,&dma)); 
-    CHECKERROR (olDaGetSSCaps(board.hdass,OLSSC_SUP_PROGRAMGAIN,&gainsup)); 
-     
-    dma  = min (1, dma);            /* try for one dma channel   */  
-    freq = min (1000.0, freq);      /* try for 1000hz throughput */ 
-   
-    CHECKERROR (olDaSetDataFlow(board.hdass,OL_DF_CONTINUOUS)); 
-    CHECKERROR (olDaSetWrapMode(board.hdass,OL_WRP_MULTIPLE)); 
-    CHECKERROR (olDaSetClockFrequency(board.hdass,freq)); 
-    CHECKERROR (olDaSetDmaUsage(board.hdass,dma)); 
-    CHECKERROR (olDaSetChannelListEntry(board.hdass,0,channel)); 
-   
-    /* only set the gain if the board supports it!!! */ 
-   
-    if (gainsup) 
-       CHECKERROR (olDaSetGainListEntry(board.hdass,0,gain)); 
-   
-    CHECKERROR (olDaSetChannelListSize(board.hdass,1)); 
-    CHECKERROR (olDaConfig(board.hdass)); 
-   
-    size = (UINT)freq/1;     /* 1 second buffer */ 
-     
-    /* allocate the input buffers */ 
-    /* Put the buffer to the ADC  */ 
-      
-     CHECKERROR(olDaGetResolution(board.hdass,&samplesize)); 
-     if (samplesize > 16) 
-         samplesize=4; //4 bytes...// e.g. 24 bits = 4 btyes 
-     else 
-         samplesize=2;             // e.g. 16 or 12 bits = 2 bytes 
-   
-    for (i=0;i<NUM_BUFFERS;i++) 
-    { 
-       CHECKERROR (olDmCallocBuffer(0,0,(ULNG) size,samplesize,&hBuffer)); 
-       CHECKERROR (olDaPutBuffer(board.hdass, hBuffer)); 
-    } 
-   
-    /* 
-       use a dialog box to collect information and error 
-       messages from the subsystem 
-    */ 
-   
-    DialogBox(hInstance, (LPCSTR)INPUTBOX, HWND_DESKTOP, InputBox); 
-   
-    /* 
-       get the input buffers from the ADC subsystem and 
-       free the input buffers 
-    */ 
-   
-    CHECKERROR (olDaFlushBuffers(board.hdass)); 
-     
-    for (i=0;i<NUM_BUFFERS;i++) 
-    { 
-       CHECKERROR (olDaGetBuffer(board.hdass, &hBuffer)); 
-       CHECKERROR (olDmFreeBuffer(hBuffer)); 
-    } 
-     
-    /* release the subsystem and the board */ 
-   
-    CHECKERROR (olDaReleaseDASS(board.hdass)); 
-    CHECKERROR (olDaTerminate(board.hdrvr)); 
-   
-    /* all done - return */ 
-   
-    return ((UINT)NULL); 
- }