00001 /* ///////////////////////////////////////////////////////////////////////// 00002 * File: winstl/toolhelp/process_sequence.hpp 00003 * 00004 * Purpose: TOOLHELP process sequence class. 00005 * 00006 * Created: 21st May 2005 00007 * Updated: 10th August 2009 00008 * 00009 * Thanks: To Pablo for contributing this great library. 00010 * 00011 * Home: http://stlsoft.org/ 00012 * 00013 * Copyright (c) 2005-2009, Pablo Aguilar 00014 * Copyright (c) 2006-2007, Matthew Wilson 00015 * All rights reserved. 00016 * 00017 * Redistribution and use in source and binary forms, with or without 00018 * modification, are permitted provided that the following conditions are met: 00019 * 00020 * - Redistributions of source code must retain the above copyright notice, this 00021 * list of conditions and the following disclaimer. 00022 * - Redistributions in binary form must reproduce the above copyright notice, 00023 * this list of conditions and the following disclaimer in the documentation 00024 * and/or other materials provided with the distribution. 00025 * - Neither the name(s) of Matthew Wilson and Synesis Software, nor Pablo 00026 * Aguilar, nor the names of any contributors may be used to endorse or 00027 * promote products derived from this software without specific prior written 00028 * permission. 00029 * 00030 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00031 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00032 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00033 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00034 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00035 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00036 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00037 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00038 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00039 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00040 * POSSIBILITY OF SUCH DAMAGE. 00041 * 00042 * ////////////////////////////////////////////////////////////////////// */ 00043 00044 00052 #ifndef WINSTL_INCL_WINSTL_TOOLHELP_HPP_PROCESS_SEQUENCE 00053 #define WINSTL_INCL_WINSTL_TOOLHELP_HPP_PROCESS_SEQUENCE 00054 00055 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION 00056 # define WINSTL_VER_WINSTL_TOOLHELP_HPP_PROCESS_SEQUENCE_MAJOR 1 00057 # define WINSTL_VER_WINSTL_TOOLHELP_HPP_PROCESS_SEQUENCE_MINOR 1 00058 # define WINSTL_VER_WINSTL_TOOLHELP_HPP_PROCESS_SEQUENCE_REVISION 1 00059 # define WINSTL_VER_WINSTL_TOOLHELP_HPP_PROCESS_SEQUENCE_EDIT 8 00060 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ 00061 00062 /* ///////////////////////////////////////////////////////////////////////// 00063 * Includes 00064 */ 00065 00066 #ifndef WINSTL_INCL_WINSTL_H_WINSTL 00067 # include <winstl/winstl.h> 00068 #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */ 00069 #ifdef STLSOFT_CF_PRAGMA_ONCE_SUPPORT 00070 # pragma once 00071 #endif /* STLSOFT_CF_PRAGMA_ONCE_SUPPORT */ 00072 #ifndef WINSTL_INCL_WINSTL_TOOLHELP_HPP_SEQUENCE_BASE 00073 # include <winstl/toolhelp/sequence_base.hpp> 00074 #endif /* !WINSTL_INCL_WINSTL_TOOLHELP_HPP_SEQUENCE_BASE */ 00075 00076 /* ///////////////////////////////////////////////////////////////////////// 00077 * Namespace 00078 */ 00079 00080 #ifndef _WINSTL_NO_NAMESPACE 00081 # if defined(_STLSOFT_NO_NAMESPACE) || \ 00082 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) 00083 /* There is no stlsoft namespace, so must define ::winstl */ 00084 namespace winstl 00085 { 00086 # else 00087 /* Define stlsoft::winstl_project */ 00088 00089 namespace stlsoft 00090 { 00091 00092 namespace winstl_project 00093 { 00094 00095 # endif /* _STLSOFT_NO_NAMESPACE */ 00096 #endif /* !_WINSTL_NO_NAMESPACE */ 00097 00098 /* ///////////////////////////////////////////////////////////////////////// 00099 * Classes 00100 */ 00101 00102 // th_sequence_value_traits specialization for process_sequence 00104 #define WINSTL_TH_API_SEQUENCE_VALUE_TRAITS_VALUE PROCESSENTRY32 00105 #define WINSTL_TH_API_SEQUENCE_VALUE_TRAITS_FIRST Process32First 00106 #define WINSTL_TH_API_SEQUENCE_VALUE_TRAITS_NEXT Process32Next 00107 #define WINSTL_TH_API_SEQUENCE_VALUE_TRAITS_FLAG TH32CS_SNAPPROCESS 00108 #define WINSTL_TH_API_SEQUENCE_VALUE_TRAITS_CREATE_SNAPSHOT_FAIL_MESSAGE TEXT("Could not create process list snapshot") 00109 #include <winstl/toolhelp/sequence_value_traits.hpp> 00110 00115 typedef th_sequence_base<PROCESSENTRY32> process_sequence; 00116 00123 inline DWORD get_pid(PROCESSENTRY32 const& pe) 00124 { 00125 return pe.th32ProcessID; 00126 } 00127 00128 /* ////////////////////////////////////////////////////////////////////// */ 00129 00130 #ifndef _WINSTL_NO_NAMESPACE 00131 # if defined(_STLSOFT_NO_NAMESPACE) || \ 00132 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) 00133 } // namespace winstl 00134 # else 00135 } // namespace winstl_project 00136 } // namespace stlsoft 00137 # endif /* _STLSOFT_NO_NAMESPACE */ 00138 #endif /* !_WINSTL_NO_NAMESPACE */ 00139 00140 /* ////////////////////////////////////////////////////////////////////// */ 00141 00142 #endif // WINSTL_INCL_WINSTL_TOOLHELP_HPP_PROCESS_SEQUENCE 00143 00144 /* ///////////////////////////// end of file //////////////////////////// */