protected override void WndProc(ref Message m) { System.Diagnostics.Debug.WriteLine(m.Msg.ToString()); if (m.Msg == WmDevicechange) { switch (m.WParam.ToInt32()) { case DbtDevicearrival: // USB Driver Connected DelegateGetDrives gdi = GetDrives; IAsyncResult result = gdi.BeginInvoke(null, ""); gdi.EndInvoke(result); break; case DbtDeviceremovecomplete: // USB Driver Disconnected if (ClsMain.ConLogInfo == "1") { WriteLog("设备已弹出", 0, ClsMain.ConLogPath); } break; } } else if (m.Msg == WmHotkey) { Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF); if (!FrmSettings.Visible) { FrmSettings.ShowDialog(); } } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { if (m.Msg == WmDevicechange) { switch (m.WParam.ToInt32()) { case DbtDevicearrival: // USB Driver Connected DelegateGetDrives gdi = GetDrives; IAsyncResult result = gdi.BeginInvoke(null, ""); gdi.EndInvoke(result); break; case DbtDeviceremovecomplete: // USB Driver Disconnected if (ClsMain.ConLogInfo == "1") { WriteLog("设备已弹出", 0, ClsMain.ConLogPath); } break; } } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { UInt32 WM_DEVICECHANGE = 0x0219; UInt32 DBT_DEVTUP_VOLUME = 0x02; UInt32 DBT_DEVICEARRIVAL = 0x8000; UInt32 DBT_DEVICEREMOVECOMPLETE = 0x8004; if ((m.Msg == WM_DEVICECHANGE) && (m.WParam.ToInt32() == DBT_DEVICEARRIVAL)) //디바이스 연결 { int devType = Marshal.ReadInt32(m.LParam, 4); if (devType == DBT_DEVTUP_VOLUME) { DelegateGetDrives gdi = new DelegateGetDrives(RefreshDevice); IAsyncResult result = gdi.BeginInvoke(true, null, ""); gdi.EndInvoke(result); //string path = @"C:\Users\77\Desktop\바탕화면\프로젝트 0613\바탕화면(쌤플)\WpfApplication1\bin\Debug\WpfApplication1.exe"; //Process.Start(path); //Run(); } } if ((m.Msg == WM_DEVICECHANGE) && (m.WParam.ToInt32() == DBT_DEVICEREMOVECOMPLETE)) //디바이스 연결 해제 { int devType = Marshal.ReadInt32(m.LParam, 4); if (devType == DBT_DEVTUP_VOLUME) { //RefreshDevice(false); DelegateKillProcess kp = new DelegateKillProcess(ProcessKill); IAsyncResult result = kp.BeginInvoke(null, ""); kp.EndInvoke(result); } } base.WndProc(ref m); }