Open oliveagle opened 9 years ago
/*
typedef long LONG;
typedef unsigned long DWORD;
typedef struct _PDH_FMT_COUNTERVALUE_DOUBLE
{
DWORD CStatus;
double DoubleValue;
}PDH_FMT_COUNTERVALUE_DOUBLE;
*/
import "C"
this struct will be better
That's weird. When I created the code (+ the example in the comments) it worked fine. When I try it right now myself, I also get garbled data.
I'm also running into this using \System\System Up Time
on all of the types. Using the CGo double struct that @oliveagle proposed seems to be working fine. Perhaps Go structs no longer line up correctly with Windows C structs or it is also possible that this only worked/works correctly with 32bit as I'm running into the problem on 64bit.
Code above will get processes count of windows. which usually in my system is around 60
but with
pdh.go
version I always get meaningless data. here is my code:here is the output![qq20150211-1](https://cloud.githubusercontent.com/assets/2270205/6143196/6ac3fddc-b1ff-11e4-984e-c239cd27846f.png)
after some dig on this. I found out a solution:
pass in a c struct instead of go struct
here is the code:
I checked these counters they all give me correct data