첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

728x90
반응형

TestProject.zip
다운로드

▶ MainForm.cs

using System;
using System.Management;
using System.Windows.Forms;

namespace TestProject
{
    /// <summary>
    /// 메인 폼
    /// </summary>
    public partial class MainForm : Form
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainForm()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            #region 이벤트를 설정한다.

            Load += Form_Load;

            #endregion
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region 폼 로드시 처리하기 - Form_Load(sender, e)

        /// <summary>
        /// 폼 로드시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void Form_Load(object sender, EventArgs e)
        {
            ManagementObjectSearcher mso = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");

            foreach(ManagementObject mo in mso.Get())
            {
                AddListViewData(mo, "BootDevice"                               );
                AddListViewData(mo, "BuildNumber"                              );
                AddListViewData(mo, "BuildType"                                );
                AddListViewData(mo, "Caption"                                  );
                AddListViewData(mo, "CodeSet"                                  );
                AddListViewData(mo, "CountryCode"                              );
                AddListViewData(mo, "CreationClassName"                        );
                AddListViewData(mo, "CSCreationClassName"                      );
                AddListViewData(mo, "CSDVersion"                               );
                AddListViewData(mo, "CSName"                                   );
                AddListViewData(mo, "CurrentTimeZone"                          );
                AddListViewData(mo, "DataExecutionPrevention_Available"        );
                AddListViewData(mo, "DataExecutionPrevention_32BitApplications");
                AddListViewData(mo, "DataExecutionPrevention_Drivers"          );
                AddListViewData(mo, "DataExecutionPrevention_SupportPolicy"    );
                AddListViewData(mo, "Debug"                                    );
                AddListViewData(mo, "Description"                              );
                AddListViewData(mo, "Distributed"                              );
                AddListViewData(mo, "EncryptionLevel"                          );
                AddListViewData(mo, "ForegroundApplicationBoost"               );
                AddListViewData(mo, "FreePhysicalMemory"                       );
                AddListViewData(mo, "FreeSpaceInPagingFiles"                   );
                AddListViewData(mo, "FreeVirtualMemory"                        );
                AddListViewData(mo, "InstallDate"                              );
                AddListViewData(mo, "LargeSystemCache"                         );
                AddListViewData(mo, "LastBootUpTime"                           );
                AddListViewData(mo, "LocalDateTime"                            );
                AddListViewData(mo, "Locale"                                   );
                AddListViewData(mo, "Manufacturer"                             );
                AddListViewData(mo, "MaxNumberOfProcesses"                     );
                AddListViewData(mo, "MaxProcessMemorySize"                     );
                AddListViewData(mo, "MUILanguages[]"                           );
                AddListViewData(mo, "Name"                                     );
                AddListViewData(mo, "NumberOfLicensedUsers"                    );
                AddListViewData(mo, "NumberOfProcesses"                        );
                AddListViewData(mo, "NumberOfUsers"                            );
                AddListViewData(mo, "OperatingSystemSKU"                       );
                AddListViewData(mo, "Organization"                             );
                AddListViewData(mo, "OSArchitecture"                           );
                AddListViewData(mo, "OSLanguage"                               );
                AddListViewData(mo, "OSProductSuite"                           );
                AddListViewData(mo, "OSType"                                   );
                AddListViewData(mo, "OtherTypeDescription"                     );
                AddListViewData(mo, "PAEEnabled"                               );
                AddListViewData(mo, "PlusProductID"                            );
                AddListViewData(mo, "PlusVersionNumber"                        );
                AddListViewData(mo, "Primary"                                  );
                AddListViewData(mo, "ProductType"                              );
                AddListViewData(mo, "QuantumLength"                            );
                AddListViewData(mo, "QuantumType"                              );
                AddListViewData(mo, "RegisteredUser"                           );
                AddListViewData(mo, "SerialNumber"                             );
                AddListViewData(mo, "ServicePackMajorVersion"                  );
                AddListViewData(mo, "ServicePackMinorVersion"                  );
                AddListViewData(mo, "SizeStoredInPagingFiles"                  );
                AddListViewData(mo, "Status"                                   );
                AddListViewData(mo, "SuiteMask"                                );
                AddListViewData(mo, "SystemDevice"                             );
                AddListViewData(mo, "SystemDirectory"                          );
                AddListViewData(mo, "SystemDrive"                              );
                AddListViewData(mo, "TotalSwapSpaceSize"                       );
                AddListViewData(mo, "TotalVirtualMemorySize"                   );
                AddListViewData(mo, "TotalVisibleMemorySize"                   );
                AddListViewData(mo, "Version"                                  );
                AddListViewData(mo, "WindowsDirectory"                         );
            }

            foreach(ColumnHeader header in this.listView.Columns)
            {
                header.Width = -2;
            }
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////// Function

        #region 리스트 뷰 데이터 추가하기 - AddListViewData(mo, propertyName)

        /// <summary>
        /// 리스트 뷰 데이터 추가하기
        /// </summary>
        /// <param name="mo">관리 객체</param>
        /// <param name="propertyName">속성명</param>
        private void AddListViewData(ManagementObject mo, string propertyName)
        {
            string value;

            try
            {
                value = mo[propertyName].ToString();
            }
            catch(Exception exception)
            {
                value = "[에러] : " + exception.Message;
            }

            this.listView.Items.Add(propertyName).SubItems.Add(value);
        }

        #endregion
    }
}
728x90
반응형
Posted by 사용자 icodebroker
TAG , ,

댓글을 달아 주세요