home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / WIN_UTL2 / SAMDU260.ZIP / SAMPLE.C < prev    next >
Text File  |  1994-04-01  |  25KB  |  588 lines

  1. #include <Windows.h>
  2.  
  3. #include <IO.h>
  4. #include <StdIO.h>
  5. #include <StdLib.h>
  6. #include <String.h>
  7.  
  8. #include "DDrive.h"
  9. #include "DiskDriv.h"
  10. #include "HandleSt.h"
  11. #include "IOStatus.h"
  12. #include "Sample.h"
  13.  
  14. #ifdef DEBUG
  15. #include "DebugOut.h"
  16. #endif
  17.  
  18. BOOL bCancel ;
  19. BOOL bFast ;
  20. BOOL bIdle ;
  21. BOOL bQuick ;
  22. BOOL bRegisteredClass ;
  23.  
  24. char czIconMessage[64] ;
  25. char czNormalMessage[512] ;
  26.  
  27. FARPROC lpfnHandleStatus ;
  28.  
  29. HINSTANCE hInstance ;
  30.  
  31. HWND hWnd ;
  32.  
  33. UINT nNumberOfDrives ;
  34. UINT nFormatOption ;
  35. UINT nPercentageToColor ;
  36.  
  37. VOID far * pCDebugOut ;
  38.  
  39. VOID far * pCVDriveTest ;
  40.  
  41. VOID far *pCVDrives[26] ;
  42.  
  43. VOID far * pCDiskImage ;
  44.  
  45. VOID far * pCDiskTemporary ;
  46.  
  47. #pragma warning(disable:4100)
  48. int PASCAL WinMain ( HINSTANCE hCurrentInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, UINT nCmdShow)
  49. {
  50.     MSG msg;
  51.  
  52.     UINT n ;
  53.  
  54. #ifdef DEBUG
  55.     pCDebugOut = DebugOutCreate ( lpCmdLine ) ;
  56. #endif
  57.  
  58.     bRegisteredClass = FALSE ;
  59.     if (!hPrevInstance)
  60.        {
  61.        if (!InitApplication(hCurrentInstance)) return (FALSE);
  62.        bRegisteredClass = TRUE ;
  63.        }
  64.  
  65.     if (!InitInstance(hCurrentInstance, nCmdShow)) return (FALSE);
  66.  
  67.     hInstance = hCurrentInstance ;
  68.  
  69.     while (GetMessage(&msg, NULL, NULL, NULL))
  70.        {
  71.        TranslateMessage(&msg);
  72.        DispatchMessage(&msg);
  73.        }
  74.  
  75.     if ( nNumberOfDrives )
  76.        {
  77.        for ( n=0; n<nNumberOfDrives; n++ ) DDriveDelete ( pCVDrives[n] ) ;
  78.        }
  79.  
  80.     if ( bRegisteredClass ) UnregisterClass ( "SampleWClass", hInstance ) ;
  81.  
  82.     return ( msg.wParam ) ;
  83. }                            
  84. #pragma warning(default:4100)
  85.  
  86. BOOL InitApplication ( HINSTANCE hInstance )
  87. {
  88.     WNDCLASS  wc;
  89.  
  90.     wc.style = NULL;
  91.     wc.lpfnWndProc = MainWndProc;
  92.     wc.cbClsExtra = 0;
  93.     wc.cbWndExtra = 0;
  94.     wc.hInstance = hInstance;
  95.     wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  96.     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  97.     wc.hbrBackground = GetStockObject(WHITE_BRUSH); 
  98.     wc.lpszMenuName =  "SampleMenu";
  99.     wc.lpszClassName = "SampleWClass";
  100.     return (RegisterClass(&wc));
  101. }
  102.  
  103. BOOL InitInstance ( HINSTANCE hInstance, UINT nCmdShow )
  104. {
  105.  
  106.     char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
  107.     char czBuffer[256] ;
  108.  
  109.     HMENU hMainMenu ;
  110.     HMENU hPopupMenu ;
  111.  
  112.     int i ;
  113.  
  114.     UINT nMenuID ;
  115.     UINT nPopupMenuID ;
  116.  
  117.     VOID far * pCVDriveTest ;
  118.  
  119.     hWnd = CreateWindow( "SampleWClass", "Sample SABDU001.DLL Application", WS_OVERLAPPEDWINDOW,
  120.                          100, 200, 400, 200,
  121.                          NULL, NULL, hInstance, NULL );
  122.     if (!hWnd) return (FALSE);
  123.  
  124. #ifdef DEBUG
  125.     /* The following will be executed if the program is invoked with /D1 on the command line   */
  126.     /* It will be written to a trace file unless /M1 is also on the command line in which case */
  127.     /* it will be displayed in a MessageBox on the screen                                      */
  128.     wsprintf ( DebugOutczDebugBuffer(), "This is a sample of a debug trace.\n hWnd = %4.4X", hWnd ) ;
  129.     DebugOutOutputIf ( 0x00000001L, DebugOutczDebugBuffer(), "Sample Trace", MB_OK ) ;
  130. #endif
  131.  
  132.     nMenuID = 0 ;
  133.     nNumberOfDrives = 0 ;
  134.     hMainMenu = GetMenu ( hWnd ) ;
  135.     for ( i = 0; i < sizeof(alphabet)/sizeof(alphabet[0])-1 ; i++ )
  136.        {
  137.        pCVDriveTest = (VOID far *) DDriveCreate ( alphabet[i], (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  138.        if (pCVDriveTest==NULL)
  139.           {
  140.           ; /* Memory problems or worse */
  141.           return ( FALSE ) ;
  142.           break ;
  143.           }
  144.        if ((VDriveIsUseable ( pCVDriveTest ))&&(!VDriveIsRemote ( pCVDriveTest ))&&(VDriveIsRemovable ( pCVDriveTest )))
  145.           {
  146.           pCVDrives[nNumberOfDrives] = pCVDriveTest ;
  147.           nNumberOfDrives++ ;
  148.           nMenuID += 100 ;
  149.           hPopupMenu = CreatePopupMenu () ;
  150.           nPopupMenuID = nMenuID ;
  151.           AppendMenu ( hPopupMenu, MF_ENABLED|MF_STRING, ++nPopupMenuID, "&Compare" ) ;
  152.           nPopupMenuID++ ;
  153.           if ( FD0360 & VDriveType  ( pCVDriveTest ) ) AppendMenu ( hPopupMenu, MF_ENABLED|MF_STRING, nPopupMenuID, "Format 0&360KB" ) ;
  154.           nPopupMenuID++ ;
  155.           if ( FD0720 & VDriveType  ( pCVDriveTest ) ) AppendMenu ( hPopupMenu, MF_ENABLED|MF_STRING, nPopupMenuID, "Format 0&720KB" ) ;
  156.           nPopupMenuID++ ;
  157.           if ( FD1200H & VDriveType ( pCVDriveTest ) ) AppendMenu ( hPopupMenu, MF_ENABLED|MF_STRING, nPopupMenuID, "Format 1&200KB" ) ;
  158.           nPopupMenuID++ ;
  159.           if ( FD1440H & VDriveType ( pCVDriveTest ) ) AppendMenu ( hPopupMenu, MF_ENABLED|MF_STRING, nPopupMenuID, "Format 1&440KB" ) ;
  160.           nPopupMenuID++ ;
  161.           if ( FD2880H & VDriveType ( pCVDriveTest ) ) AppendMenu ( hPopupMenu, MF_ENABLED|MF_STRING, nPopupMenuID, "Format 2&880KB" ) ;
  162.           AppendMenu ( hPopupMenu, MF_ENABLED|MF_STRING, ++nPopupMenuID, "&Read" ) ;
  163.           AppendMenu ( hPopupMenu, MF_ENABLED|MF_STRING, ++nPopupMenuID, "&Write" ) ;
  164.           czBuffer[0] = '&' ;
  165.           czBuffer[1] = VDriveLetter ( pCVDriveTest ) ;
  166.           czBuffer[2] = ':' ;
  167.           czBuffer[3] = '\0' ;
  168.           AppendMenu ( hMainMenu, MF_ENABLED|MF_STRING|MF_POPUP, hPopupMenu, czBuffer ) ;
  169.           }
  170.        else
  171.           {
  172.           DDriveDelete ( pCVDriveTest ) ;
  173.           }
  174.        }
  175.  
  176.     if ( !nNumberOfDrives ) return ( FALSE ) ;
  177.  
  178.     bCancel = FALSE ;
  179.     bFast   = FALSE ;
  180.     bIdle   = TRUE ;
  181.     bQuick  = FALSE ;
  182.  
  183.     pCDiskImage = NULL ;
  184.  
  185.     lpfnHandleStatus = MakeProcInstance ( (FARPROC)HandleStatus, hInstance ) ;
  186.  
  187.     (*(lpfnHANDLESTATUS)lpfnHandleStatus) ( STATUS1_INIT, 0, (UINT)hWnd, (UINT)hInstance, MAKELONG ( TIMER_INTERVAL, 0x0000 ), MAKELONG ( 0x0001, 0x0001 ) ) ;
  188.  
  189.     ShowWindow( hWnd, nCmdShow ) ;
  190.     UpdateWindow( hWnd ) ;
  191.     return ( TRUE ) ;
  192.  
  193. }
  194.  
  195. long FAR PASCAL MainWndProc ( HWND hWnd, UINT nMessage, UINT nParam, LONG lParam )
  196. {
  197.     char  czMessageBuffer[512] ;
  198.  
  199.     HDC     hdc ;
  200.  
  201.     PAINTSTRUCT ps ;
  202.  
  203.     RECT    rClient ;
  204.  
  205.     STMESSAGE far *lpstMessage ;
  206.  
  207.     UINT nAction ;
  208.     UINT nDrive ;
  209.  
  210.     char czApplicationTitle [] = "SAB Diskette Utility" ;
  211.     char czFileName [] = "SABDU.SDU" ;
  212.     char czVersionNumber [] = "2.00" ;
  213.     char czFullPath [_MAX_PATH] ;
  214.  
  215.     switch ( nMessage )
  216.        {
  217.        case WM_PAINT:
  218.           {
  219.           hdc = BeginPaint ( hWnd, &ps ) ;
  220.  
  221.           if (!IsIconic( hWnd ))
  222.              {
  223.              GetClientRect ( hWnd, &rClient ) ;
  224.              if (bIdle)
  225.                 {
  226.                 _fstrcpy ( czMessageBuffer, "Please select an item from the menu" ) ;
  227.                 }
  228.              else
  229.                 {
  230.                 _fstrcpy ( czMessageBuffer, czNormalMessage ) ;
  231.                 }
  232.              DrawText ( hdc, czMessageBuffer, -1, &rClient, DT_CENTER|DT_WORDBREAK ) ;
  233.              }
  234.  
  235.           EndPaint ( hWnd, &ps ) ;
  236.           return ( FALSE ) ;
  237.           break ;
  238.           }
  239.        case USR_ACTIVE:
  240.           {
  241.           bIdle = FALSE ;
  242.  
  243.           lpstMessage = (STMESSAGE far *)lParam ;
  244.  
  245.           if (lpstMessage->pIconMessage)   _fstrcpy ( czIconMessage, lpstMessage->pIconMessage   )  ;
  246.           if (lpstMessage->pNormalMessage) _fstrcpy ( czNormalMessage, lpstMessage->pNormalMessage ) ;
  247.           nPercentageToColor = lpstMessage->nPercentageToColor ;
  248.  
  249.           InvalidateRect ( hWnd, NULL, TRUE ) ;
  250.           UpdateWindow ( hWnd ) ;
  251.  
  252.           return ( !bCancel ) ;
  253.           break ;
  254.           }
  255.        case USR_UPDATE:
  256.           {
  257.           bIdle = FALSE ;
  258.  
  259.           lpstMessage = (STMESSAGE far *)lParam ;
  260.  
  261.           if (lpstMessage->pIconMessage)   _fstrcpy ( czIconMessage, lpstMessage->pIconMessage   )  ;
  262.           if (lpstMessage->pNormalMessage) _fstrcpy ( czNormalMessage, lpstMessage->pNormalMessage ) ;
  263.           nPercentageToColor = lpstMessage->nPercentageToColor ;
  264.  
  265.           InvalidateRect ( hWnd, NULL, FALSE ) ;
  266.           UpdateWindow ( hWnd ) ;
  267.  
  268.           return ( !bCancel ) ;
  269.           break ;
  270.           }
  271.        case USR_INACTIVE:
  272.           {
  273.           bIdle = TRUE ;
  274.           InvalidateRect ( hWnd, NULL, TRUE ) ;
  275.           UpdateWindow ( hWnd ) ;
  276.           return ( !bCancel ) ;
  277.           break ;
  278.           }
  279.        case WM_COMMAND:
  280.           {
  281.  
  282.           if ( nParam==IDCANCEL )
  283.              {
  284.              /*******************************************************/
  285.              /*                                                     */
  286.              /* The user wants to canceL the current activity       */
  287.              /*                                                     */
  288.              /*******************************************************/
  289.              bCancel = TRUE ;
  290.              return ( TRUE ) ;
  291.              }
  292.  
  293.           if (!bIdle)
  294.              {
  295.              /*******************************************************/
  296.              /*                                                     */
  297.              /* The system does not support concurrent activities so*/
  298.              /* ignore requests since we are not idle.              */
  299.              /*                                                     */
  300.              /*******************************************************/
  301.              return ( TRUE ) ;
  302.              }
  303.  
  304.           if ( nParam==IDM_OPEN )
  305.              {
  306.              /*******************************************************/
  307.              /*                                                     */
  308.              /* The user wants to open and read in a diskette image */
  309.              /* file.                                               */
  310.              /* Note: The sample uses the variable czFileName which */
  311.              /* is initialized to "SABDU.SDU".  A file selection    */
  312.              /* dialog would be usefull here.                       */
  313.              /*                                                     */
  314.              /*******************************************************/
  315.              SetWindowText ( hWnd, "Openning" ) ;
  316.              if (_access ( czFileName, 4 ) )
  317.                 {
  318.                 wsprintf ( (LPSTR)czMessageBuffer, (LPCSTR)"Unable to access file: %s", (LPCSTR)_fullpath ( czFullPath, czFileName, _MAX_PATH ) ) ;
  319.                 MessageBox ( hWnd, czMessageBuffer, "Sample", MB_ICONEXCLAMATION|MB_OK ) ;
  320.                 return ( TRUE ) ;
  321.                 }
  322.              bCancel = FALSE ;
  323.              pCDiskTemporary = (VOID far *) DiskDriveCreateFile ( czFileName, czApplicationTitle, czVersionNumber, FD0000, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  324.              if (!DiskDriveHasData(pCDiskTemporary)) return ( TRUE ) ;
  325.              if ( pCDiskImage != NULL )
  326.                 {
  327.                 DiskDriveDelete ( pCDiskImage ) ;
  328.                 pCDiskImage = NULL ;
  329.                 }
  330.              pCDiskImage = DiskDriveCreateMemory ( (UINT)0, DiskDriveType ( pCDiskTemporary ), 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  331.              DiskDriveCopy ( pCDiskImage, pCDiskTemporary ) ;
  332.              DiskDriveDelete ( pCDiskTemporary ) ;
  333.              if ( bCancel )
  334.                 {
  335.                 DiskDriveDelete ( pCDiskImage ) ;
  336.                 pCDiskImage = NULL ;
  337.                 }
  338.              bIdle = TRUE ;
  339.              SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  340.              return ( TRUE ) ;
  341.              }
  342.           if ( nParam==IDM_SAVE )
  343.              {
  344.              /*******************************************************/
  345.              /*                                                     */
  346.              /* The user wants to open and write out a diskette     */
  347.              /* image file.                                         */
  348.              /* Note: The sample uses the variable czFileName which */
  349.              /* is initialized to "SABDU.SDU".  A file selection    */
  350.              /* dialog would be usefull here.                       */
  351.              /*                                                     */
  352.              /*******************************************************/
  353.              if ( pCDiskImage==NULL )
  354.                 {
  355.                 MessageBox ( hWnd, "You must first READ in a diskette image before saving", "Sample", MB_ICONEXCLAMATION|MB_OK ) ;
  356.                 return ( TRUE ) ;
  357.                 }
  358.              SetWindowText ( hWnd, "Saving" ) ;
  359.              bCancel = FALSE ;
  360.              pCDiskTemporary = (VOID far *) DiskDriveCreateFile ( czFileName, czApplicationTitle, czVersionNumber, DiskDriveType ( pCDiskImage ), DiskDriveUsedCylinders ( pCDiskImage ), (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  361.              if (!DiskDriveType(pCDiskTemporary)) return ( TRUE ) ;
  362.              DiskDriveCopy ( pCDiskTemporary, pCDiskImage ) ;
  363.              DiskDriveDelete ( pCDiskTemporary ) ;
  364.              if (bCancel) remove ( czFileName ) ;
  365.              bIdle = TRUE ;
  366.              SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  367.              return ( TRUE ) ;
  368.              }
  369.  
  370.           if ( nParam==IDM_EXIT )
  371.              {
  372.              /*******************************************************/
  373.              /*                                                     */
  374.              /* The user wants to exit.                             */
  375.              /*                                                     */
  376.              /*******************************************************/
  377.              DestroyWindow ( hWnd ) ;
  378.              return ( TRUE ) ;
  379.              }
  380.  
  381.           if ( nParam==IDM_FAST )
  382.              {
  383.              /*******************************************************/
  384.              /*                                                     */
  385.              /* The user wants to change the Fast Format option.    */
  386.              /* (The system will not check the diskette before      */
  387.              /*  beginning a format.)                               */
  388.              /*                                                     */
  389.              /*******************************************************/
  390.              bFast = !bFast ;
  391.              if ( bFast ) CheckMenuItem ( GetMenu ( hWnd ), IDM_FAST, MF_BYCOMMAND | MF_CHECKED   ) ;
  392.              else         CheckMenuItem ( GetMenu ( hWnd ), IDM_FAST, MF_BYCOMMAND | MF_UNCHECKED ) ;
  393.              return ( TRUE ) ;
  394.              }
  395.  
  396.           if ( nParam==IDM_QUICK )
  397.              {
  398.              /*******************************************************/
  399.              /*                                                     */
  400.              /* The user wants to change the Quick Format option.   */
  401.              /* (The system will not check the diskette for bad     */
  402.              /*  sectors.  It will write the boot sector, FAT(s)    */
  403.              /*  and root directory.)                               */
  404.              /*                                                     */
  405.              /*******************************************************/
  406.              bQuick = !bQuick ;
  407.              if ( bQuick ) CheckMenuItem ( GetMenu ( hWnd ), IDM_QUICK, MF_BYCOMMAND | MF_CHECKED   ) ;
  408.              else          CheckMenuItem ( GetMenu ( hWnd ), IDM_QUICK, MF_BYCOMMAND | MF_UNCHECKED ) ;
  409.              return ( TRUE ) ;
  410.              }
  411.  
  412.           if ( (nParam>=(UINT)100)&&(nParam<=(UINT)100*(nNumberOfDrives+1) ) )
  413.              {
  414.              /*******************************************************/
  415.              /*                                                     */
  416.              /* The use has selected a diskette drive function.     */
  417.              /* The first digit of the three digit nParam identifies*/
  418.              /* the device.  The next two identify the function.    */
  419.              /*                                                     */
  420.              /*******************************************************/
  421.              nDrive = ( nParam / 100 ) - 1 ;
  422.              nAction = nParam % 100 ;
  423.              bCancel = FALSE ;
  424.              switch ( nAction )
  425.                 {
  426.                 case 1: /* Compare */
  427.                    {
  428.                    if ( pCDiskImage==NULL )
  429.                       {
  430.                       MessageBox ( hWnd, "You must first READ in a diskette image before comparing.", "Sample", MB_ICONEXCLAMATION|MB_OK ) ;
  431.                       return ( TRUE ) ;
  432.                       }
  433.                    SetWindowText ( hWnd, "Comparing" ) ;
  434.                    pCDiskTemporary = DiskDriveCreateVDrive ( pCVDrives[nDrive], 0, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  435.                    if (!DiskDriveHasData(pCDiskTemporary)) return ( TRUE ) ;
  436.                    DiskDriveCompare ( pCDiskImage, pCDiskTemporary ) ;
  437.                    DiskDriveReset ( pCDiskTemporary ) ;
  438.                    DiskDriveDelete ( pCDiskTemporary ) ;
  439.                    bIdle = TRUE ;
  440.                    SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  441.                    return ( TRUE ) ;
  442.                    break ;
  443.                    }
  444.                 case 2: /* Format  360KB */
  445.                    {
  446.                    nFormatOption = NULL ;
  447.                    if ( bFast  ) nFormatOption |= FORMATFAST  ;
  448.                    if ( bQuick ) nFormatOption |= FORMATQUICK ;
  449.                    SetWindowText ( hWnd, "Formating 0360KB" ) ;
  450.                    pCDiskTemporary = DiskDriveCreateVDrive ( pCVDrives[nDrive], FD0360, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  451.                    DiskDriveSetWrite ( pCDiskTemporary, FD0360, 0 ) ;
  452.                    DiskDriveSetType ( pCDiskTemporary, FD0360 ) ;
  453.                    DiskDriveFormat ( pCDiskTemporary, "Sample 0360", NULL, NULL, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  454.                    DiskDriveReset ( pCDiskTemporary ) ;
  455.                    DiskDriveDelete ( pCDiskTemporary ) ;
  456.                    bIdle = TRUE ;
  457.                    SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  458.                    return ( TRUE ) ;
  459.                    break ;
  460.                    }
  461.                 case 3: /* Format  720KB */
  462.                    {
  463.                    nFormatOption = NULL ;
  464.                    if ( bFast  ) nFormatOption |= FORMATFAST  ;
  465.                    if ( bQuick ) nFormatOption |= FORMATQUICK ;
  466.                    SetWindowText ( hWnd, "Formating 0720KB" ) ;
  467.                    pCDiskTemporary = DiskDriveCreateVDrive ( pCVDrives[nDrive], FD0720, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  468.                    DiskDriveSetWrite ( pCDiskTemporary, FD0720, 0 ) ;
  469.                    DiskDriveSetType ( pCDiskTemporary, FD0720 ) ;
  470.                    DiskDriveFormat ( pCDiskTemporary, "Sample 0720", nFormatOption, NULL, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  471.                    DiskDriveReset ( pCDiskTemporary ) ;
  472.                    DiskDriveDelete ( pCDiskTemporary ) ;
  473.                    bIdle = TRUE ;
  474.                    SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  475.                    return ( TRUE ) ;
  476.                    break ;
  477.                    }
  478.                 case 4: /* Format 1200KB */
  479.                    {
  480.                    nFormatOption = NULL ;
  481.                    if ( bFast  ) nFormatOption |= FORMATFAST  ;
  482.                    if ( bQuick ) nFormatOption |= FORMATQUICK ;
  483.                    SetWindowText ( hWnd, "Formating 1200KB" ) ;
  484.                    pCDiskTemporary = DiskDriveCreateVDrive ( pCVDrives[nDrive], FD1200, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  485.                    DiskDriveSetWrite ( pCDiskTemporary, FD1200, 0 ) ;
  486.                    DiskDriveSetType ( pCDiskTemporary, FD1200 ) ;
  487.                    DiskDriveFormat ( pCDiskTemporary, "Sample 1200", nFormatOption, NULL, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  488.                    DiskDriveReset ( pCDiskTemporary ) ;
  489.                    DiskDriveDelete ( pCDiskTemporary ) ;
  490.                    bIdle = TRUE ;
  491.                    SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  492.                    return ( TRUE ) ;
  493.                    break ;
  494.                    }
  495.                 case 5: /* Format 1440KB */
  496.                    {
  497.                    nFormatOption = NULL ;
  498.                    if ( bFast  ) nFormatOption |= FORMATFAST  ;
  499.                    if ( bQuick ) nFormatOption |= FORMATQUICK ;
  500.                    SetWindowText ( hWnd, "Formating 1440KB" ) ;
  501.                    pCDiskTemporary = DiskDriveCreateVDrive ( pCVDrives[nDrive], FD1440, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  502.                    DiskDriveSetWrite ( pCDiskTemporary, FD1440, 0 ) ;
  503.                    DiskDriveSetType ( pCDiskTemporary, FD1440 ) ;
  504.                    DiskDriveFormat ( pCDiskTemporary, "Sample 1440", nFormatOption, NULL, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  505.                    DiskDriveReset ( pCDiskTemporary ) ;
  506.                    DiskDriveDelete ( pCDiskTemporary ) ;
  507.                    bIdle = TRUE ;
  508.                    SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  509.                    return ( TRUE ) ;
  510.                    break ;
  511.                    }
  512.                 case 6: /* Format 2880KB */
  513.                    {
  514.                    nFormatOption = NULL ;
  515.                    if ( bFast  ) nFormatOption |= FORMATFAST  ;
  516.                    if ( bQuick ) nFormatOption |= FORMATQUICK ;
  517.                    SetWindowText ( hWnd, "Formating 2880KB" ) ;
  518.                    pCDiskTemporary = DiskDriveCreateVDrive ( pCVDrives[nDrive], FD2880, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  519.                    DiskDriveSetWrite ( pCDiskTemporary, FD2880, 0 ) ;
  520.                    DiskDriveSetType ( pCDiskTemporary, FD2880 ) ;
  521.                    DiskDriveFormat ( pCDiskTemporary, "Sample 2880", nFormatOption, NULL, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  522.                    DiskDriveReset ( pCDiskTemporary ) ;
  523.                    DiskDriveDelete ( pCDiskTemporary ) ;
  524.                    bIdle = TRUE ;
  525.                    SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  526.                    return ( TRUE ) ;
  527.                    break ;
  528.                    }
  529.                 case 7: /* Read */
  530.                    {
  531.                    SetWindowText ( hWnd, "Reading" ) ;
  532.                    pCDiskTemporary = DiskDriveCreateVDrive ( pCVDrives[nDrive], FD0000, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  533.                    if (!DiskDriveHasData(pCDiskTemporary)) return ( TRUE ) ;
  534.                    if ( pCDiskImage != NULL )
  535.                       {
  536.                       DiskDriveDelete ( pCDiskImage ) ;
  537.                       pCDiskImage = NULL ;
  538.                       }
  539.                    pCDiskImage = DiskDriveCreateMemory ( (UINT)0, DiskDriveType ( pCDiskTemporary ), 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  540.                    DiskDriveCopy ( pCDiskImage, pCDiskTemporary ) ;
  541.                    DiskDriveReset ( pCDiskTemporary ) ;
  542.                    DiskDriveDelete ( pCDiskTemporary ) ;
  543.                    if ( bCancel )
  544.                       {
  545.                       DiskDriveDelete ( pCDiskImage ) ;
  546.                       pCDiskImage = NULL ;
  547.                       }
  548.                    bIdle = TRUE ;
  549.                    SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  550.                    return ( TRUE ) ;
  551.                    break ;
  552.                    }
  553.                 case 8: /* Write */
  554.                    {
  555.                    if ( pCDiskImage==NULL )
  556.                       {
  557.                       MessageBox ( hWnd, "You must first READ in a diskette image before writting.", "Sample", MB_ICONEXCLAMATION|MB_OK ) ;
  558.                       return ( TRUE ) ;
  559.                       }
  560.                    SetWindowText ( hWnd, "Writing" ) ;
  561.                    pCDiskTemporary = DiskDriveCreateVDrive ( pCVDrives[nDrive], 0, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  562.                    DiskDriveCopy ( pCDiskTemporary, pCDiskImage ) ;
  563.                    DiskDriveReset ( pCDiskTemporary ) ;
  564.                    DiskDriveDelete ( pCDiskTemporary ) ;
  565.                    bIdle = TRUE ;
  566.                    SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  567.                    return ( TRUE ) ;
  568.                    break ;
  569.                    }
  570.                 }
  571.              }
  572.  
  573.           break ;
  574.           }
  575.        case WM_DESTROY:
  576.           {
  577.           PostQuitMessage( 0 ) ;
  578.           break ;
  579.           }
  580.        default:
  581.           {
  582.           break ;
  583.           }
  584.        }
  585.     return ( DefWindowProc ( hWnd, nMessage, nParam, lParam ) ) ;
  586. }
  587.  
  588.