| Author |
Message |
francoiste
Joined: 03 Dec 2011 Posts: 5
|
Posted: Sat Dec 03, 2011 1:21 pm Post subject: request for pdh.dll |
|
|
this is a request for pdh.dll
i searched through all of the web.
and nowhere i'm able to find a working example for PdhLookupPerfNameByIndex getting invoked from csharp.
cheers, francoiste |
|
| Back to top |
|
 |
Brian Donahue
Joined: 23 Aug 2004 Posts: 6344 Location: Red Gate Software
|
Posted: Mon Dec 05, 2011 10:42 am Post subject: |
|
|
Hello,
As a PInvoke wiki administrator, I can add the pdh module to the list of modules, but someone is going to have to contribute a signature for the PdhLookupPerfNameByIndex method. Any takers? _________________ Brian Donahue
Technical Support
Red Gate Software Ltd.
44 (0)870 160 0037 ext 8521
US and CAN 1-866-RED GATE ext 8521 |
|
| Back to top |
|
 |
francoiste
Joined: 03 Dec 2011 Posts: 5
|
Posted: Mon Dec 05, 2011 11:30 am Post subject: |
|
|
thanks, brian!
regarding the native signature:
the requested method PdhLookupPerfNameByIndex and all related Pdh* methods are documented here:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa372648%28v=vs.85%29.aspx
so you can maybe get it from there?
as mentioned earlier. i tried various approaches but never got it running. so i'm hoping to get the PDH modules added to the PInvoke wiki - maybe someone will also post a working example. |
|
| Back to top |
|
 |
francoiste
Joined: 03 Dec 2011 Posts: 5
|
Posted: Tue Dec 06, 2011 4:23 pm Post subject: |
|
|
just wanted to share with everyone: in the meantime i got it working
1) native signature
| Code: |
PDH_STATUS PdhLookupPerfNameByIndex(
__in LPCTSTR szMachineName,
__in DWORD dwNameIndex,
__out LPTSTR szNameBuffer,
__in LPDWORD pcchNameBufferSize
); |
2) pinvoke
| Code: |
[DllImport( "pdh.dll", SetLastError = true, CharSet = CharSet.Unicode )]
public static extern UInt32 PdhLookupPerfNameByIndex(string szMachineName, uint dwNameIndex, StringBuilder szNameBuffer, ref uint pcchNameBufferSize);
|
3) example
| Code: |
const uint iProcessorQueueLength = 44;
StringBuilder buffer = new StringBuilder(1024);
uint bufSize = (uint)buffer.Capacity;
UInt32 iRet = 0;
iRet = PdhLookupPerfNameByIndex(null, iProcessorQueueLength, buffer, ref bufSize);
Console.WriteLine(buffer.ToString());
|
|
|
| Back to top |
|
 |
francoiste
Joined: 03 Dec 2011 Posts: 5
|
Posted: Wed Aug 01, 2012 5:28 pm Post subject: |
|
|
as i just figured out how this wiki works i went ahead and added the signature myself.
thanks again, francoiste |
|
| Back to top |
|
 |
|
|
All times are GMT + 1 Hour
|
| Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group