Exemplo n.º 1
0
        private static Int32 Create(
            IntPtr FileSystemPtr,
            String FileName,
            UInt32 CreateOptions,
            UInt32 GrantedAccess,
            UInt32 FileAttributes,
            IntPtr SecurityDescriptor,
            UInt64 AllocationSize,
            IntPtr ExtraBuffer,
            UInt32 ExtraLength,
            Boolean ExtraBufferIsReparsePoint,
            ref FullContext FullContext,
            ref OpenFileInfo OpenFileInfo)
        {
            FileSystemBase FileSystem = (FileSystemBase)Api.GetUserContext(FileSystemPtr);

            try
            {
                Object FileNode, FileDesc;
                String NormalizedName;
                Int32  Result;
                Result = FileSystem.CreateEx(
                    FileName,
                    CreateOptions,
                    GrantedAccess,
                    FileAttributes,
                    Api.MakeSecurityDescriptor(SecurityDescriptor),
                    AllocationSize,
                    ExtraBuffer,
                    ExtraLength,
                    ExtraBufferIsReparsePoint,
                    out FileNode,
                    out FileDesc,
                    out OpenFileInfo.FileInfo,
                    out NormalizedName);
                if (0 <= Result)
                {
                    if (null != NormalizedName)
                    {
                        OpenFileInfo.SetNormalizedName(NormalizedName);
                    }
                    Api.SetFullContext(ref FullContext, FileNode, FileDesc);
                }
                return(Result);
            }
            catch (Exception ex)
            {
                return(ExceptionHandler(FileSystem, ex));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 打开程序
        /// </summary>
        /// <param name="item">程序地址</param>
        private static void OpenProgram(string path, bool isWait = true)
        {
            Process pro = Process.Start(path);

            if (isWait)
            {
                pro.WaitForInputIdle();
            }
            OpenFileInfo op = new OpenFileInfo();

            op.ID          = pro.Id;
            op.Name        = path;
            op.ProcessName = pro.ProcessName;
            op.HWND        = pro.MainWindowHandle;
            op.Time        = DateTime.Now.ToString();
            Global.FileInfo.Add(op);
        }
Exemplo n.º 3
0
        private static Int32 Open(
            IntPtr FileSystemPtr,
            String FileName,
            UInt32 CreateOptions,
            UInt32 GrantedAccess,
            ref FullContext FullContext,
            ref OpenFileInfo OpenFileInfo)
        {
            FileSystemBase FileSystem = (FileSystemBase)Api.GetUserContext(FileSystemPtr);

            try
            {
                Object FileNode, FileDesc;
                String NormalizedName;
                Int32  Result;
                Result = FileSystem.Open(
                    FileName,
                    CreateOptions,
                    GrantedAccess,
                    out FileNode,
                    out FileDesc,
                    out OpenFileInfo.FileInfo,
                    out NormalizedName);
                if (0 <= Result)
                {
                    if (null != NormalizedName)
                    {
                        OpenFileInfo.SetNormalizedName(NormalizedName);
                    }
                    Api.SetFullContext(ref FullContext, FileNode, FileDesc);
                }
                return(Result);
            }
            catch (Exception ex)
            {
                return(ExceptionHandler(FileSystem, ex));
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 大开文件
 /// </summary>
 /// <param name="item"></param>
 private void OpenSingleApp(string item)
 {
     //判断是从自定义界面打开还是其他界面
     if (Global.IsOneSelf && !Global.IsNew && !Global.IsOpenFolder)
     {
         //如果是自定义则看是可以直接置顶
         int i = FileIsOpen.FileIsOpens(item);
         if (i == 0)
         {
             Thread th = new Thread(() =>
             {
                 object obj = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Policies").OpenSubKey("System").GetValue("EnableLUA");
                 if (obj != null)
                 {
                     if ((int)obj == 0)
                     {
                         OpenProgram(item);
                     }
                     else
                     {  //开启了UAC
                         OpenProgram(item, false);
                     }
                 }
                 else
                 {
                     OpenProgram(item);
                 }
             });
             th.IsBackground = true;
             th.Start();
         }
         string str = mXMLHelper.GetXmlAttrValue(item, "Count");
         str = (int.Parse(str) + 1).ToString();
         mXMLHelper.UpdateNode(item, "Count", str);
         mXMLHelper.UpdateNode(item, "End", DateTime.Now.ToShortDateString());
     }
     else if (Global.IsOneSelf && Global.IsNew && !Global.IsOpenFolder)
     {
         Thread th = new Thread(() =>
         {
             Process pro = Process.Start(item);
             pro.WaitForInputIdle();
             OpenFileInfo op = new OpenFileInfo();
             op.ID           = pro.Id;
             op.Name         = item;
             op.ProcessName  = pro.ProcessName;
             op.HWND         = pro.MainWindowHandle;
             op.Time         = DateTime.Now.ToString();
             Global.FileInfo.Add(op);
         });
         th.IsBackground = true;
         th.Start();
     }
     else if (Global.IsOneSelf && Global.IsOpenFolder)
     {
         string filename = System.IO.Path.GetDirectoryName(item);
         //MessageBox.Show(filename);
         Process.Start("explorer.exe", filename);
         Global.IsOpenFolder = false;
     }
     else
     {
         string cs = "";
         if (item.ToLower() == "shutdown ")
         {
             cs = " -s -t 120";
         }
         Process.Start(item, cs);
     }
 }