Exemple #1
0
        private unsafe static bool TryToSend(IntPtr hwnd, string filename)
        {
            char[] data = filename.ToCharArray();
            char * b    = stackalloc char[data.Length + 1];

            for (int i = 0; i < data.Length; i++)
            {
                b[i] = data[i];
            }
            b[data.Length] = '\0';

            //string t = ReadFileName(hglobal);
            Win32.COPYDATASTRUCT cddata = new Win32.COPYDATASTRUCT();
            cddata.dwData = OPEN_SHORTCUT;
            cddata.cbData = (uint)(sizeof(char) * (data.Length + 1));
            cddata.lpData = b;

            int lresult = Win32.SendMessage(hwnd, Win32.WM_COPYDATA, IntPtr.Zero, new IntPtr(&cddata));

            //Debug.WriteLine("TryToSend "+lresult);
            return(lresult == OPEN_SHORTCUT_OK);
        }
Exemple #2
0
        private static unsafe bool TryToSend(IntPtr hwnd, string filename)
        {
            char[] data = filename.ToCharArray();
            char* b = stackalloc char[data.Length+1];
            for(int i=0; i<data.Length; i++) b[i] = data[i];
            b[data.Length] = '\0';

            //string t = ReadFileName(hglobal);
            Win32.COPYDATASTRUCT cddata = new Win32.COPYDATASTRUCT();
            cddata.dwData = OPEN_SHORTCUT;
            cddata.cbData = (uint)(sizeof(char) * (data.Length+1));
            cddata.lpData = b;

            int lresult = Win32.SendMessage(hwnd, Win32.WM_COPYDATA, IntPtr.Zero, new IntPtr(&cddata));
            //Debug.WriteLine("TryToSend "+lresult);
            return lresult==OPEN_SHORTCUT_OK;
        }