Changeset 77

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

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

Location:
trunk
Files:
2 added
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/MacFaceFloat/MacFaceApp.cs

    r75 r77  
    4949                } 
    5050 
     51                /// <summary> 
     52                /// Windows 2000 �̓p�t�H�[�}���X���j�^���_���Ȃ炻�ꂼ��API�ł���΂� 
     53                /// </summary> 
     54                public void SetupStatisticsForWindows2000() 
     55                { 
     56                        cpuStats = new CPUStatistics(81); 
     57                        memStats = new MemoryStatistics(81); 
     58 
     59                        try  
     60                        { 
     61                                // �����ɃJ�E���^����s���Ă݂� 
     62                                cpuStats.Update(); 
     63                                memStats.Update(); 
     64                        }  
     65                        catch (System.ComponentModel.Win32Exception)  
     66                        { 
     67                                // �_���������̂Ńp�t�H�[�}���X�J�E���^��g��Ȃ����@�� 
     68                                cpuStats = new CPUStatisticsNtQuerySystemInformation(61); 
     69                                memStats = new MemoryStatisticsGlobalMemoryStatusEx(61); 
     70                        } 
     71                        catch (System.InvalidOperationException)  
     72                        { 
     73                                // �_���������̂Ńp�t�H�[�}���X�J�E���^��g��Ȃ����@�� 
     74                                cpuStats = new CPUStatisticsNtQuerySystemInformation(61); 
     75                                memStats = new MemoryStatisticsGlobalMemoryStatusEx(61); 
     76                        } 
     77                } 
     78 
     79                public void SetupStatisticsForWindowsXP() 
     80                { 
     81                        cpuStats = new CPUStatistics(81); 
     82                        memStats = new MemoryStatistics(81); 
     83                        try  
     84                        { 
     85                                // �����ɃJ�E���^����s���Ă݂� 
     86                                cpuStats.Update(); 
     87                                memStats.Update(); 
     88                        }  
     89                        catch (System.ComponentModel.Win32Exception)  
     90                        { 
     91                                // �_���������̂Ńp�t�H�[�}���X�J�E���^��g��Ȃ����@�� 
     92                                cpuStats = new CPUStatisticsGetSystemTime(61); 
     93                                memStats = new MemoryStatisticsPSAPI(61); 
     94                        } 
     95                        catch (System.InvalidOperationException)  
     96                        { 
     97                                // �_���������̂Ńp�t�H�[�}���X�J�E���^��g��Ȃ����@�� 
     98                                cpuStats = new CPUStatisticsGetSystemTime(61); 
     99                                memStats = new MemoryStatisticsPSAPI(61); 
     100                        } 
     101                } 
     102 
    51103                public MacFaceApp() 
    52104                { 
     
    54106                        config.Load(); 
    55107                         
    56                         cpuStats = new CPUStatistics(81); 
    57                         memStats = new MemoryStatistics(81); 
    58108                        pageio_count = 0; 
    59                         // XXX: �Ώ����@���A�������Ȃ̂��Ƃ����� 
    60                         try  
    61                         { 
    62                                 // �����ɃJ�E���^����s���Ă݂� 
    63                                 cpuStats.Update(); 
    64                         }  
    65                         catch (System.ComponentModel.Win32Exception e)  
    66                         { 
    67                                 // �_���������̂Ńp�t�H�[�}���X�J�E���^��g��Ȃ����@�� 
    68                                 cpuStats = new CPUStatisticsGetSystemTime(61); 
    69                                 memStats = new MemoryStatisticsPSAPI(61); 
     109 
     110                        // OS ���ƂɎ擾������@��ύX���� 
     111                        if (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 0) 
     112                        { 
     113                                SetupStatisticsForWindows2000(); 
     114                        } 
     115                        else 
     116                        { 
     117                                // XP / 2003 / Vista 
     118                                SetupStatisticsForWindowsXP(); 
    70119                        } 
    71120 
  • 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"