Bonjour à tous,

voila je suis actuellement en train d'écrire un programme qui me permettra de dialoguer avec un périphérique USB via une DLL.
Mais voila je rencontre quelques soucis : je n'arrive pas à utiliser la fonction RegisterDeviceNotification situer dans la dll user32.
Je code sous code::block avec mingw. je me suis servi pour écrire mon prog d'un autre programme (ecrit avec VC++) dont j'avais les sources. Je vous fourni le bout de code qui me pose problème

merci de votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
 
#define _WIN32_WINDOWS 0x0410
 
#include <iostream>
#include <windows.h>
#include <Dbt.h>
 
 
#define DeviceVID_PID "vid_04d8&pid_000c"
 
using namespace std;
 
typedef DWORD MPUSBGetDLLVersion(void);
typedef DWORD MPUSBGetDeviceCount(PCHAR pVID_PID);
typedef HANDLE MPUSBOpen(DWORD instance, PCHAR pVID_PID, PCHAR pEP, DWORD dwDir, DWORD dwReserved);
typedef BOOL MPUSBClose(HANDLE handle);
typedef DWORD MPUSBRead(HANDLE handle, PVOID pData, DWORD dwLen, PDWORD pLength, DWORD dwMilliseconds);
typedef DWORD MPUSBWrite(HANDLE handle, PVOID pData, DWORD dwLen, PDWORD pLength, DWORD dwMilliseconds);
typedef DWORD MPUSBReadInt(HANDLE handle, PVOID pData, DWORD dwLen, PDWORD pLength, DWORD dwMilliseconds);
typedef HDEVNOTIFY WINAPI RegisterDeviceNotificationUM(HANDLE hRecipient,LPVOID NotificationFilter,DWORD Flags);
 
 
int main()
{
    HINSTANCE dllCoupleur = LoadLibrary("mpusbapi.dll");
        MPUSBGetDLLVersion *versionDll = (MPUSBGetDLLVersion*) GetProcAddress(dllCoupleur,"_MPUSBGetDLLVersion");
        MPUSBGetDeviceCount *nombrePeripherique = (MPUSBGetDeviceCount*) GetProcAddress(dllCoupleur,"_MPUSBGetDeviceCount");
        MPUSBOpen *ouvrir = (MPUSBOpen*) GetProcAddress(dllCoupleur,"_MPUSBOpen");
        MPUSBClose *fermer = (MPUSBClose*) GetProcAddress(dllCoupleur,"_MPUSBClose");
        MPUSBRead *lire = (MPUSBRead*) GetProcAddress(dllCoupleur,"_MPUSBRead");
        MPUSBWrite *ecrire = (MPUSBWrite*) GetProcAddress(dllCoupleur,"_MPUSBWrite");
        MPUSBReadInt *lireInt = (MPUSBReadInt*) GetProcAddress(dllCoupleur,"_MPUSBReadInt");
 
 
 
   HINSTANCE dllAuthentification = LoadLibrary("user32.dll");
      RegisterDeviceNotificationUM *authentification = (RegisterDeviceNotificationUM*) GetProcAddress(dllAuthentification,"RegisterDeviceNotification");
 
 
    HANDLE  EP1INHandle = INVALID_HANDLE_VALUE;
	HANDLE  EP1OUTHandle = INVALID_HANDLE_VALUE;
	unsigned int ADCValue = 0;
	BOOL AttachedState = FALSE;
 
	GUID InterfaceClassGuid = {0xa5dcbf10, 0x6530, 0x11d2, 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED};
	//Register for WM_DEVICECHANGE notifications:
    DEV_BROADCAST_DEVICEINTERFACE MyDeviceBroadcastHeader;// = new DEV_BROADCAST_HDR;
    MyDeviceBroadcastHeader.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
    MyDeviceBroadcastHeader.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
    MyDeviceBroadcastHeader.dbcc_reserved = 0;	//Reserved says not to use...
    MyDeviceBroadcastHeader.dbcc_classguid = InterfaceClassGuid;
//**********ICI*****************
    authentification((HANDLE)this->Handle, &MyDeviceBroadcastHeader, 0x00000000);
    //*****************************************************************************
    //authentification((HANDLE)this->Handle,(LPVOID) &MyDeviceBroadcastHeader, 0x00000000);
			/*
			//Now perform an initial start up check of the device state (attached or not attached), since we would not have
			//received a WM_DEVICECHANGE notification.
			if(MPUSBGetDeviceCount(DeviceVID_PID))	//Check and make sure at least one device with matching VID/PID is attached
			{
				EP1OUTHandle = MPUSBOpen(0, DeviceVID_PID, "\\MCHP_EP1", MP_WRITE, 0);
				EP1INHandle = MPUSBOpen(0, DeviceVID_PID, "\\MCHP_EP1", MP_READ, 0);
 
				AttachedState = TRUE;
				StatusBox_txtbx->Text = "Device Found: AttachedState = TRUE";
				label2->Enabled = true;	//Make the label no longer greyed out
			}
			else	//Device must not be connected (or not programmed with correct firmware)
			{
				StatusBox_txtbx->Text = "Device Not Detected: Verify Connection/Correct Firmware";
				AttachedState = FALSE;
				label2->Enabled = false;	//Make the label greyed out
			}
 
 
*/
    if (versionDll != NULL )
    {
        cout << versionDll() << endl;
    }
 
    if (nombrePeripherique != NULL )
    {
        cout << nombrePeripherique(DeviceVID_PID) << endl;
    }
 
 
 
	return 0;
}