Changeset 77


Ignore:
Timestamp:
Jul 14, 2006, 2:37:00 AM (18 years ago)
Author:
mayuki
Message:

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

Location:
trunk
Files:
2 added
3 edited

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"
Note: See TracChangeset for help on using the changeset viewer.