Quiero usar c para escribir un monitor para monitorear la situación del complemento USB en win7
#include?lt;dbt.hgt;
#include?lt;stdio.hgt;
#include ?lt; math.hgt;
#include?LRESULT?CALLBACK?WndProc(HWND?h, ?UINT?msg, ?WPARAM?wp, ?LPARAM?lp)
{
¿if?(msg?==?WM_DEVICECHANGE)?{
if((DWORD)wp?==?DBT_DEVICEARRIVAL)?{
DEV_BROADCAST_VOLUME*? (DEV_BROADCAST_VOLUME*)?lp;
if?(p-gt;dbcv_devicetype?==?DBT_DEVTYP_VOLUME)?{
int?(int)(log(double(p-gt ;dbcv_unitmask))?/?log(double(2)));
printf("ah...c disco insertado\n",?' A'? ?l);
}
} else?if((DWORD)wp?==?DBT_DEVICEREMOVECOMPLETE)?{
DEV_BROADCAST_VOLUME*?(DEV_BROADCAST_VOLUME*)?lp;
p >if?(p-gt;dbcv_devicetype?==?DBT_DEVTYP_VOLUME)?{
int?(int)(log(double(p-gt;dbcv_unitmask))?/?log( double (2)));
printf("ah...c disco estaba desconectado\n",?' A'? ?l);
}
}
return?TRUE;
} else?return?DefWindowProc(h,?msg,?wp,?lp);
} p>
int?main()?{
WNDCLASS?wc;
MemoriaCero(amp;wc,?sizeof(wc));
wc.lpszClassName?=?TEXT("myusbmsg");
wc.lpfnWndProc?=?WndProc;
RegisterClass(amp;wc);
HWND ?h?=?CreateWindow(TEXT("myusbmsg"),?TEXT(""),?GetModuleHandle(0),?0);
MSG?msg;
mientras (?GetMessage(amp;msg,?0,?0,?0)?gt;?0?)?{
TranslateMessage(amp;msg);
DispatchMessage(amp ;msg);
}
}}
}}
}