PurifyNewHandlesInuse example

//Note: This program assumes that a file called foo

//is located in the current directory.

#include <windows.h>

#include "pure.h"

 

void main()

{

   HANDLE  hFile;

   hFile = CreateFile("foo", GENERIC_READ, FILE_SHARE_READ, 0,

         OPEN_EXISTING, 0, 0);

 

   if (hFile != INVALID_HANDLE_VALUE) {

      PurifyPrintf("Look for handles after CreateFile()");

      PurifyNewHandlesInuse();

      CloseHandle(hFile);

      PurifyPrintf("Look for handles after CloseHandle()");

      PurifyNewHandlesInuse();

   }

   PurifyPrintf("Automatically search for handles and leaks at

         the end of a program");

}

(C) Copyright IBM Corporation 1992, 2010.