lxn / win

A Windows API wrapper package for the Go Programming Language
Other
1.19k stars 312 forks source link

The Non English windows will report error in this function but the performance counter work will #94

Open wawa0210 opened 4 years ago

wawa0210 commented 4 years ago

https://github.com/lxn/win/blob/24c5960b03d885e4fb67113029e0afe2e0d23db0/pdh.go#L432

I have encountered a very strange problem with the performance counter in the French operating system. When I use the PdhValidatePath method to check if the key is reasonable, the system reports an error, but the performance data returns normally.

I note the same key on English is \Network Adapter(*)\Packets Sent/sec and the same key on French windows is \Interface réseau(*)\Paquets/s

Performance monitoring data can be obtained using both keys, but PdhValidatePath reports an error. Errcode is that

0xC0000BC0 (PDH_CSTATUS_BAD_COUNTERNAME) | Unable to parse the counter path. Check the format and syntax of the specified path.

I checked the msdn documentation and found that they did not use PdhValidatePath in their official sample.

https://docs.microsoft.com/en-us/windows/win32/perfctrs/browsing-performance-counters

I hope that you can help me to give pointers on the best practices of pdh in non-English environments.

image

cbwest3 commented 1 year ago

@wawa0210, will https://github.com/lxn/win/pull/126 help?