IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MFC Discussion :

Intercepter la connexion d'un clavier usb


Sujet :

MFC

  1. #1
    dus
    dus est déconnecté
    Membre confirmé
    Homme Profil pro
    Informatique industrielle
    Inscrit en
    Octobre 2002
    Messages
    98
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Informatique industrielle
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2002
    Messages : 98
    Par défaut Intercepter la connexion d'un clavier usb
    Mon appli tourne sous W2000 et est codée en VC++6.0.
    Elle fonctionne avec une dalle tactile et donc sans clavier ni souris.
    J'arrive à détecter la connexion d'une clé usb avec le message ON_WM_DEVICECHANGE.
    J'aimerais intercepter la connexion d'un clavier usb. Je reçois un évenement ON_WM_DEVICECHANGE avec un EventType que je ne sais pas analyser. quelqu'un a-t'il déjà fait ça ?

  2. #2
    mat.M
    Invité(e)
    Par défaut
    : :

    Tout est dans le MSDN

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/wm_devicechange.asp

    latform SDK: Device I/O
    WM_DEVICECHANGE

    The WM_DEVICECHANGE device message notifies an application of a change to the hardware configuration of a device or the computer.

    A window receives this message through its WindowProc function.

    LRESULT CALLBACK WindowProc(
    HWND hwnd, // handle to window
    UINT uMsg, // message identifier
    WPARAM wParam, // device-change event
    LPARAM lParam // event-specific data
    );

    Parameters

    hwnd
    Handle to window.
    uMsg
    WM_DEVICECHANGE identifier.
    wParam
    Event that has occurred. This parameter can be one of the following values from the Dbt.h header file.
    Value Meaning
    DBT_CONFIGCHANGECANCELED
    0x0019 A request to change the current configuration (dock or undock) has been canceled.
    DBT_CONFIGCHANGED
    0x0018 The current configuration has changed, due to a dock or undock.
    DBT_CUSTOMEVENT
    0x8006 A custom event has occurred.

    Windows NT 4.0 and Windows 95: This value is not supported.

    DBT_DEVICEARRIVAL
    0x8000 A device or piece of media has been inserted and is now available.
    DBT_DEVICEQUERYREMOVE
    0x8001 Permission is requested to remove a device or piece of media. Any application can deny this request and cancel the removal.
    DBT_DEVICEQUERYREMOVEFAILED
    0x8002 A request to remove a device or piece of media has been canceled.
    DBT_DEVICEREMOVECOMPLETE
    0x8004 A device or piece of media has been removed.
    DBT_DEVICEREMOVEPENDING
    0x8003 A device or piece of media is about to be removed. Cannot be denied.
    DBT_DEVICETYPESPECIFIC
    0x8005 A device-specific event has occurred.
    DBT_DEVNODES_CHANGED
    0x0007 A device has been added to or removed from the system.

    Windows NT 4.0 and Windows Me/98/95: This value is not supported.

    DBT_QUERYCHANGECONFIG
    0x0017 Permission is requested to change the current configuration (dock or undock).
    DBT_USERDEFINED
    0xFFFF The meaning of this message is user-defined.
    lParam
    Pointer to a structure that contains event-specific data. Its format depends on the value of the wParam parameter. For more information, refer to the documentation for each event.

    Return Values

    Return TRUE to grant the request.

    Return BROADCAST_QUERY_DENY to deny the request.
    Remarks

    For devices that offer software-controllable features, such as ejection and locking, the system typically sends a DBT_DEVICEREMOVEPENDING message to let applications and device drivers end their use of the device gracefully. If the system forcibly removes a device, it may not send a DBT_DEVICEQUERYREMOVE message before doing so.
    Requirements
    Client Requires Windows "Longhorn", Windows XP, Windows 2000 Professional, Windows NT Workstation 4.0, Windows Me, Windows 98, or Windows 95.
    Server Requires Windows Server "Longhorn", Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.
    Header

    Declared in Winuser.h; include Windows.h and Dbt.h.
    Il faut examiner wParam et LParam ( avec des "casts")

    Si projet win32 ce message est à traiter dans un switch{} tous les messages.
    Si projet MFCil faut rajouter un gestionnaire de message "message handler'

Discussions similaires

  1. Interdire la connexion d'un clavier USB
    Par COGAN dans le forum Sécurité
    Réponses: 4
    Dernier message: 08/01/2014, 08h25
  2. Clavier usb et grub
    Par troumad dans le forum Matériel
    Réponses: 3
    Dernier message: 12/01/2010, 15h43
  3. Comment detecter la connexion d'une clé USB
    Par uvealoop dans le forum MFC
    Réponses: 1
    Dernier message: 07/06/2006, 16h57
  4. Clavier usb sous windows XP
    Par aouidj dans le forum Windows XP
    Réponses: 2
    Dernier message: 06/11/2005, 17h59
  5. connexion wifi et adaptateur usb
    Par HULK dans le forum Hardware
    Réponses: 1
    Dernier message: 10/09/2005, 16h16

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo