Performance Counter CustomActions

PerfCounter元素能够让你利用Windows API注册自己的性能计数器。这里有几个部分一起使用来完成注册:

Your performance DLL -
DLL必须输出Open, Collect, 和 Close 方法。更多细节请参考MSDN。

Performance registry values -
注册表必须包含键值指向你的DLL及其Open, Collect, and Close方法。这些键值由Registry元素创建。

Perfmon INI and H text files -
这些文件包含显示于界面的文字描述。更多细节请参考MSDN。

The RegisterPerfmon custom action -
你可以链接sca.wixlib来确保在MSI中包含定制功能。定制功能调用(Un)LoadPerfCounterTextStrings来注册你的计数器。为了调用自定义功能,在Perfmon.INI文件File元素里创建PerfCounter元素。PerfCounter元素包含唯一一个属性:Name,Name属性应该与注册表、WIX源文件 fragment节和PerfCounter.ini文件中的名称匹配。

<?xml version="1.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <DirectoryRef Id="BinDir">
      <Component Id="SharedNative" DiskId="1">
 
        <Registry Id="Shared_r1" Root="HKLM" Key="SYSTEM/CurrentControlSet/Services/MyApplication/Performance" Name="Open" Value="OpenPerformanceData" Type="string" />
        <Registry Id="Shared_r2" Root="HKLM" Key="SYSTEM/CurrentControlSet/Services/MyApplication/Performance" Name="Collect" Value="CollectPerformanceData" Type="string" />
        <Registry Id="Shared_r3" Root="HKLM" Key="SYSTEM/CurrentControlSet/Services/MyApplication/Performance" Name="Close" Value="ClosePerformanceData" Type="string" />
        <Registry Id="Shared_r4" Root="HKLM" Key="SYSTEM/CurrentControlSet/Services/MyApplication/Performance" Name="Library" Value="[!PERFDLL.DLL]" Type="string" />
 
       <File Id="PERFDLL.DLL" Name="MyPerfDll.dll" src="x86/debug/0/myperfdll.dll" />
 
       <File Id="PERFCOUNTERS.H" Name="PerfCounters.h" src="x86/debug/0/perfcounters.h" />
       <File Id="PERFCOUNTERS.INI" Name="PerfCounters.ini" src="x86/debug/0/perfcounters.ini" >
          <PerfCounter Name="MyApplication" />
       </File>
 
      </Component>
    </DirectoryRef>
  </Fragment>
</Wix>


--------------------------------------------------------------------------------

Sample PerfCounters.ini:
[info]
drivername=MyApplication
symbolfile=PerfCounters.h
 
[languages]
009=English
004=Chinese
 
[objects]
PERF_OBJECT_1_009_NAME=Performance object name
PERF_OBJECT_1_004_NAME=Performance object name in Chinese
 
[text] 
OBJECT_1_009_NAME=Name of the device
OBJECT_1_009_HELP=Displays performance statistics of the device
OBJECT_1_004_NAME=Name of the device in Chinese
OBJECT_1_004_HELP=Displays performance statistics of the device in Chinese
 
DEVICE_COUNTER_1_009_NAME=Name of first counter
DEVICE_COUNTER_1_009_HELP=Displays the current value of the first counter
DEVICE_COUNTER_1_004_NAME=Name of the first counter in Chinese
DEVICE_COUNTER_1_004_HELP=Displays the value of the first counter in Chinese
 
DEVICE_COUNTER_2_009_NAME=Name of the second counter
DEVICE_COUNTER_2_009_HELP=Displays the current rate of the second counter
DEVICE_COUNTER_2_004_NAME=Name of the second counter in Chinese
DEVICE_COUNTER_2_004_HELP=Displays the rate of the second counter in Chinese
 
PERF_OBJECT_1_009_NAME=Name of the third counter
PERF_OBJECT_1_009_HELP=Displays the current rate of the third counter
PERF_OBJECT_1_004_NAME=Name of the third counter in Chinese
PERF_OBJECT_1_004_HELP=Displays the rate of the third counter in Chinese
Sample PerfCounters.h:
#define OBJECT_1    0
#define DEVICE_COUNTER_1    2
#define DEVICE_COUNTER_2    4
#define PERF_OBJECT_1    8

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值