request for pdh.dll

Announcements and discussion for PInvoke

Moderators: Luke Jefferson, Robert

request for pdh.dll

Postby francoiste » Sat Dec 03, 2011 1:21 pm

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
francoiste
 
Posts: 5
Joined: Sat Dec 03, 2011 1:17 pm

Postby Brian Donahue » Mon Dec 05, 2011 10:42 am

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
 
Posts: 6669
Joined: Mon Aug 23, 2004 10:48 am

Postby francoiste » Mon Dec 05, 2011 11:30 am

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 ... 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.
francoiste
 
Posts: 5
Joined: Sat Dec 03, 2011 1:17 pm

Postby francoiste » Tue Dec 06, 2011 4:23 pm

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

1) native signature

Code: Select all
PDH_STATUS PdhLookupPerfNameByIndex(
  __in   LPCTSTR szMachineName,
  __in   DWORD dwNameIndex,
  __out  LPTSTR szNameBuffer,
  __in   LPDWORD pcchNameBufferSize
);


2) pinvoke

Code: Select all
[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: Select all
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());
francoiste
 
Posts: 5
Joined: Sat Dec 03, 2011 1:17 pm

Postby francoiste » Wed Aug 01, 2012 5:28 pm

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

thanks again, francoiste
francoiste
 
Posts: 5
Joined: Sat Dec 03, 2011 1:17 pm


Return to PInvoke.Net

Who is online

Users browsing this forum: No registered users and 0 guests

cron