Figure 3   GetDriveTypeReturn Values

Identifier Defined as Description
DRIVE_UNKNOWN 0 Drive type cannot be determined
DRIVE_NO_ROOT_DIR 1 Root directory does not exist
DRIVE_REMOVABLE 2 The drive is removable
DRIVE_FIXED 3 The disk is not removable
DRIVE_REMOTE 4 A remote (network) drive
DRIVE_CDROM 5 A CD-ROM drive
DRIVE_RAMDISK 6 A RAM disk drive


Figure 4   QueryCancelAutoPlay.cpp


/******************************************************************************
Module name: QueryCancelAutoPlay.cpp
Written by: Jeffrey Richter
******************************************************************************/


#define STRICT
#include <Windows.h>
#include <WindowsX.h>
#include "Resource.h"


///////////////////////////////////////////////////////////////////////////////


BOOL WINAPI DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {

    BOOL fRet = TRUE;
    switch (uMsg) {

      case WM_INITDIALOG:
        fRet = TRUE; 
        break;

      case WM_COMMAND:
        if (GET_WM_COMMAND_ID(wParam, lParam) == IDCANCEL)
            EndDialog(hwnd, 0);
        break;

      default:
        fRet = FALSE;
        break;
    }

    static UINT uMsgQueryCancelAutoPlay = 
        RegisterWindowMessage("QueryCancelAutoPlay");

    if (uMsg == uMsgQueryCancelAutoPlay) {
        int n = MessageBox(hwnd, "Do you wish to cancel AutoPlay?", NULL,
                           MB_YESNO);
        SetDlgMsgResult(hwnd, uMsg, (n == IDYES) ? 1 : 0);
        fRet = TRUE;
    }
    
    return(fRet);
}


///////////////////////////////////////////////////////////////////////////////


int WINAPI WinMain(HINSTANCE hinstExe, HINSTANCE, LPSTR, int) {
    DialogBox(hinstExe, MAKEINTRESOURCE(IDD_QUERYCANCELAUTOPLAY), 
        NULL, DlgProc);
    return(0);
}


///////////////////////////////// End Of File /////////////////////////////////