Ejemplo n.º 1
0
 private static void _find_file(List <CIM_DataFile> _find_files, System.Threading.ManualResetEvent rs_e,
                                Win32_Process prc, ref List <Win32_Process> lstProc)
 {
     CIM_DataFile[] files = prc.GetOpenedCIM_DataFiles();
     foreach (CIM_DataFile file in files)
     {
         _search_file = file;
         CIM_DataFile d_finded = _find_files.Find(find_file);
         if (d_finded != null)
         {
             lstProc.Add(prc);
         }
     }
     rs_e.Set();
 }
Ejemplo n.º 2
0
        public static CIM_DataFile[] GetCIM_DataFilesByName(string machineName, string filename)
        {
            filename = filename.Replace(@"\", @"\\");
            System.Management.ManagementObjectCollection mog =
                WmiAccess.GetInstancesByNameForFiles(machineName, "CIM_DataFile", filename);

            List <CIM_DataFile> _find_files = new List <CIM_DataFile>();

            foreach (System.Management.ManagementObject o_file in mog)
            {
                CIM_DataFile f_o = new CIM_DataFile(o_file);
                _find_files.Add(f_o);
            }
            return(_find_files.ToArray());
        }
Ejemplo n.º 3
0
        public string[] GetOpenedFiles()
        {
            System.Management.ManagementObjectCollection mg = _win_process.GetRelated("CIM_DataFile");
            List <string> dt_diles = new List <string>();

            try
            {
                foreach (System.Management.ManagementObject mo in mg)
                {
                    CIM_DataFile dt = new CIM_DataFile(mo);
                    dt_diles.Add(dt.FileName);
                }
            }
            catch (Exception ex) { }
            return(dt_diles.ToArray());
        }
Ejemplo n.º 4
0
        private static void _find_file(List<CIM_DataFile> _find_files, System.Threading.ManualResetEvent rs_e, 
            Win32_Process prc, ref List<Win32_Process> lstProc)
        {
            CIM_DataFile[] files = prc.GetOpenedCIM_DataFiles();
                foreach (CIM_DataFile file in files)
                {
                    _search_file = file;
                    CIM_DataFile d_finded = _find_files.Find(find_file);
                    if (d_finded != null)
                    {
                        lstProc.Add(prc);
                    }

                }
                rs_e.Set();
        }
Ejemplo n.º 5
0
 private static bool find_file(CIM_DataFile file)
 {
     return _search_file.Name.ToLower() == file.Name.ToLower();
 }
Ejemplo n.º 6
0
 public string[] GetOpenedFiles()
 {
     System.Management.ManagementObjectCollection mg = _win_process.GetRelated("CIM_DataFile");
     List<string> dt_diles = new List<string>();
     try
     {
         foreach (System.Management.ManagementObject mo in mg)
         {
             CIM_DataFile dt = new CIM_DataFile(mo);
             dt_diles.Add(dt.FileName);
         }
     }
     catch (Exception ex) { }
     return dt_diles.ToArray();
 }
Ejemplo n.º 7
0
        public static Win32_Process[] GetProcessesWithOpenedFile(string machineName, string filename)
        {
            filename = filename.Replace(@"\", @"\\");
            System.Management.ManagementObjectCollection mog =
                WmiAccess.GetInstancesByNameForFiles(machineName, "CIM_DataFile", filename);
            List<Win32_Process> lstProc = new List<Win32_Process>();

            List<CIM_DataFile> _find_files = new List<CIM_DataFile>();
            foreach (System.Management.ManagementObject o_file in mog)
            {
                CIM_DataFile f_o = new CIM_DataFile(o_file);
                _find_files.Add(f_o);
            }

            List<System.Threading.ManualResetEvent> _resets = new List<System.Threading.ManualResetEvent>();

            Win32_Process[] procs = Win32_Process.GetWin32_Processes(machineName);
            int cnt = 0;
            foreach (Win32_Process prc in procs)
            {
                //CIM_DataFile[] files = prc.GetOpenedCIM_DataFiles();
                //foreach (CIM_DataFile file in files)
                //{
                //    _search_file = file;
                //    CIM_DataFile d_finded = _find_files.Find(find_file);
                //    if (d_finded != null)
                //    {
                //        lstProc.Add(prc);
                //    }

                //}
                _find_file_handler dlg = new _find_file_handler(_find_file);
                System.Threading.ManualResetEvent rs = new System.Threading.ManualResetEvent(false);

                dlg.BeginInvoke(_find_files, rs, prc, ref lstProc, null, null);
                _resets.Add(rs);
                cnt++;
                if (cnt == 60)
                {
                    System.Threading.ManualResetEvent[] m_resets = _resets.ToArray();
                    System.Threading.WaitHandle.WaitAll(m_resets);
                    _resets = new List<System.Threading.ManualResetEvent>();
                    cnt = 0;
                }

            }

            System.Threading.ManualResetEvent[] resets = _resets.ToArray();

            System.Threading.WaitHandle.WaitAll(resets, new TimeSpan(0,5,0));
            System.Threading.Thread.CurrentThread.Join(500);
                //foreach (System.Management.ManagementObject mo in mog)
                //{
                //    System.Management.ManagementObjectCollection mg_C = mo.GetRelated();
                //    foreach (System.Management.ManagementObject mo_L in mg_C)
                //    {
                //        Console.WriteLine(mo_L.ClassPath);
                //        System.Management.ManagementObjectCollection mg_CC = mo_L.GetRelated("Win32_Process");
                //        foreach (System.Management.ManagementObject mo_LL in mg_CC)
                //        {
                //            Console.WriteLine(mo_LL.ClassPath);
                //        }
                //        //Win32_Process prc = new Win32_Process(mo_L);
                //        //lstProc.Add(prc);
                //    }
                //}

            return lstProc.ToArray();
        }
Ejemplo n.º 8
0
 private static bool find_file(CIM_DataFile file)
 {
     return(_search_file.Name.ToLower() == file.Name.ToLower());
 }
Ejemplo n.º 9
0
        public static Win32_Process[] GetProcessesWithOpenedFile(string machineName, string filename)
        {
            filename = filename.Replace(@"\", @"\\");
            System.Management.ManagementObjectCollection mog =
                WmiAccess.GetInstancesByNameForFiles(machineName, "CIM_DataFile", filename);
            List <Win32_Process> lstProc = new List <Win32_Process>();

            List <CIM_DataFile> _find_files = new List <CIM_DataFile>();

            foreach (System.Management.ManagementObject o_file in mog)
            {
                CIM_DataFile f_o = new CIM_DataFile(o_file);
                _find_files.Add(f_o);
            }



            List <System.Threading.ManualResetEvent> _resets = new List <System.Threading.ManualResetEvent>();

            Win32_Process[] procs = Win32_Process.GetWin32_Processes(machineName);
            int             cnt   = 0;

            foreach (Win32_Process prc in procs)
            {
                //CIM_DataFile[] files = prc.GetOpenedCIM_DataFiles();
                //foreach (CIM_DataFile file in files)
                //{
                //    _search_file = file;
                //    CIM_DataFile d_finded = _find_files.Find(find_file);
                //    if (d_finded != null)
                //    {
                //        lstProc.Add(prc);
                //    }

                //}
                _find_file_handler dlg = new _find_file_handler(_find_file);
                System.Threading.ManualResetEvent rs = new System.Threading.ManualResetEvent(false);

                dlg.BeginInvoke(_find_files, rs, prc, ref lstProc, null, null);
                _resets.Add(rs);
                cnt++;
                if (cnt == 60)
                {
                    System.Threading.ManualResetEvent[] m_resets = _resets.ToArray();
                    System.Threading.WaitHandle.WaitAll(m_resets);
                    _resets = new List <System.Threading.ManualResetEvent>();
                    cnt     = 0;
                }
            }

            System.Threading.ManualResetEvent[] resets = _resets.ToArray();

            System.Threading.WaitHandle.WaitAll(resets, new TimeSpan(0, 5, 0));
            System.Threading.Thread.CurrentThread.Join(500);
            //foreach (System.Management.ManagementObject mo in mog)
            //{
            //    System.Management.ManagementObjectCollection mg_C = mo.GetRelated();
            //    foreach (System.Management.ManagementObject mo_L in mg_C)
            //    {
            //        Console.WriteLine(mo_L.ClassPath);
            //        System.Management.ManagementObjectCollection mg_CC = mo_L.GetRelated("Win32_Process");
            //        foreach (System.Management.ManagementObject mo_LL in mg_CC)
            //        {
            //            Console.WriteLine(mo_LL.ClassPath);
            //        }
            //        //Win32_Process prc = new Win32_Process(mo_L);
            //        //lstProc.Add(prc);
            //    }
            //}


            return(lstProc.ToArray());
        }
Ejemplo n.º 10
0
        public static CIM_DataFile[] GetCIM_DataFilesByName(string machineName, string filename)
        {
            filename = filename.Replace(@"\", @"\\");
            System.Management.ManagementObjectCollection mog =
                WmiAccess.GetInstancesByNameForFiles(machineName, "CIM_DataFile", filename);

            List<CIM_DataFile> _find_files = new List<CIM_DataFile>();
            foreach (System.Management.ManagementObject o_file in mog)
            {
                CIM_DataFile f_o = new CIM_DataFile(o_file);
                _find_files.Add(f_o);
            }
            return _find_files.ToArray();
        }