View GDI handles/resources list and detect GDI leaks

View GDI handles/resources list and detect GDI leaks

Postby Antonio Linares » Tue Jul 30, 2013 4:14 pm

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41289
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: View GDI handles/resources list and detect GDI leaks

Postby Antonio Linares » Tue Jul 30, 2013 4:59 pm

Buscando he llegado hasta esto con código muy interesante :-)

http://drmemory.googlecode.com/svn/trunk/tests/handle.cpp

y desde ahi a su página:
https://code.google.com/p/drmemory/
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41289
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: View GDI handles/resources list and detect GDI leaks

Postby Antonio Linares » Tue Jul 30, 2013 5:51 pm

I was curious to know how they get such info, so I started googling and it seems as first of all we need to identify the running processes. Here you can test it from FWH :-)

Code: Select all  Expand view
#include "FiveWin.ch"

//----------------------------------------------------------------------------//

function Main()

   local oWnd

   DEFINE WINDOW oWnd TITLE "Right click me"

   ACTIVATE WINDOW oWnd ;
      ON RIGHT CLICK XBrowse( GetProcesses(), "Processes" )

return nil

//----------------------------------------------------------------------------//

#pragma BEGINDUMP

#include <windows.h>
#include <tlhelp32.h>
#include <hbapi.h>
#include <hbapiitm.h>

HB_FUNC( GETPROCESSES )
{
   HANDLE hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPALL, 0 );
   HANDLE hProcess;
   PROCESSENTRY32 pe;
   PHB_ITEM pProcesses = hb_itemArrayNew( 0 );
   PHB_ITEM pProcess = hb_itemNew( NULL );
   
   pe.dwSize = sizeof( pe );
   Process32First( hSnapshot, &pe );
   
   do
   {
      hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pe.th32ProcessID );

      hb_arrayNew( pProcess, 2 );
      hb_arraySetNLL( pProcess, 1, pe.th32ProcessID );
      hb_arraySetC( pProcess, 2, pe.szExeFile );
      hb_arrayAddForward( pProcesses, pProcess );
     
   } while( Process32Next( hSnapshot, &pe ) );
   
   hb_itemRelease( pProcess );
   hb_itemReturnRelease( pProcesses );
   
   CloseHandle( hProcess );
   CloseHandle( hSnapshot );
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41289
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: View GDI handles/resources list and detect GDI leaks

Postby Antonio Linares » Tue Jul 30, 2013 6:02 pm

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41289
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: View GDI handles/resources list and detect GDI leaks

Postby Antonio Linares » Tue Jul 30, 2013 6:05 pm

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41289
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to Utilities / Utilidades

Who is online

Users browsing this forum: No registered users and 7 guests