protected override void WndProc(ref Message m) { if (m.Msg != NativeMethods.WM_COPYDATA) { base.WndProc(ref m); return; } //------------------------------- // Handle WM_COPYDATA. // Supported commands: // - Trigger capture. //------------------------------- log.DebugFormat("Received WM_COPYDATA."); NativeMethods.COPYDATASTRUCT copyData = (NativeMethods.COPYDATASTRUCT)Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.COPYDATASTRUCT)); int dataType = (int)copyData.dwData; if (dataType != 0) { return; } if (Marshal.PtrToStringUni(copyData.lpData) == COMMAND_TRIGGERCAPTURE || Marshal.PtrToStringAnsi(copyData.lpData) == COMMAND_TRIGGERCAPTURE) { log.DebugFormat("Received capture trigger command."); NotificationCenter.RaiseCaptureTriggered(this); } else { log.ErrorFormat("Unrecognized command."); } return; }