Click here to Skip to main content
16,011,120 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralProblem with XP! Pin
Lazzari Patrizio10-Jan-05 5:50
Lazzari Patrizio10-Jan-05 5:50 
GeneralRe: Problem with XP! Pin
Iain Clarke, Warrior Programmer10-Jan-05 8:26
Iain Clarke, Warrior Programmer10-Jan-05 8:26 
GeneralRe: Problem with XP! Pin
Lazzari Patrizio10-Jan-05 21:00
Lazzari Patrizio10-Jan-05 21:00 
GeneralRe: Problem with XP! Pin
Iain Clarke, Warrior Programmer11-Jan-05 0:58
Iain Clarke, Warrior Programmer11-Jan-05 0:58 
GeneralRe: Problem with XP! Pin
Lazzari Patrizio11-Jan-05 1:15
Lazzari Patrizio11-Jan-05 1:15 
GeneralRe: Problem with XP! Pin
Antony M Kancidrowski11-Jan-05 2:10
Antony M Kancidrowski11-Jan-05 2:10 
GeneralRe: Problem with XP! Pin
Iain Clarke, Warrior Programmer11-Jan-05 2:45
Iain Clarke, Warrior Programmer11-Jan-05 2:45 
Generalplease help if you can - this problem is driving me mad! Pin
AnthonyDalton10-Jan-05 5:22
AnthonyDalton10-Jan-05 5:22 
Hey, im trying to write some C++ code that will monitor when a certain usb device is plugged in/ plugged out. I've been on the MSDN website and good idea of what i need to do. However, I'm having trouble with RegisterDeviceNotification. The RegisterDeviceNotification is always returning NULL. I would very much appreciate if someone could point out where ive gone wrong with this code:


Code:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <dbt.h>
#include <setupapi.h>

int main()
{
bool result;
HWND hWnd;
char szMsg[80];
GUID InterFaceClassGuid;
void **hDevNotify=NULL;

//CLASSGUID FOR USB DEVICE
InterFaceClassGuid.Data1 = 0x8D948EE9;
InterFaceClassGuid.Data2 = 0xD0AA;
InterFaceClassGuid.Data3 = 0x4A12;
InterFaceClassGuid.Data4[0] = 0x9D;
InterFaceClassGuid.Data4[1] = 0x9A;
InterFaceClassGuid.Data4[2] = 0x9C;
InterFaceClassGuid.Data4[3] = 0xC5;
InterFaceClassGuid.Data4[4] = 0xDE;
InterFaceClassGuid.Data4[5] = 0x36;
InterFaceClassGuid.Data4[6] = 0x19;
InterFaceClassGuid.Data4[7] = 0x9B;

DEV_BROADCAST_DEVICEINTERFACE NotificationFilter;

ZeroMemory( &NotificationFilter, sizeof(NotificationFilter) );
NotificationFilter.dbcc_devicetype= DBT_DEVTYP_DEVICEINTERFACE;
NotificationFilter.dbcc_classguid = InterFaceClassGuid;
hDevNotify=(void**)RegisterDeviceNotification(hWnd,&NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE);

if (!hDevNotify)
{
printf("RegisterDeviceNotification failure: %d\n", GetLastError() );
MessageBox(hWnd, szMsg, "ResisterDeviceNotification", MB_OK);

result= false;
}
result= true;


return 0;
}

Thanks
GeneralRe: please help if you can - this problem is driving me mad! Pin
Martin Koorts10-Jan-05 6:07
Martin Koorts10-Jan-05 6:07 
GeneralInitiate Sending EMail from C++ Pin
Vancouver10-Jan-05 4:44
Vancouver10-Jan-05 4:44 
GeneralRe: Initiate Sending EMail from C++ Pin
Neville Franks10-Jan-05 8:51
Neville Franks10-Jan-05 8:51 
GeneralRe: Initiate Sending EMail from C++ Pin
Vancouver23-Jan-05 20:22
Vancouver23-Jan-05 20:22 
GeneralRe: Initiate Sending EMail from C++ Pin
PJ Arends10-Jan-05 9:04
professionalPJ Arends10-Jan-05 9:04 
GeneralRe: Initiate Sending EMail from C++ Pin
Vancouver23-Jan-05 20:20
Vancouver23-Jan-05 20:20 
GeneralRe: Initiate Sending EMail from C++ Pin
Shog910-Jan-05 9:36
sitebuilderShog910-Jan-05 9:36 
GeneralRe: Initiate Sending EMail from C++ Pin
Vancouver23-Jan-05 20:25
Vancouver23-Jan-05 20:25 
Questionlosing mouse events, help? Pin
DBob10-Jan-05 4:32
DBob10-Jan-05 4:32 
GeneralGlobal Variables in VC++ 6 Pin
guf-cryptkeeper10-Jan-05 4:23
guf-cryptkeeper10-Jan-05 4:23 
GeneralRe: Global Variables in VC++ 6 Pin
fklldsvs10-Jan-05 7:44
fklldsvs10-Jan-05 7:44 
GeneralRe: Global Variables in VC++ 6 Pin
guf-cryptkeeper10-Jan-05 22:53
guf-cryptkeeper10-Jan-05 22:53 
GeneralRe: Global Variables in VC++ 6 Pin
act_x10-Jan-05 8:11
act_x10-Jan-05 8:11 
GeneralRe: Global Variables in VC++ 6 Pin
guf-cryptkeeper10-Jan-05 22:58
guf-cryptkeeper10-Jan-05 22:58 
GeneralRe: Global Variables in VC++ 6 Pin
Iain Clarke, Warrior Programmer10-Jan-05 8:45
Iain Clarke, Warrior Programmer10-Jan-05 8:45 
GeneralRe: Global Variables in VC++ 6 Pin
guf-cryptkeeper13-Jan-05 3:10
guf-cryptkeeper13-Jan-05 3:10 
GeneralRe: Global Variables in VC++ 6 Pin
Iain Clarke, Warrior Programmer13-Jan-05 4:38
Iain Clarke, Warrior Programmer13-Jan-05 4:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.