Red Gate forums :: View topic - request for pdh.dll
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
PInvoke.Net
PInvoke.Net forum

request for pdh.dll

Search in PInvoke.Net forum
Post new topic   Reply to topic
Jump to:  
Author Message
francoiste



Joined: 03 Dec 2011
Posts: 5

PostPosted: Sat Dec 03, 2011 1:21 pm    Post subject: request for pdh.dll Reply with quote

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
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6677

PostPosted: Mon Dec 05, 2011 10:42 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
francoiste



Joined: 03 Dec 2011
Posts: 5

PostPosted: Mon Dec 05, 2011 11:30 am    Post subject: Reply with quote

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
View user's profile Send private message
francoiste



Joined: 03 Dec 2011
Posts: 5

PostPosted: Tue Dec 06, 2011 4:23 pm    Post subject: Reply with quote

just wanted to share with everyone: in the meantime i got it working Smile

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
View user's profile Send private message
francoiste



Joined: 03 Dec 2011
Posts: 5

PostPosted: Wed Aug 01, 2012 5:28 pm    Post subject: Reply with quote

as i just figured out how this wiki works i went ahead and added the signature myself.

thanks again, francoiste
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic 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