Пример #1
0
        protected override void WndProc(ref Message m)
        {
            try
            {
                switch (m.Msg)
                {

                    case WM_COPYDATA:
                        COPYDATASTRUCT cd = (COPYDATASTRUCT)Marshal.PtrToStructure(m.LParam, typeof(COPYDATASTRUCT));
                        ShareInfo shi;

                        shi = (ShareInfo)Marshal.PtrToStructure(cd.lpData, typeof(ShareInfo));

                        if (shi.lpMsg == "0x77654")
                        {
                            SetExplorerAsDefault(false, false);
                        }
                        if (shi.lpMsg == "0x77655")
                        {
                            SetExplorerAsDefault(false, true);
                        }
                        if (shi.lpMsg == "Share")
                        {

                            csSharing csh = new csSharing();

                            csh.ShareFolder(shi.lpShare, shi.lpSharingName, shi.lpDescription, false);
                            csh = null;
                        }
                        if (shi.lpMsg == "0x88775")
                        {
                            SetExpandFolderTreeOnNavigate(false);
                        }
                        if (shi.lpMsg == "0x88776")
                        {
                            SetExpandFolderTreeOnNavigate(true);
                        }
                        if (shi.lpMsg == "0x88779")
                        {
                            List<string> sources = ListPaths(shi.lpShare);
                            List<string> drops = ListPaths(shi.lpSharingName);

                            for (int val = 0; val < sources.Count; val++)
                            {
                                string source = sources[val];
                                string drop = drops[val];



                                if (source.StartsWith("(f)"))
                                {

                                    WindowsHelper.WindowsAPI.CreateSymbolicLink(drop, source.Substring(3), WindowsAPI.SYMBOLIC_LINK_FLAG.Directory);
                                }
                                else
                                {
                                    WindowsHelper.WindowsAPI.CreateSymbolicLink(drop, source, WindowsAPI.SYMBOLIC_LINK_FLAG.File);
                                }
                            }

                            //WindowsHelper.WindowsAPI.CreateSymbolicLink(shi.lpSharingName, shi.lpShare, (WindowsAPI.SYMBOLIC_LINK_FLAG)shi.IsSetPermisions);
                        }
                        Close();
                        break;
                }
            }
            catch
            {
                Close();
            }
            base.WndProc(ref m);
        }
Пример #2
0
 private void SetSharing(string FolderPath, string Sharename, string Description)
 {
     csSharing csh = new csSharing();
     MessageBox.Show(FolderPath);
     csh.ShareFolder(FolderPath, Sharename, Description,false);
     csh = null;
 }