⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smbrdr.c

📁 winddk src目录下的文件系统驱动源码压缩!
💻 C
📖 第 1 页 / 共 3 页
字号:
            {
                return TRUE;
            }
        }
        if ( pdds->RdrState == RDR_STARTED )
        {
            return TRUE;
        }
        DestroyWindow( hDlg );
    }
    break;

    case WM_DESTROY:
        KillTimer( hDlg, TIMER_ID );
        PostQuitMessage( 0 );
        break;
    }

    return 0;
}


INT_PTR CALLBACK ProviderDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {

        case WM_INITDIALOG:
        {
            ULONG_PTR count, len, nIndex;
            LPTSTR OrderString = NULL, marker, ptr;

#if 0 // #ifdef UNICODE
            TCHAR btntext[10];

            btntext[0] = 0x25b2;    // up arrow in unicode char set
            lstrcpy( &btntext[1], TEXT(" Move Up" ));
            SetDlgItemText( hDlg, IDC_MOVEUP, btntext );
            btntext[0] = 0x25bc;    // down arrow in unicode char set
            lstrcpy( &btntext[1], TEXT(" Move Dn" ));
            SetDlgItemText( hDlg, IDC_MOVEDN, btntext );
#endif

            len = RdrGetProviderOrderString( &OrderString );
            marker = OrderString;

            for ( count = 0, ptr = OrderString; ptr && count <= len; count++, ptr++ )
            {
                switch ( *ptr )
                {
                    case TEXT(','):
                    {
                        if ( count > 0 && ptr > marker )
                        {
                            *ptr = TEXT('\0');
                            SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_ADDSTRING, 0, (LPARAM) marker );
                            *ptr = TEXT(',');
                        }
                        marker = ptr + 1;
                    }
                    break;

                    case TEXT('\0'):
                    {
                        if ( count > 0 && ptr > marker )
                        {
                            SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_ADDSTRING, 0, (LPARAM) marker );
                        }
                    }
                    break;

                    case TEXT(' '):
                        marker = ptr + 1;
                        break;

                    default:
                        break;
                }
            }
            if ( OrderString )
            {
                free( OrderString );
            }
            nIndex = SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_FINDSTRING,
                        (WPARAM) -1, (LPARAM) PROVIDER_NAME );
            SetWindowLongPtr( hDlg, DWLP_USER, nIndex );
            if ( nIndex == LB_ERR)
            {
                nIndex = 0;
                EnableWindow( GetDlgItem( hDlg, IDC_MOVEUP ), FALSE );
                EnableWindow( GetDlgItem( hDlg, IDC_MOVEDN ), FALSE );
            }
            SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_SETCURSEL,
                            (WPARAM) nIndex, 0 );
            
        }
        break;

        case WM_COMMAND:
        {
            switch ( LOWORD( wParam ) )
            {
                case IDC_ORDERLIST:
                {
                    if ( HIWORD( wParam ) == LBN_SELCHANGE )
                    {
                        ULONG_PTR staticsel, cursel;

                        staticsel = GetWindowLongPtr( hDlg, DWLP_USER );
                        cursel = SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_GETCURSEL, 0, 0 );
                        if ( staticsel != cursel && staticsel != LB_ERR )
                        {
                            SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_SETCURSEL,
                                            (WPARAM) staticsel, 0 );

                        }
                    }
                }
                break;

                case IDC_MOVEUP:
                case IDC_MOVEDN:
                {
                        ULONG_PTR staticsel, items, len;
                        LPTSTR pstr;

                        staticsel = GetWindowLongPtr( hDlg, DWLP_USER );
                        items = SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_GETCOUNT,0 ,0 );
                        if ( staticsel != LB_ERR && items != LB_ERR )
                        {
                            len = SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_GETTEXTLEN, staticsel, 0 );
                            pstr = malloc( (len + 1 ) * sizeof(TCHAR) );
                            if ( pstr )
                            {
                                if ( LOWORD( wParam ) == IDC_MOVEUP && staticsel > 0 )
                                {
                                     SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_GETTEXT, staticsel, (LPARAM) pstr );
                                     SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_DELETESTRING, staticsel, 0 );
                                     SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_INSERTSTRING, --staticsel, (LPARAM) pstr );
                                }
                                else if ( (LOWORD( wParam ) == IDC_MOVEDN) && (items > 0) && (staticsel < (items - 1) ) )
                                {
                                     SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_GETTEXT, staticsel, (LPARAM) pstr );
                                     SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_DELETESTRING, staticsel, 0 );
                                     SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_INSERTSTRING, ++staticsel, (LPARAM) pstr );
                                }
                                free( pstr );
                                SetWindowLongPtr( hDlg, DWLP_USER, staticsel );
                                SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_SETCURSEL, staticsel, 0 );
                            }
                        }
                }
                break;

                case IDOK:
                {
                    LPTSTR OrderString, pstr;
                    ULONG_PTR items, len = 0, index;

                    items = SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_GETCOUNT,0 ,0 );
                    if ( items != LB_ERR )
                    {
                        for ( index = 0; items > 0 && index < items; index++ )
                        {
                            len += SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_GETTEXTLEN, index, 0 );
                        }
                        len += items;   //commas and ending null
                        OrderString = pstr = malloc( len * sizeof( TCHAR ) );
                        if ( OrderString )
                        {
                            for ( index = 0; items > 0 && index < items; index++ )
                            {
                                len = SendDlgItemMessage( hDlg, IDC_ORDERLIST, LB_GETTEXT, index, (LPARAM) pstr );
                                pstr += len;
                                *pstr++ = ( index < ( items - 1 ) ) ? TEXT(',') : TEXT('\0');
                            }
                            RdrSetProviderOrderString( OrderString );
                            free( OrderString );
                        }
                    }
                }

                case IDCANCEL:
                    PostMessage( hDlg, WM_CLOSE, 0, 0 );
                    break;
            }
        }
        break;
                
        case WM_CLOSE:
            EndDialog( hDlg, 0 );
            break;
    }

    return FALSE;
}

INT_PTR CALLBACK StatisticsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_COMMAND:
        {
            switch ( LOWORD( wParam ) )
            {
                case IDOK:
                    PostMessage( hDlg, WM_CLOSE, 0, 0 );
                    break;
            }
        }
        break;

        case WM_CLOSE:
            EndDialog( hDlg, 0 );
            break;
    }

    return FALSE;
}

VOID IndicateWait( PDLGDATASTRUCT pdds )
{
    pdds->hBusySignal = CreateEvent( NULL, FALSE, FALSE, NULL );                    
    pdds->hBusyThread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE) BusyProc, pdds, 0, NULL );
}

VOID UnindicateWait( PDLGDATASTRUCT pdds )
{
    SetEvent( pdds->hBusySignal );
    WaitForSingleObject( pdds->hBusyThread, 1000 );
    CloseHandle( pdds->hBusyThread );
    CloseHandle( pdds->hBusySignal );
    pdds->hBusyThread = NULL;
    pdds->hBusySignal = NULL;
}

VOID InitiateAction( PDLGDATASTRUCT pdds )
{
    if ( pdds->hActionThread )
    {
        WaitForSingleObject( pdds->hActionThread, INFINITE );
        CloseHandle( pdds->hActionThread );
        pdds->hActionThread = NULL;
    }
    //pdds->Action = ACTION_TRANS;
    pdds->hActionThread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE) ActionProc, pdds, 0, NULL );
}

DWORD ActionProc( PDLGDATASTRUCT pdds )
{
    ULONG_PTR newstate;
    BOOL success;

    IndicateWait( pdds );
    success = RdrDoAction( pdds->Action );
    UnindicateWait( pdds );

    pdds->Action = success ? ACTION_TRANS : ACTION_ERROR;
    newstate = RdrGetNextState( pdds->Action, pdds->RdrState );
    PostMessage( pdds->hDlg, WM_RDRSTATECHANGE, 0, newstate );

    return 0;
}


DWORD BusyProc( PDLGDATASTRUCT pdds )
{
    HDC hDC;
    HWND hBusyWnd = GetDlgItem( pdds->hDlg, IDC_BUSY );
    ULONG pos = 0, width;
    RECT clRect, mRect;

    GetClientRect( hBusyWnd, &clRect );

    mRect.left   = clRect.left;
    mRect.top    = clRect.top + clRect.bottom / 6;
    mRect.right  = width = clRect.right / 8;
    mRect.bottom = clRect.bottom - clRect.bottom / 6;

    while ( WaitForSingleObject( pdds->hBusySignal, 100 ) == WAIT_TIMEOUT )
    {
        hDC = GetDC( hBusyWnd );
        FillRect( hDC, &clRect, pdds->hWhtBrush );
        FillRect( hDC, &mRect, pdds->hBluBrush );
        mRect.left += width;
        mRect.right += width;           

        if ( mRect.right > clRect.right )
        {
            mRect.left = 0;
            mRect.right = width;            
        }
        ReleaseDC( hBusyWnd, hDC );
    }
    InvalidateRect( hBusyWnd, NULL, TRUE );

    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -