Пример #1
0
        private static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg != 0x219 && msg != 0xD903) //WM_DEVICECHANGE, postmessage msg - 55555
            {
                return(IntPtr.Zero);
            }

            if (wParam.ToInt32() != 0x8000) //DBT_DEVICEARRIVAL
            {
                return(IntPtr.Zero);
            }

            var devType = Marshal.ReadInt32(lParam, IntPtr.Size);

            if (devType != 0x00000002 && msg != 0xD903) //DBT_DEVTYP_VOLUME, postmessage msg - 55555
            {
                return(IntPtr.Zero);
            }

            if (msg != 0xD903) //If this is system message repost it as own message
            {
                PostMessage(hwnd, 55555, wParam, lParam);
            }
            else //If this is own postmessage start the usbsync class
            {
                DebugConsole.WriteLine("Autosync: USB storage device connection detected, triggering UsbSync");
                Debug.WriteLine("Triggering UsbSync");
                UsbSync.Sync();
            }

            return(IntPtr.Zero);
        }
Пример #2
0
 private void Sync_OnClick(object sender, RoutedEventArgs e)
 {
     Info(String.Format(UiLang.Get("SyncDeviceSearch"), Properties.Settings.Default.DeviceModel));
     UsbSync.ManualSync = true;
     UsbSync.Sync();
 }