Beispiel #1
0
        public IntPtr WndProc(IntPtr hwnd, int payload, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (payload == (int)WmType.WM_COPYDATA) {
                var cd = new CopyDataStruct();
                cd = (CopyDataStruct)Marshal.PtrToStructure(lParam, typeof(CopyDataStruct));

                handled = true;
                WMReceived(new Win32EventArgs(cd));
            }

            return IntPtr.Zero;
        }
Beispiel #2
0
        /// <summary>
        /// Packs the command into a WM_COPYDATA structure.
        /// </summary>
        /// <param name="cmd"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        private CopyDataStruct packParams(uint cmd, string param)
        {
            var data = new CopyDataStruct {
                dwData = new IntPtr((Int64) cmd),
                cbData = (param.Length + 1) * Marshal.SystemDefaultCharSize,
                lpData = Marshal.StringToHGlobalUni(param)
            };

            return data;
        }
Beispiel #3
0
 public Win32EventArgs(CopyDataStruct cd)
 {
     CopyData = cd;
     Payload = Marshal.PtrToStringAuto(cd.lpData, cd.cbData);
     Payload = Payload.Substring(0, Payload.IndexOf("\0")).Replace("\0", String.Empty);
 }