示例#1
0
 public override string GetItemDisplaySummaryInfo(int index)
 {
     if (index == 0)
     {
         return("");
     }
     else
     {
         FtpEntryInfo info = internal_list.Keys[index - 1];
         if (info.Directory)
         {
             return(string.Format
                        ("Directory [{0}] [{1} {2}]",
                        info.Permission,
                        info.Timestamp.ToShortDateString(),
                        info.Timestamp.ToShortTimeString()));
         }
         else
         {
             return(string.Format
                        ("{0} [{1}] [{2} {3}]",
                        IOhelper.SizeToString(info.Size),
                        info.Permission,
                        info.Timestamp.ToShortDateString(),
                        info.Timestamp.ToShortTimeString()));
         }
     }
 }
示例#2
0
        public override string GetItemDisplaySummaryInfo(int index)
        {
            Process p = intern_list[index];
            string  total_cpu_time = string.Empty;

            try
            {
                total_cpu_time = p.TotalProcessorTime.ToString();
            }
            catch (Exception)
            {
                total_cpu_time = "<Unknown>";
            }
            string working_set = string.Empty;

            try
            {
                working_set = IOhelper.SizeToString(p.WorkingSet64);
            }
            catch (Exception)
            {
                working_set = "<Unknown>";
            }
            return(string.Format
                       ("PID:{0} [{1}] [{2}]",
                       p.Id,
                       total_cpu_time,
                       working_set));
        }
示例#3
0
        protected override void internal_command_proc()
        {
            QueryPanelInfoEventArgs e = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e);

            if (!(e.ItemCollection is DirectoryList))
            {
                return;
            }

            try
            {
                DirectoryList   dl   = (DirectoryList)e.ItemCollection;
                VolumeSpaceInfo info = WinAPiFSwrapper.GetVolumeSpaceInfo(dl.DirectoryPath);

                VolumeSpaceInfoDialog dialog = new VolumeSpaceInfoDialog();
                dialog.textBoxTotalSize.Text      = IOhelper.SizeToString(info.TotalNumberOfBytes);
                dialog.textBoxTotalAvailable.Text = IOhelper.SizeToString(info.FreeBytesAvailable);
                dialog.Text = dl.DirectoryPath;
                dialog.ShowDialog();
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
        }
示例#4
0
 public override string GetSummaryInfo()
 {
     return(string.Format
                ("[{0} folders] [{1} files] [{2}]",
                cache_directory_count,
                cache_files_count,
                IOhelper.SizeToString(cache_size)));
 }
示例#5
0
 public override string GetSummaryInfo()
 {
     return
         (string.Format
              ("Total: {0} stream(s), {1}",
              internal_list.Count - 1,
              IOhelper.SizeToString(total_size)));
 }
        private void set_readonly(string file_name)
        {
            FileSystemInfo fsi         = IOhelper.GetFileSystemInfo(file_name);
            FileAttributes fa_existing = fsi.Attributes;
            FileAttributes fa_needed   = FileAttributes.ReadOnly | fa_existing;

            fsi.Attributes = fa_needed;
        }
        private void clear_readonly(string file_name)
        {
            FileSystemInfo fsi         = IOhelper.GetFileSystemInfo(file_name);
            FileAttributes fa_existing = fsi.Attributes;
            FileAttributes fs_feeded   = ~((~fa_existing) | FileAttributes.ReadOnly);

            fsi.Attributes = fs_feeded;
        }
示例#8
0
        public void FillContents(string file_name)
        {
            //directory or file?

            FileName = file_name;
            var            file_hanle = IntPtr.Zero;
            var            win_err    = 0;
            Win32Exception win_ex     = null;

            try
            {
                if (IOhelper.IsDirectory(file_name))
                {
                    file_hanle = WinApiFS.CreateFile_intptr
                                     (file_name,
                                     Win32FileAccess.GENERIC_READ,
                                     FileShare.ReadWrite,
                                     IntPtr.Zero,
                                     FileMode.Open,
                                     CreateFileOptions.BACKUP_SEMANTICS,
                                     IntPtr.Zero);
                }
                else
                {
                    file_hanle = WinApiFS.CreateFile_intptr
                                     (file_name,
                                     Win32FileAccess.GENERIC_READ,
                                     FileShare.ReadWrite,
                                     IntPtr.Zero,
                                     FileMode.Open,
                                     CreateFileOptions.None,
                                     IntPtr.Zero);
                }

                if (file_hanle.ToInt64() == WinApiFS.INVALID_HANDLE_VALUE)
                {
                    win_err = Marshal.GetLastWin32Error();
                    win_ex  = new Win32Exception(win_err);
                    return;
                }

                FillContents(file_hanle);
            }
            finally
            {
                if ((file_hanle != IntPtr.Zero) && (file_hanle.ToInt64() != WinApiFS.INVALID_HANDLE_VALUE))
                {
                    WinApiFS.CloseHandle(file_hanle);
                }

                if (win_ex != null)
                {
                    var fake_info = new NT_FILE_STREAM_INFORMATION();
                    fake_info.StreamName = win_ex.Message;
                    listViewStreams.Items.Add(new InternalListViewItem(fake_info));
                }
            }
        }
示例#9
0
        public void FillContents(string file_name)
        {
            FileName = file_name;
            Text     = file_name;

            is_directory = IOhelper.IsDirectory(file_name);

            FillStandardPage(file_name);
        }
示例#10
0
        private void FillStandardPage(string file_name)
        {
            IntPtr file_handle  = IntPtr.Zero;
            string nt_file_name = IOhelper.GetUnicodePath(file_name);

            try
            {
                textBoxName.Text = string.Format
                                       ("{0}",
                                       Path.GetFileName(file_name));

                // find data --------------------------------------
                WIN32_FIND_DATA f_data = new WIN32_FIND_DATA();
                WinAPiFSwrapper.GetFileInfo(file_name, ref f_data);
                textBoxAttributes.Text = f_data.dwFileAttributes.ToString();
                textBoxAltname.Text    = f_data.cAlternateFileName;
                textBoxReaprseTag.Text = f_data.ReparseTag.ToString();
                //--------------------------------------------------

                fileSystemSecurityViewer1.FillContains(file_name);

                try
                {
                    fill_basic_info();
                    //fill_device();
                    fill_standard_info();
                    //fill_volume_attr();
                    //fill_volume_info();
                    fill_links(f_data.ReparseTag);
                    fill_dir_size();
                }
                catch (Exception ex)
                {
                    Messages.ShowException(ex);
                }

                try
                {
                    streamViewer1.FillContents(file_name);
                }
                catch (Exception)
                {
                }
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
            finally
            {
                if ((file_handle != IntPtr.Zero) && (file_handle.ToInt32() != WinApiFS.INVALID_HANDLE_VALUE))
                {
                    WinApiFS.CloseHandle(file_handle);
                }
            }
        }
示例#11
0
        private void set_attributes_file(string file_name, FileAttributes fa)
        {
            FileSystemInfo fsi = IOhelper.GetFileSystemInfo(file_name);

            if (fsi == null)
            {
                throw new ApplicationException(string.Format(Options.GetLiteral(Options.LANG_FILE_0_NOT_FOUND), file_name));
            }
            fsi.Attributes = fa;
        }
        private void set_attributes_file(string file_name, FileAttributes fa)
        {
            FileSystemInfo fsi = IOhelper.GetFileSystemInfo(file_name);

            if (fsi == null)
            {
                throw new ApplicationException(string.Format("File '{0}' not found.", file_name));
            }
            fsi.Attributes = fa;
        }
示例#13
0
        public override string GetItemDisplaySummaryInfo(int index)
        {
            var name = internal_list.Keys[index];

            if (name == "..")
            {
                return(Options.GetLiteral(Options.LANG_UP));
            }


            var entry = zip_file.GetEntry(name);

            if (entry == null)
            {
                //try to get slash-ended entry
                entry = zip_file.GetEntry(name + "/");

                if (entry == null)
                {
                    //this is fake dir
                    return("[" + Options.GetLiteral(Options.LANG_DIRECTORY) + "]");
                }
            }


            var fa = FileAttributes.Normal;

            if (entry.IsDOSEntry)
            {
                try
                {
                    fa = (FileAttributes)entry.ExternalFileAttributes;
                }
                catch (Exception) { }
            }

            if (entry.IsDirectory)
            {
                return(string.Format
                           ("[" + Options.GetLiteral(Options.LANG_DIRECTORY) + "] [{0}] [{1} {2}]",
                           IOhelper.FileAttributes2String(fa),
                           entry.DateTime.ToShortDateString(),
                           entry.DateTime.ToShortTimeString()));
            }
            else
            {
                return(string.Format
                           ("{0} [{1}] [{2}] [{3} {4}]",
                           IOhelper.SizeToString(entry.Size),
                           IOhelper.SizeToString(entry.CompressedSize),
                           IOhelper.FileAttributes2String(fa),
                           entry.DateTime.ToShortDateString(),
                           entry.DateTime.ToShortTimeString()));
            }
        }
示例#14
0
            public InternalListViewItem(string dir_path, WIN32_FIND_DATA data)
            {
                InternalData = data;

                Text = System.IO.Path.Combine(dir_path, data.cFileName);
                SubItems.Add(data.FileSize.ToString("#,##0"));
                SubItems.Add(IOhelper.FileAttributes2String(data.dwFileAttributes));
                SubItems.Add(DateTime.FromFileTime(data.ftCreationTime).ToString());
                SubItems.Add(DateTime.FromFileTime(data.ftLastWriteTime).ToString());
                SubItems.Add(DateTime.FromFileTime(data.ftLastAccessTime).ToString());
            }
示例#15
0
        public override string GetItemDisplaySummaryInfo(int index)
        {
            string_builder.Remove(0, string_builder.Length);

            if (internal_list.Keys[index].DeviceReady)
            {
                string_builder.Append(string.Format("[Total: {0}] [Available: {1}]", IOhelper.SizeToString(internal_list.Keys[index].VolumeSpaceInfo.TotalNumberOfBytes), IOhelper.SizeToString(internal_list.Keys[index].VolumeSpaceInfo.FreeBytesAvailable)));
            }

            return(string_builder.ToString());
        }
示例#16
0
        public override string GetItemDisplaySummaryInfo(int index)
        {
            FileStreamInfo info = internal_list.Keys[index];

            return
                (string.Format
                     ("{0} [{1}] [{2}]",
                     IOhelper.SizeToString(info.Size),
                     IOhelper.FileStreamID2String(info.ID),
                     IOhelper.FileStreamAttributes2String(info.Attributes)));
        }
        private void copy_proc()
        {
            //now we have initial_source[] and destination

            //see initial_destination
            //initial_destination may be directory or file or file stream
            //and it may existent or no
            if (IOhelper.PathIsFileStream(initial_destination))
            {
                //copy_dest_file_stream();
            }
        }
        private void add_attributes_file(string file_name, FileAttributes fa)
        {
            FileSystemInfo fsi = IOhelper.GetFileSystemInfo(file_name);

            if (fsi == null)
            {
                throw new ApplicationException(string.Format("File '{0}' not found"));
            }
            FileAttributes existing_fa = fsi.Attributes;
            FileAttributes needed_fa   = fa | existing_fa;

            fsi.Attributes = needed_fa;
        }
示例#19
0
        private void add_attributes_file(string file_name, FileAttributes fa)
        {
            FileSystemInfo fsi = IOhelper.GetFileSystemInfo(file_name);

            if (fsi == null)
            {
                throw new ApplicationException(string.Format(Options.GetLiteral(Options.LANG_FILE_0_NOT_FOUND), file_name));
            }
            FileAttributes existing_fa = fsi.Attributes;
            FileAttributes needed_fa   = fa | existing_fa;

            fsi.Attributes = needed_fa;
        }
示例#20
0
        public override string GetSummaryInfo(int[] indices)
        {
            ulong sel_size = 0UL;

            for (int i = 0; i < indices.Length; i++)
            {
                sel_size += internal_list.Keys[indices[i]].Size;
            }
            return
                (string.Format
                     ("Selected {0} stream(s), {1}",
                     indices.Length,
                     IOhelper.SizeToString(sel_size)));
        }
示例#21
0
        } //end of proc

        /// <summary>
        /// work only if source and destination on one volume
        /// </summary>
        /// <param name="source">can be file or dir</param>
        /// <param name="destination">file or dir</param>
        private void move_one_item(FileInfoEx source, string destination)
        {
            //prepare callback buffer
            if (callback_data != IntPtr.Zero)
            {
                Marshal.FreeHGlobal(callback_data);
            }
            callback_data = IOhelper.strings_to_buffer(source.FullName, destination);

            //prepare uni names
            var source_uni      = IOhelper.GetUnicodePath(source.FullName);
            var destination_uni = IOhelper.GetUnicodePath(destination);

            //call update dialog before...
            var e_begin_move = new UpdateProgressArgs();

            e_begin_move.DestinationFile     = destination;
            e_begin_move.EnableTotalProgress = false;
            e_begin_move.Reason     = UpdateProgressReason.StreamSwitch;
            e_begin_move.SourceFile = source.FullName;
            update_progress_safe(e_begin_move);

            //and call MoveFileWithProgress
            var res = WinApiFS.MoveFileWithProgress
                          (source_uni,
                          destination_uni,
                          move_progress_delegate_holder,
                          callback_data,
                          options_api);

            if (res == 0)
            {
                var win_err = Marshal.GetLastWin32Error();
                var win_ex  = new Win32Exception(win_err);
                AbortJobSafe = !process_errors
                                   (string.Format
                                       (Options.GetLiteral(Options.LANG_CANNOT_MOVE_0_ARROW_1),
                                       source,
                                       destination),
                                   win_ex);
                return;
            }
            //success move
            //notify item done - not needed, source item deleted
        }
        private void clear_attributes_file(string file_name, FileAttributes fa)
        {
            FileSystemInfo fsi = IOhelper.GetFileSystemInfo(file_name);

            if (fsi == null)
            {
                throw new ApplicationException(string.Format("File '{0}' not found"));
            }
            FileAttributes existing_fa     = fsi.Attributes;
            int            existing_fa_int = (int)existing_fa;
            int            needed_fa_int;
            int            fa_int = (int)fa;

            needed_fa_int = ~((~existing_fa_int) | fa_int);
            FileAttributes needed_fa = (FileAttributes)needed_fa_int;

            fsi.Attributes = needed_fa;
        }
示例#23
0
        private void clear_attributes_file(string file_name, FileAttributes fa)
        {
            FileSystemInfo fsi = IOhelper.GetFileSystemInfo(file_name);

            if (fsi == null)
            {
                throw new ApplicationException(string.Format(Options.GetLiteral(Options.LANG_FILE_0_NOT_FOUND), file_name));
            }
            FileAttributes existing_fa     = fsi.Attributes;
            int            existing_fa_int = (int)existing_fa;
            int            needed_fa_int;
            int            fa_int = (int)fa;

            needed_fa_int = ~((~existing_fa_int) | fa_int);
            FileAttributes needed_fa = (FileAttributes)needed_fa_int;

            fsi.Attributes = needed_fa;
        }
示例#24
0
        private void search_in_directory_with_subdirs(string dir_path)
        {
            //first find matches in current dir
            search_in_directory(dir_path);

            //check abort
            if (Abort)
            {
                return;
            }

            //see directories
            var search_path = IOhelper.GetUnicodePath(dir_path);

            search_path = search_path.TrimEnd(new char[] { Path.DirectorySeparatorChar });
            search_path = search_path + Path.DirectorySeparatorChar + "*";
            var fs_enum = new WinAPiFSwrapper.WIN32_FIND_DATA_enumerable(search_path, true);

            foreach (var data in fs_enum)
            {
                //check abort
                if (Abort)
                {
                    break;
                }

                //skip some entries
                if (data.cFileName == "..")
                {
                    continue;
                }
                if (data.cFileName == ".")
                {
                    continue;
                }
                if ((data.dwFileAttributes & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    //recursive call
                    search_in_directory_with_subdirs(Path.Combine(dir_path, data.cFileName));
                }
            }
        }
示例#25
0
        public override string GetSummaryInfo(int[] indices)
        {
            if (indices.Length == 0)
            {
                return(GetSummaryInfo());
            }
            else
            {
                var sel_size   = 0L;
                var file_count = 0;
                var dir_count  = 0;

                for (var i = 0; i < indices.Length; i++)
                {
                    if (indices[i] > internal_list.Count)
                    {
                        continue;
                    }

                    sel_size += internal_list.Keys[indices[i] - 1].Size;
                    if (internal_list.Keys[indices[i] - 1].Directory)
                    {
                        dir_count++;
                    }
                    else
                    {
                        file_count++;
                    }
                }

                return(string.Format
                           (Options.GetLiteral
                               (Options.LANG_SELECTED) + ": {0} " +
                           Options.GetLiteral(Options.LANG_DIRECTORIES) + " {1} " +
                           Options.GetLiteral(Options.LANG_FILE_VOLUME_INFORMATION) + " {2}",
                           dir_count,
                           file_count,
                           IOhelper.SizeToString(sel_size)));
            }
        }
示例#26
0
        public override string GetItemDisplaySummaryInfo(int index)
        {
            WIN32_FIND_DATA data     = internal_list.Keys[index];
            DateTime        mod_time = DateTime.FromFileTime(data.ftLastWriteTime);

            if ((data.dwFileAttributes & FileAttributes.Directory) == FileAttributes.Directory)
            {
                return(string.Format
                           ("[Directory] [{0}] [{1} {2}]",
                           IOhelper.FileAttributes2String(data.dwFileAttributes),
                           mod_time.ToShortDateString(),
                           mod_time.ToShortTimeString()));
            }
            else
            {
                return(string.Format
                           ("{0} [{1}] [{2} {3}]",
                           IOhelper.SizeToString(data.FileSize),
                           IOhelper.FileAttributes2String(data.dwFileAttributes),
                           mod_time.ToShortDateString(),
                           mod_time.ToShortTimeString()));
            }
        }
示例#27
0
        public override string GetSummaryInfo(int[] indices)
        {
            if (indices.Length == 0)
            {
                return(GetSummaryInfo());
            }
            else
            {
                long sel_size   = 0L;
                int  file_count = 0;
                int  dir_count  = 0;

                for (int i = 0; i < indices.Length; i++)
                {
                    if (indices[i] > internal_list.Count)
                    {
                        continue;
                    }

                    sel_size += internal_list.Keys[indices[i] - 1].Size;
                    if (internal_list.Keys[indices[i] - 1].Directory)
                    {
                        dir_count++;
                    }
                    else
                    {
                        file_count++;
                    }
                }

                return(string.Format
                           ("Selected: {0} dir(s) {1} file(s) {2}",
                           dir_count,
                           file_count,
                           IOhelper.SizeToString(sel_size)));
            }
        }
示例#28
0
        private void update_progress(UpdateProgressArgs e)
        {
            //will be invoke in UI thread - canot use anything else e and progress_dialog members

            switch (e.Reason)
            {
            case UpdateProgressReason.ChunkFinish:
                progress_dialog.SetProgress(e.TotalTransferred, e.TotalSize);
                progress_dialog.labelSpeed.Text = string.Format
                                                      (Options.GetLiteral(Options.LANG_0_KBYTE_SEC), e.KBytesPerSec);
                progress_dialog.labelStatusTotal.Text = string.Format
                                                            (Options.GetLiteral(Options.LANG_0_BYTES_TRANSFERRED), e.TotalTransferred);
                break;

            case UpdateProgressReason.JobBegin:
                progress_dialog.Text = Options.GetLiteral(Options.LANG_EXTRACT);
                break;

            case UpdateProgressReason.JobDone:
                progress_dialog.SetProgress(100, 100);
                progress_dialog.labelSpeed.Text = string.Format
                                                      (Options.GetLiteral(Options.LANG_0_KBYTE_SEC), e.KBytesPerSec);
                break;

            case UpdateProgressReason.StreamSwitch:
                progress_dialog.labelStatus.Text =
                    string.Format
                        (Options.GetLiteral(Options.LANG_0_ARROW_1_2),
                        e.SourceFile,
                        e.DestinationFile,
                        IOhelper.SizeToString(e.StreamSize));
                progress_dialog.labelSpeed.Text = string.Format
                                                      (Options.GetLiteral(Options.LANG_0_KBYTE_SEC), e.KBytesPerSec);
                break;
            }
        }
示例#29
0
        private void fill_netserver_page()
        {
            try
            {
                var serv_info = WinApiNETwrapper.GetServerInfo_102(resource_intern.lpRemoteName);
                textBoxNetserverPlatformId.Text      = serv_info.sv102_platform_id.ToString();
                textBoxNetserverSoftwareType.Text    = IOhelper.NetserverTypeToString(serv_info.sv102_type);
                textBoxPlatformVersion.Text          = string.Format("{0}.{1}", serv_info.GetVersionMajor(), serv_info.sv102_version_minor);
                textBoxNetserverMaxUsers.Text        = serv_info.sv102_users.ToString();
                textBoxNetserverDisconnectTime.Text  = serv_info.sv102_disc.ToString();
                textBoxNetserverAnnounceTime.Text    = serv_info.sv102_announce.ToString();
                textBoxNetserverUsersPerLicense.Text = serv_info.sv102_licenses.ToString();
                textBoxNetserverUserPath.Text        = serv_info.sv102_userpath;
            }
            catch (Exception ex)
            {
                errorProvider1.SetIconAlignment(textBoxNetserverPlatformId, ErrorIconAlignment.MiddleLeft);
                errorProvider1.SetError(textBoxNetserverPlatformId, ex.Message);
            }

            try
            {
                var features = WinApiNETwrapper.GetComputerSupports(resource_intern.lpRemoteName);
                textBoxNetserverFeatures.Text = features.ToString();
            }
            catch (Exception ex)
            {
                errorProvider1.SetIconAlignment(textBoxNetserverFeatures, ErrorIconAlignment.MiddleLeft);
                errorProvider1.SetError(textBoxNetserverFeatures, ex.Message);
            }

            try
            {
                var dt = WinApiNETwrapper.GetServerTime(resource_intern.lpRemoteName);
                textBoxNetserverDatetime.Text = string.Format("{0} {1},{2}", dt.GetCurrentDatetime().ToLongDateString(), dt.GetCurrentDatetime().ToLongTimeString(), dt.GetCurrentDatetime().Millisecond);
                textBoxNetserverUptime.Text   = dt.GetUptime().ToString();
            }
            catch (Exception ex)
            {
                errorProvider1.SetIconAlignment(textBoxNetserverDatetime, ErrorIconAlignment.MiddleLeft);
                errorProvider1.SetError(textBoxNetserverDatetime, ex.Message);
            }

            //NET_DISPLAY_GROUP[] groups = WinApiNETwrapper.QueryDisplayInfoGroup(resource_intern.lpRemoteName);
            //NET_DISPLAY_MACHINE[] machines = WinApiNETwrapper.QueryDisplayInfoMachine(resource_intern.lpRemoteName);
            //NET_DISPLAY_USER[] users = WinApiNETwrapper.QueryDisplayInfoUser(resource_intern.lpRemoteName);

            try
            {
                var transports = WinApiNETwrapper.ServerTransportEnum_1(resource_intern.lpRemoteName);
                for (var i = 0; i < transports.Length; i++)
                {
                    var lvi = new ListViewItem();
                    lvi.Text = transports[i].svti1_transportname;
                    lvi.SubItems.Add(transports[i].TransportAddress);
                    lvi.SubItems.Add(transports[i].svti1_networkaddress);
                    lvi.SubItems.Add(transports[i].svti1_domain);
                    lvi.SubItems.Add(transports[i].svti1_numberofvcs.ToString());
                    listViewTransports.Items.Add(lvi);
                }
                listViewTransports.Dock = DockStyle.Fill;
            }
            catch (Exception ex)
            {
                errorProvider1.SetIconAlignment(listViewTransports, ErrorIconAlignment.MiddleLeft);
                errorProvider1.SetError(listViewTransports, ex.Message);
            }

            /* net sessions */
            errorProvider1.SetIconAlignment(listViewSessions, ErrorIconAlignment.MiddleLeft);
            Array sessions      = null;
            var   session_level = NetSessionEnumLevel.INFO_502;

            try
            {
                //try level 502
                sessions = WinApiNETwrapper.NetSessionEnum(resource_intern.lpRemoteName, null, null, session_level);
            }
            catch (Exception)
            {
                //if exception try level 10
                session_level = NetSessionEnumLevel.INFO_10;
                try
                {
                    sessions = WinApiNETwrapper.NetSessionEnum(resource_intern.lpRemoteName, null, null, session_level);
                }
                catch (Exception ex_10)
                {
                    errorProvider1.SetError(listViewSessions, ex_10.Message);
                }
            }
            if (sessions != null)
            {
                listViewSessions.Dock = DockStyle.Fill;
                for (var i = 0; i < sessions.Length; i++)
                {
                    var lvi = new ListViewItem();
                    switch (session_level)
                    {
                    case NetSessionEnumLevel.INFO_502:
                        var info_502 = (SESSION_INFO_502)sessions.GetValue(i);
                        lvi.Text = info_502.sesi502_cname;
                        lvi.SubItems.Add(info_502.sesi502_username);
                        lvi.SubItems.Add(info_502.sesi502_num_opens.ToString());
                        lvi.SubItems.Add(info_502.TimeActive.ToString());
                        lvi.SubItems.Add(info_502.TimeIdle.ToString());
                        lvi.SubItems.Add(info_502.sesi502_user_flags.ToString());
                        lvi.SubItems.Add(info_502.sesi502_cltype_name);
                        lvi.SubItems.Add(info_502.sesi502_transport);
                        break;

                    case NetSessionEnumLevel.INFO_10:
                        var info_10 = (SESSION_INFO_10)sessions.GetValue(i);
                        lvi.Text = info_10.sesi10_cname;
                        lvi.SubItems.Add(string.Empty);
                        lvi.SubItems.Add(string.Empty);
                        lvi.SubItems.Add(info_10.TimeActive.ToString());
                        lvi.SubItems.Add(info_10.TimeIdle.ToString());
                        lvi.SubItems.Add(string.Empty);
                        lvi.SubItems.Add(string.Empty);
                        lvi.SubItems.Add(string.Empty);
                        break;
                    }
                    listViewSessions.Items.Add(lvi);
                }
            }
            /* end of net sessions */

            /* open files */
            try
            {
                var files = WinApiNETwrapper.NetFileEnum(resource_intern.lpRemoteName, null, null, NetFileEnumLevel.INFO_3);
                listViewFiles.Dock = DockStyle.Fill;
                for (var i = 0; i < files.Length; i++)
                {
                    var f_info = (FILE_INFO_3)files.GetValue(i);
                    var lvi    = new ListViewItem();
                    lvi.Text = string.Format("0x{0:X}", f_info.fi3_id);
                    lvi.SubItems.Add(f_info.fi3_permission.ToString());
                    lvi.SubItems.Add(f_info.fi3_num_locks.ToString());
                    lvi.SubItems.Add(f_info.fi3_pathname);
                    lvi.SubItems.Add(f_info.fi3_username);
                    listViewFiles.Items.Add(lvi);
                }
            }
            catch (Exception ex_files)
            {
                errorProvider1.SetIconAlignment(listViewFiles, ErrorIconAlignment.MiddleLeft);
                errorProvider1.SetError(listViewFiles, ex_files.Message);
            }
            /* end of open files */
        }
示例#30
0
        public void Fill(Process p)
        {
            Text = p.ProcessName;
            textBoxProcessId.Text   = p.Id.ToString();
            textBoxProcessName.Text = p.ProcessName;
            try
            {
                textBoxProcessPriorityClass.Text = p.PriorityClass.ToString();
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(textBoxProcessPriorityClass, ex.Message);
            }
            try
            {
                textBoxProcessWindowTitle.Text = p.MainWindowTitle;
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(textBoxProcessWindowTitle, ex.Message);
            }
            try
            {
                checkBoxProcessPriorityBoostEnable.Checked = p.PriorityBoostEnabled;
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(checkBoxProcessPriorityBoostEnable, ex.Message);
            }
            try
            {
                checkBoxProcessResponding.Checked = p.Responding;
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(checkBoxProcessResponding, ex.Message);
            }
            try
            {
                textBoxProcessMainModule.Text = p.MainModule.FileName;
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(textBoxProcessMainModule, ex.Message);
            }
            try
            {
                textBoxProcessNonpagedSystemMemorySize.Text = IOhelper.SizeToString(p.NonpagedSystemMemorySize64);
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(textBoxProcessNonpagedSystemMemorySize, ex.Message);
            }
            try
            {
                textBoxprocessorUserProcessorTime.Text = p.UserProcessorTime.ToString();
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(textBoxprocessorUserProcessorTime, ex.Message);
            }
            try
            {
                textBoxProcessPagedMemorySize.Text = IOhelper.SizeToString(p.PagedMemorySize64);
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(textBoxProcessPagedMemorySize, ex.Message);
            }
            try
            {
                textBoxProcessPagedSystemMemorySize.Text = IOhelper.SizeToString(p.PagedSystemMemorySize64);
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(textBoxProcessPagedSystemMemorySize, ex.Message);
            }
            try
            {
                textBoxProcessPrivateMemorySize.Text = IOhelper.SizeToString(p.PrivateMemorySize64);
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(textBoxProcessPrivateMemorySize, ex.Message);
            }
            try
            {
                textBoxProcessPrivilegedProcessorTime.Text = p.PrivilegedProcessorTime.ToString();
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(textBoxProcessPrivilegedProcessorTime, ex.Message);
            }
            try
            {
                textBoxProcessStartTime.Text = p.StartTime.ToString();
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(textBoxProcessStartTime, ex.Message);
            }
            try
            {
                var time_from_start = DateTime.Now.Subtract(p.StartTime);
                var secs_from_start = time_from_start.TotalSeconds;
                var secs_cpu_time   = p.TotalProcessorTime.TotalSeconds;
                var cpu_load        = secs_cpu_time / secs_from_start;
                textBoxProcessTotalProcessorTime.Text = string.Format("{0} <{1:P4}>", p.TotalProcessorTime.ToString(), cpu_load);
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(textBoxProcessTotalProcessorTime, ex.Message);
            }
            try
            {
                textBoxProcessVirtualMemorySize.Text = IOhelper.SizeToString(p.VirtualMemorySize64);
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(textBoxProcessVirtualMemorySize, ex.Message);
            }
            try
            {
                textBoxProcessWorkingSet.Text = IOhelper.SizeToString(p.WorkingSet64);
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(textBoxProcessWorkingSet, ex.Message);
            }

            try
            {
                var pmc = p.Modules;
                foreach (ProcessModule pm in pmc)
                {
                    var lvi = new ListViewItem();
                    lvi.Text = pm.FileName;
                    lvi.SubItems.Add(pm.FileVersionInfo.CompanyName);
                    lvi.SubItems.Add(pm.FileVersionInfo.ProductName);
                    lvi.SubItems.Add(pm.FileVersionInfo.ProductVersion);
                    lvi.SubItems.Add(IOhelper.SizeToString((long)pm.ModuleMemorySize));
                    listViewModulesInfo.Items.Add(lvi);
                }
                listViewModulesInfo.Dock = DockStyle.Fill;
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(listViewModulesInfo, ex.Message);
            }

            try
            {
                var ptc = p.Threads;
                foreach (ProcessThread pt in ptc)
                {
                    var lvi = new ListViewItem();
                    try
                    {
                        lvi.Text = pt.Id.ToString();

                        var ts = pt.ThreadState;
                        if (ts == ThreadState.Wait)
                        {
                            lvi.SubItems.Add(pt.ThreadState.ToString() + " " + pt.WaitReason.ToString());
                        }
                        else
                        {
                            lvi.SubItems.Add(pt.ThreadState.ToString());
                        }

                        if (pt.ThreadState != ThreadState.Terminated)
                        {
                            lvi.SubItems.Add(pt.PriorityLevel.ToString());

                            //load
                            var total_secs = DateTime.Now.Subtract(pt.StartTime).TotalSeconds;
                            var cpu_secs   = pt.TotalProcessorTime.TotalSeconds;
                            var cpu_load   = cpu_secs / total_secs;
                            lvi.SubItems.Add(string.Format("{0:P4}", cpu_load));

                            lvi.SubItems.Add(pt.StartTime.ToString());
                            lvi.SubItems.Add(pt.PrivilegedProcessorTime.ToString());
                            lvi.SubItems.Add(pt.UserProcessorTime.ToString());
                        }
                    }
                    catch (Exception ex_int)
                    {
                        lvi.SubItems.Add(ex_int.Message);
                    }
                    listViewThreadsInfo.Items.Add(lvi);
                }
                listViewThreadsInfo.Dock = DockStyle.Fill;
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(listViewThreadsInfo, ex.Message);
            }
        }