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

📄 1394api.c

📁 winddk src目录下的WDM源码压缩!
💻 C
📖 第 1 页 / 共 3 页
字号:

ULONG
WINAPI
Get1394AddressFromDeviceObject(
    HWND                hWnd,
    PSTR                szDeviceName,
    PGET_1394_ADDRESS   Get1394Address
    )
{
    HANDLE      hDevice;
    DWORD       dwRet, dwBytesRet;
    
    TRACE(TL_TRACE, (hWnd, "Enter Get1394AddressFromDeviceObject\r\n"));

    TRACE(TL_TRACE, (hWnd, "fulFlags = 0x%x\r\n", Get1394Address->fulFlags));

    hDevice = OpenDevice(hWnd, szDeviceName, FALSE);

    if (hDevice != INVALID_HANDLE_VALUE) {

        dwRet = DeviceIoControl( hDevice,
                                 IOCTL_GET_1394_ADDRESS_FROM_DEVICE_OBJECT,
                                 Get1394Address,
                                 sizeof(GET_1394_ADDRESS),
                                 Get1394Address,
                                 sizeof(GET_1394_ADDRESS),
                                 &dwBytesRet,
                                 NULL
                                 );

        if (dwRet) {

            dwRet = ERROR_SUCCESS;

            TRACE(TL_TRACE, (hWnd, "NA_Bus_Number = 0x%x\r\n", Get1394Address->NodeAddress.NA_Bus_Number));
            TRACE(TL_TRACE, (hWnd, "NA_Node_Number = 0x%x\r\n", Get1394Address->NodeAddress.NA_Node_Number));
        }
        else {

            dwRet = GetLastError();
            TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));
        }

        // free up resources
        CloseHandle(hDevice);
    }    
    else {

        dwRet = GetLastError();
        TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));        
    }

    TRACE(TL_TRACE, (hWnd, "Exit Get1394AddressFromDeviceObject = %d\r\n", dwRet));
    return(dwRet);
} // Get1394AddressFromDeviceObject

ULONG
WINAPI
Control(
    HWND    hWnd,
    PSTR    szDeviceName
    )
{
    HANDLE      hDevice;
    DWORD       dwRet, dwBytesRet;
    
    TRACE(TL_TRACE, (hWnd, "Enter Control\r\n"));

    hDevice = OpenDevice(hWnd, szDeviceName, FALSE);

    if (hDevice != INVALID_HANDLE_VALUE) {

        dwRet = DeviceIoControl( hDevice,
                                 IOCTL_CONTROL,
                                 NULL,
                                 0,
                                 NULL,
                                 0,
                                 &dwBytesRet,
                                 NULL
                                 );

        if (dwRet) {

            dwRet = GetLastError();
            TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));
        }
        else {

            dwRet = ERROR_SUCCESS;
        }

        // free up resources
        CloseHandle(hDevice);
    }
    else {

        dwRet = GetLastError();
        TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));        
    }
    
    TRACE(TL_TRACE, (hWnd, "Exit Control = %d\r\n", dwRet));
    return(dwRet);
} // Control

ULONG
WINAPI
GetMaxSpeedBetweenDevices(
    HWND                            hWnd,
    PSTR                            szDeviceName,
    PGET_MAX_SPEED_BETWEEN_DEVICES  GetMaxSpeedBetweenDevices
    )
{
    HANDLE      hDevice;
    DWORD       dwRet, dwBytesRet;
    ULONG       i;

    TRACE(TL_TRACE, (hWnd, "Enter GetMaxSpeedBetweenDevices\r\n"));

    TRACE(TL_TRACE, (hWnd, "fulFlags = 0x%x\r\n", GetMaxSpeedBetweenDevices->fulFlags));
    TRACE(TL_TRACE, (hWnd, "ulNumberOfDestinations = 0x%x\r\n", GetMaxSpeedBetweenDevices->ulNumberOfDestinations));

    for (i=0; i<GetMaxSpeedBetweenDevices->ulNumberOfDestinations; i++) {

        TRACE(TL_TRACE, (hWnd, "hDestinationDeviceObjects[%d] = 0x%x\r\n", i, 
            GetMaxSpeedBetweenDevices->hDestinationDeviceObjects[i]));
    }

    hDevice = OpenDevice(hWnd, szDeviceName, FALSE);

    if (hDevice != INVALID_HANDLE_VALUE) {

        dwRet = DeviceIoControl( hDevice,
                                 IOCTL_GET_MAX_SPEED_BETWEEN_DEVICES,
                                 GetMaxSpeedBetweenDevices,
                                 sizeof(GET_MAX_SPEED_BETWEEN_DEVICES),
                                 GetMaxSpeedBetweenDevices,
                                 sizeof(GET_MAX_SPEED_BETWEEN_DEVICES),
                                 &dwBytesRet,
                                 NULL
                                 );

        if (dwRet) {

            dwRet = ERROR_SUCCESS;

            TRACE(TL_TRACE, (hWnd, "fulSpeed = 0x%x\r\n", GetMaxSpeedBetweenDevices->fulSpeed));
        }
        else {

            dwRet = GetLastError();
            TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));
        }

        // free up resources
        CloseHandle(hDevice);
    }
    else {

        dwRet = GetLastError();
        TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));        
    }
    
    TRACE(TL_TRACE, (hWnd, "Exit GetMaxSpeedBetweenDevices\r\n"));
    return(dwRet);
} // GetMaxSpeedBetweenDevices

ULONG
WINAPI
SetDeviceXmitProperties(
    HWND                        hWnd,
    PSTR                        szDeviceName,
    PDEVICE_XMIT_PROPERTIES     DeviceXmitProperties
    )
{
    HANDLE      hDevice;
    DWORD       dwRet, dwBytesRet;
    
    TRACE(TL_TRACE, (hWnd, "Enter SetDeviceXmitProperties\r\n"));

    TRACE(TL_TRACE, (hWnd, "fulSpeed = 0x%x\r\n", DeviceXmitProperties->fulSpeed));
    TRACE(TL_TRACE, (hWnd, "fulPriority = 0x%x\r\n", DeviceXmitProperties->fulPriority));

    hDevice = OpenDevice(hWnd, szDeviceName, FALSE);

    if (hDevice != INVALID_HANDLE_VALUE) {

        dwRet = DeviceIoControl( hDevice,
                                 IOCTL_SET_DEVICE_XMIT_PROPERTIES,
                                 DeviceXmitProperties,
                                 sizeof(DEVICE_XMIT_PROPERTIES),
                                 NULL,
                                 0,
                                 &dwBytesRet,
                                 NULL
                                 );

        if (!dwRet) {

            dwRet = GetLastError();
            TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));
        }
        else {

            dwRet = ERROR_SUCCESS;
        }

        // free up resources
        CloseHandle(hDevice);
    }
    else {

        dwRet = GetLastError();
        TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));        
    }
    
    TRACE(TL_TRACE, (hWnd, "Exit SetDeviceXmitProperties = %d\r\n", dwRet));
    return(dwRet);
} // SetDeviceXmitProperties

ULONG
WINAPI
GetConfigurationInformation(
    HWND    hWnd,
    PSTR    szDeviceName
    )
{
    HANDLE      hDevice;
    DWORD       dwRet, dwBytesRet;
    
    TRACE(TL_TRACE, (hWnd, "Enter GetConfigurationInformation\r\n"));

    hDevice = OpenDevice(hWnd, szDeviceName, FALSE);

    if (hDevice != INVALID_HANDLE_VALUE) {

        dwRet = DeviceIoControl( hDevice,
                                 IOCTL_GET_CONFIGURATION_INFORMATION,
                                 NULL,
                                 0,
                                 NULL,
                                 0,
                                 &dwBytesRet,
                                 NULL
                                 );

        if (!dwRet) {

            dwRet = GetLastError();
            TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));
        }
        else {

            dwRet = ERROR_SUCCESS;
        }

        // free up resources
        CloseHandle(hDevice);
    }
    else {

        dwRet = GetLastError();
        TRACE(TL_ERROR, (hWnd, "Error = 0x%x\r\n", dwRet));        
    }
    
    TRACE(TL_TRACE, (hWnd, "Exit GetConfigurationInformation = %d\r\n", dwRet));
    return(dwRet);
} // GetConfigurationInformation

ULONG
WINAPI
BusReset(
    HWND    hWnd,
    PSTR    szDeviceName,
    ULONG   fulFlags
    )
{
    HANDLE      hDevice;
    DWORD       dwRet, dwBytesRet;
    
    TRACE(TL_TRACE, (hWnd, "Enter BusReset\r\n"));
    TRACE(TL_TRACE, (hWnd, "fulFlags = 0x%x\r\n", fulFlags));

    hDevice = OpenDevice(hWnd, szDeviceName, FALSE);

    if (hDevice != INVALID_HANDLE_VALUE) {

        dwRet = DeviceIoControl( hDevice,
                                 IOCTL_BUS_RESET,
                                 &fulFlags,
                                 sizeof(ULONG),
                                 NULL,
                                 0,
                                 &dwBytesRet,
                                 NULL
                                 );

⌨️ 快捷键说明

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