#ifndef _COMMON_SNAPSHOT_HPP_
#define _COMMON_SNAPSHOT_HPP_
#ifndef _COMMON_VERSIONINFO_HPP_
#include <common/version.hpp>
#endif
#ifndef _COMMON_LIBRARY_HPP_
#include <common/library.hpp>
#endif
#ifndef _COMMON_PROCESSENTRY_HPP_
#include <common/pentry.hpp>
#endif

class Snapshot
{
public:
  enum SnapshotFlags{Inherit=TH32CS_INHERIT,SnapAll=TH32CS_SNAPALL,SnapHeapList=TH32CS_SNAPHEAPLIST,SnapModule=TH32CS_SNAPMODULE,SnapProcess=TH32CS_SNAPPROCESS,SnapThread=TH32CS_SNAPTHREAD};
  Snapshot(void);
	virtual ~Snapshot();
	BOOL create(SnapshotFlags snapshot,DWORD processID=0);
	BOOL process32First(ProcessEntry &processEntry);
	BOOL process32Next(ProcessEntry &processEntry);
	void destroy(void);
	BOOL isOkay(void)const;
private:
  typedef HANDLE (PASCAL *PFNCREATETOOLHELP32SNAPSHOT)(DWORD dwFlags,DWORD th32ProcessID);
	typedef BOOL (PASCAL *PFNPROCESS32FIRST)(HANDLE hSnapshot,LPPROCESSENTRY32 lppe);
	typedef BOOL (PASCAL *PFNPROCESS32NEXT)(HANDLE hSnapshot,LPPROCESSENTRY32 lppe);
  Snapshot(const Snapshot &snapshot);
	Snapshot &operator=(const Snapshot &snapshot);
	BOOL initialize(void);

  Library mKernelLib;
	HANDLE mhSnapshot;
	PFNCREATETOOLHELP32SNAPSHOT mpfnCreateToolhelp32Snapshot;
	PFNPROCESS32FIRST mpfnProcess32First;
	PFNPROCESS32NEXT mpfnProcess32Next;
};
#endif