퇴근5분전



WMI 로 쿼리 할수 있는 객체 정보를 볼수 있는 쿼리는 다음과 같음.

 //WMI ~~
            using (System.Management.ManagementObjectSearcher s = new System.Management.ManagementObjectSearcher())
            {
                s.Query = new System.Management.ObjectQuery(
@"SELECT * FROM Meta_Class WHERE __Class LIKE ""%Win32%"" ");

                //s.Query = new System.Management.ObjectQuery(@"SELECT * FROM Win32_Process WHERE NAME = ""NateOnMain.exe"" ");
                //s.Query = new System.Management.ObjectQuery("Select * from Win32_Processor");
                //Win32_Processor
                var k = s.Get();
                foreach (var M in k)
                {
                    foreach (var Q in M.Qualifiers)
                    {
                        string text = string.Format(
                              "Q}} Name:{0}, Value:{1}",
                              Q.Name,
                              Q.Value
                          );
                        this.textBox1.AppendText(text + Environment.NewLine);
                    }

                    foreach (var P in M.Properties)
                    {
                        string text = string.Format(
                            "P}} Name:{0}, Value:{1}",
                            P.Name,
                            P.Value
                        );

                        this.textBox1.AppendText(text + Environment.NewLine);
                    }

                    this.textBox1.AppendText(
                        Environment.NewLine
                        );
                }
            }


위처럼 하면 쿼리 할수 있는 객체들로 나타나고.. 이를 바탕으로 정보를 쿼리 할 수 있음.

여기서 
 디스크 정보를 알고 싶을때 : Win32_LogicalDisk  관련 객체를 위 쿼리결과에서 찾아보고

파라미터명으로 GetPropertyValue를 통해서 값을 취할수 있다. 

  s.Query = new System.Management.ObjectQuery("Select * from Win32_LogicalDisk");
                var k = s.Get();
                foreach (var M in k)
                {
                    this.textBox1.AppendText("> " + M.GetPropertyValue("Caption") + Environment.NewLine);
                    this.textBox1.AppendText(
                        Environment.NewLine
                        );
                }

> \\DOKEBI-PC\ROOT\cimv2:Win32_LogicalDisk
Q} Name:dynamic, Value:True
Q} Name:Locale, Value:1033
Q} Name:provider, Value:CIMWin32
Q} Name:SupportsUpdate, Value:True
Q} Name:UUID, Value:{8502C4B7-5FBB-11D2-AAC1-006008C78BC7}
P} Name:Access, Value:
P} Name:Availability, Value:
P} Name:BlockSize, Value:
P} Name:Caption, Value:
P} Name:Compressed, Value:
P} Name:ConfigManagerErrorCode, Value:
P} Name:ConfigManagerUserConfig, Value:
P} Name:CreationClassName, Value:
P} Name:Description, Value:
P} Name:DeviceID, Value:
P} Name:DriveType, Value:
P} Name:ErrorCleared, Value:
P} Name:ErrorDescription, Value:
P} Name:ErrorMethodology, Value:
P} Name:FileSystem, Value:
P} Name:FreeSpace, Value:
P} Name:InstallDate, Value:
P} Name:LastErrorCode, Value:
P} Name:MaximumComponentLength, Value:
P} Name:MediaType, Value:
P} Name:Name, Value:
P} Name:NumberOfBlocks, Value:
P} Name:PNPDeviceID, Value:
P} Name:PowerManagementCapabilities, Value:
P} Name:PowerManagementSupported, Value:
P} Name:ProviderName, Value:
P} Name:Purpose, Value:
P} Name:QuotasDisabled, Value:
P} Name:QuotasIncomplete, Value:
P} Name:QuotasRebuilding, Value:
P} Name:Size, Value:
P} Name:Status, Value:
P} Name:StatusInfo, Value:
P} Name:SupportsDiskQuotas, Value:
P} Name:SupportsFileBasedCompression, Value:
P} Name:SystemCreationClassName, Value:
P} Name:SystemName, Value:
P} Name:VolumeDirty, Value:
P} Name:VolumeName, Value:
P} Name:VolumeSerialNumber, Value:


'# 3) .Net ( Vs 2008 ) > C#' 카테고리의 다른 글

컨텐츠 판넬 이전/ 다음 구현..  (0) 2011.09.14
Vs2008] 성능 카운터  (0) 2011.08.16
노트북 셋팅..  (0) 2011.08.02
[LINQ] group by 여러조건 넣기.  (0) 2010.11.08
MS-Chart Demo  (0) 2010.11.05