haha1 2017-04-21 02:02 采纳率: 4.5%
浏览 1542

RegisterDeviceNotification通过GetLastError的返回值1066

RegisterDeviceNotification(hNotificationHandl, &NotificationFilter,DEVICE_NOTIFY_WINDOW_HANDLE);得到错误返回值是1066,请问是什么问题,上面那个参数有问题

  • 写回答

2条回答 默认 最新

  • shen_wei 2017-04-26 08:57
    关注

    `#include
    #include

    HWND hWnd;

    BOOL DoRegisterDeviceInterface(
    GUID InterfaceClassGuid,
    HDEVNOTIFY hDevNotify
    )
    /

    Routine Description:
    Registers for notification of changes in the device interfaces for
    the specified interface class GUID.

    Parameters:
    InterfaceClassGuid - The interface class GUID for the device
    interfaces.

    hDevNotify - Receives the device notification handle. On failure, 
        this value is NULL.
    

    Return Value:
    If the function succeeds, the return value is TRUE.
    If the function fails, the return value is FALSE.
    */

    {
    DEV_BROADCAST_DEVICEINTERFACE NotificationFilter;

    ZeroMemory( &NotificationFilter, sizeof(NotificationFilter) );
    NotificationFilter.dbcc_size = 
        sizeof(DEV_BROADCAST_DEVICEINTERFACE);
    NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
    NotificationFilter.dbcc_classguid = InterfaceClassGuid;
    
    *hDevNotify = RegisterDeviceNotification( hWnd, 
        &NotificationFilter,
        DEVICE_NOTIFY_WINDOW_HANDLE
    );
    
    if(!*hDevNotify) 
    {
        printf("RegisterDeviceNotification failed: %d\n", 
                GetLastError());
        return FALSE;
    }
    
    return TRUE;
    

    }

    int _tmain(void)
    {
    HDEVNOTIFY hDevNotify;

    if(!DoRegisterDeviceInterface(GUID_DEVINTERFACE_VOLUME, &hDevNotify))
    {
        printf("DoRegisterDeviceInterface failed\n");
        return 0;
    }
    return 1;
    

    }
    ``

    
    
    评论

报告相同问题?

悬赏问题

  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号