Changeset 77

Show
Ignore:
Timestamp:
07/14/06 02:37:00 (2 years ago)
Author:
mayuki
Message:

パフォーマンスカウンタを何故か利用できない Windows2000 でも動くように場当たり的ながら修正 (closes #1)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/MacFaceFloat/MacFaceApp.cs

    r75 r77  
    4949                } 
    5050 
     51                /// <summary> 
     52                /// Windows 2000 �̓p�t�H�[�}���X���j�^���_���Ȃ炻�ꂼ��I�ł����              /// </summary> 
     53                public void SetupStatisticsForWindows2000() 
     54                { 
     55                        cpuStats = new CPUStatistics(81); 
     56                        memStats = new MemoryStatistics(81); 
     57 
     58                        try  
     59                        { 
     60                                // �����ɃJ�E���^��s���Ă݂�                               cpuStats.Update(); 
     61                                memStats.Update(); 
     62                        }  
     63                        catch (System.ComponentModel.Win32Exception)  
     64                        { 
     65                                // �_��������̂Ńp�t�H�[�}���X�J�E���^������� 
     66                                cpuStats = new CPUStatisticsNtQuerySystemInformation(61); 
     67                                memStats = new MemoryStatisticsGlobalMemoryStatusEx(61); 
     68                        } 
     69                        catch (System.InvalidOperationException)  
     70                        { 
     71                                // �_��������̂Ńp�t�H�[�}���X�J�E���^������� 
     72                                cpuStats = new CPUStatisticsNtQuerySystemInformation(61); 
     73                                memStats = new MemoryStatisticsGlobalMemoryStatusEx(61); 
     74                        } 
     75                } 
     76 
     77                public void SetupStatisticsForWindowsXP() 
     78                { 
     79                        cpuStats = new CPUStatistics(81); 
     80                        memStats = new MemoryStatistics(81); 
     81                        try  
     82                        { 
     83                                // �����ɃJ�E���^��s���Ă݂�                               cpuStats.Update(); 
     84                                memStats.Update(); 
     85                        }  
     86                        catch (System.ComponentModel.Win32Exception)  
     87                        { 
     88                                // �_��������̂Ńp�t�H�[�}���X�J�E���^������� 
     89                                cpuStats = new CPUStatisticsGetSystemTime(61); 
     90                                memStats = new MemoryStatisticsPSAPI(61); 
     91                        } 
     92                        catch (System.InvalidOperationException)  
     93                        { 
     94                                // �_��������̂Ńp�t�H�[�}���X�J�E���^������� 
     95                                cpuStats = new CPUStatisticsGetSystemTime(61); 
     96                                memStats = new MemoryStatisticsPSAPI(61); 
     97                        } 
     98                } 
     99 
    51100                public MacFaceApp() 
    52101                { 
     
    54103                        config.Load(); 
    55104                         
    56                         cpuStats = new CPUStatistics(81); 
    57                         memStats = new MemoryStatistics(81); 
    58105                        pageio_count = 0; 
    59                         // XXX: �Ώ����A�������Ȃ̂�Ƃ�����                 try  
    60                         { 
    61                                // �����ɃJ�E���^��s���Ă݂�                               cpuStats.Update(); 
    62                         }  
    63                         catch (System.ComponentModel.Win32Exception e)  
    64                         { 
    65                                // �_��������̂Ńp�t�H�[�}���X�J�E���^������� 
    66                                 cpuStats = new CPUStatisticsGetSystemTime(61); 
    67                                 memStats = new MemoryStatisticsPSAPI(61); 
     106 
     107                        // OS ���ƂɎ擾�����@��X����                      if (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 0) 
     108                        { 
     109                               SetupStatisticsForWindows2000(); 
     110                        } 
     111                        else 
     112                        { 
     113                                // XP / 2003 / Vista 
     114                                SetupStatisticsForWindowsXP(); 
    68115                        } 
    69116 
  • trunk/MacFaceLibrary/CPUStatisticsGetSystemTime.cs

    r73 r77  
    66{ 
    77        /// <summary> 
    8         /// CPUStatisticsGetSystemTime nngY 
     8        /// CPUStatisticsGetSystemTime 
    99        /// </summary> 
    1010        public class CPUStatisticsGetSystemTime : CPUStatistics 
  • trunk/MacFaceLibrary/MacFaceLibrary.csproj

    r73 r77  
    110110                /> 
    111111                <File 
     112                    RelPath = "CPUStatisticsNtQuerySystemInformation.cs" 
     113                    SubType = "Code" 
     114                    BuildAction = "Compile" 
     115                /> 
     116                <File 
    112117                    RelPath = "CPUUsage.cs" 
    113118                    SubType = "Code" 
     
    126131                <File 
    127132                    RelPath = "MemoryStatistics.cs" 
     133                    SubType = "Code" 
     134                    BuildAction = "Compile" 
     135                /> 
     136                <File 
     137                    RelPath = "MemoryStatisticsGlobalMemoryStatusEx.cs" 
    128138                    SubType = "Code" 
    129139                    BuildAction = "Compile"