EVRYTHNG.H

#ifndef _NOEXCLUSIONS
#include "Exclude.h" /* Define Preprocessor variables to */
/* exclude un-wanted header files. */
#endif
#include "envirmnt.h"
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <io.h>
#include "support.h"
#ifdef _MT
#include <process.h>
#endif
/* DWORD_PTR (pointer precision unsigned integer) is used for integers
* that are converted to handles or pointers
* This eliminates Win64 warnings regarding conversion between
* 32 and 64-bit data, as HANDLEs and pointers are 64 bits in
* Win64 (See Chapter 16). This is enable only if _Wp64 is defined.
*/
#if !defined(_Wp64)
#define DWORD_PTR DWORD
#define LONG_PTR LONG
#define INT_PTR INT
#endif[/code]


ENVIRMNT.H
[code]
/* environment.h define UNICODE and _STATICLIB, if required */
#define _WIN32_WINNT 0x0500 /* Enable use of NT 5 (XP, 2000, 2003) functions */
//#define UNICODE

/* It is best and easiest to define UNICODE within the project. */
/* Use Project...Settings...C/C++. Then, down in the "Project Options */
/* window on the bottom, add /D "UNICODE" */
/* The same is true for DLLLIB */
//#define UNICODE
//#undef UNICODE

#ifdef UNICODE
#define _UNICODE
#endif
#ifndef UNICODE
#undef _UNICODE
#endif
#define LANG_DFLT LANG_ENGLISH
#define SUBLANG_DFLT SUBLANG_ENGLISH_US

/* Define _MT when running in a threaded environment
Better Alternative: Set from the
Project...Settings...C/C++...CodeGeneration category . */
//#define _MT

/* Define UTILITY_EXPORTS only if you build a DLL. */
/* It is best and easiest to define _DLLLIB within the project. */
/* Use Project...Settings...C/C++. Then, down in the "Project Options */
/* window on the bottom, add /D "UTILITY_EXPORTS" */
//#undef UTILITY_EXPORTS
//#define UTILITY_EXPORTS
/* Define _STATICLIB if you are building a static library
or if you are linking with static libaries.
Undefine if you are builing a DLL or linking with a DLL. */
/* Again, it is best and easiest to define this in the project */
//#define _STATICLIB
//#undef _STATICLIB

//#define STRICT
[/code]

EXCLUDE.H
[code]
/* Exclude.h - Define variables to exclude selected header files.
For complete explanation, see Rector & Newcomer, Win32 Programming, pp 25ff. */

#define WIN32_LEAN_AND_MEAN
/* This has the largest impact, halving the pch file size. */

/* These definitions also reduce the pch and improve compiling time.
All the programs in the book will still compile with these definitions.
You can also eliminate, for example, security with #define NOSECURITY. */
#define NOATOM
#define NOCLIPBOARD
#define NOCOMM
#define NOCTLMGR
#define NOCOLOR
#define NODEFERWINDOWPOS
#define NODESKTOP
#define NODRAWTEXT
#define NOEXTAPI
#define NOGDICAPMASKS
#define NOHELP
#define NOICONS
#define NOTIME
#define NOIMM
#define NOKANJI
#define NOKERNEL
#define NOKEYSTATES
#define NOMCX
#define NOMEMMGR
#define NOMENUS
#define NOMETAFILE
#define NOMSG
#define NONCMESSAGES
#define NOPROFILER
#define NORASTEROPS
#define NORESOURCE
#define NOSCROLL
//#define NOSERVICE /* Windows NT Services */
#define NOSHOWWINDOW
#define NOSOUND
#define NOSYSCOMMANDS
#define NOSYSMETRICS
#define NOSYSPARAMS
#define NOTEXTMETRIC
#define NOVIRTUALKEYCODES
#define NOWH
#define NOWINDOWSTATION
#define NOWINMESSAGES
#define NOWINOFFSETS
#define NOWINSTYLES
#define OEMRESOURCE
[/code]

support.h
[code]
/* support.h */
/* Definitions of all symbolic constants and common
utility functions used throughout the example programs. */

/* Define the LIBSPEC modifier for function names and other imported/exported
* symblols. This is only required when building for Win32; you wouldn't
* need this under, for example, UNIX/Linux. The following #ifdef is
* redundant (we're only building for Win32), but it's a good habit in case
* you need to build portable code in the future
*/
#ifdef WIN32
/* When building a static library, the only modifier needed is
extern "C" when calling from a C++ program */
#ifdef _STATICLIB
#if defined (__cplusplus)
#define LIBSPEC extern "C"
#else
#define LIBSPEC
#endif /* __cplusplus */
#endif /* _STATICLIB */

/* Not building a static library.
* Either export or import symbols (function names), depending upon whether we
* are building the DLL (UTILITY_EXPORTS is defined) or importing
* the names from a "client" calling program. A C++ client needs extern "C"
* to use the C (rather than C++) calling convention and to avoid
* C++ "name decoration" (often called "name mangling").
*/
#if defined(UTILITY_3_0_EXPORTS)
#define LIBSPEC _declspec (dllexport)
#elif defined(__cplusplus)
#define LIBSPEC extern "C" _declspec (dllimport)
#else
#define LIBSPEC _declspec (dllimport)
#endif

#endif /* end of #ifdef WIN32 */

#define EMPTY _T ("")
#define YES _T ("y")
#define NO _T ("n")
#define CR 0x0D
#define LF 0x0A
#define TSIZE sizeof (TCHAR)

/* Limits and constants. */

#define TYPE_FILE 1 /* Used in ls, rm, and lsFP */
#define TYPE_DIR 2
#define TYPE_DOT 3

#define MAX_OPTIONS 20 /* Max # command line options */
#define MAX_ARG 1000 /* Max # of command line arguments */
#define MAX_COMMAND_LINE MAX_PATH+50 /* Max size of a command line */
#define MAX_NAME 256 /* Name length - users and groups */

/* Commonly used functions. */

LIBSPEC BOOL ConsolePrompt (LPCTSTR, LPTSTR, DWORD, BOOL);
LIBSPEC BOOL PrintStrings (HANDLE, ...);
LIBSPEC BOOL PrintMsg (HANDLE, LPCTSTR);
LIBSPEC VOID ReportError (LPCTSTR, DWORD, BOOL);
LIBSPEC VOID ReportException (LPCTSTR, DWORD);
LIBSPEC DWORD Options (int, LPCTSTR *, LPCTSTR, ...);
LIBSPEC LPTSTR SkipArg (LPCTSTR);
LIBSPEC BOOL WindowsVersionOK (DWORD, DWORD);
/* Collection of generic string functions modeled after string.h.
Created as required - there was only one!
Implementations are derived from Plauger: The Standard C Library. */

LIBSPEC LPCTSTR wmemchr (LPCTSTR, TCHAR, DWORD);
LIBSPEC VOID GetArgs (LPCTSTR, int *, LPTSTR *);

/* Security Functions. */

LPSECURITY_ATTRIBUTES InitializeUnixSA (DWORD, LPTSTR, LPTSTR, LPDWORD, LPDWORD, LPHANDLE);
LPSECURITY_ATTRIBUTES InitializeAccessOnlySA (DWORD, LPTSTR, LPTSTR, LPDWORD, LPHANDLE);
DWORD ReadFilePermissions (LPTSTR, LPTSTR, LPTSTR);
BOOL ChangeFilePermissions (DWORD, LPTSTR, LPDWORD, LPDWORD);
/* Simpler forms available with Visual C++ Version 5.0 */
//PSECURITY_DESCRIPTOR InitializeSD (DWORD, LPTSTR, LPTSTR, LPDWORD);
/* Constants needed by the security functions. */

#define LUSIZE 1024
#define ACCT_NAME_SIZE LUSIZE

#ifdef _UNICODE /* This declaration had to be added. */
#define _tstrrchr wcsrchr
#else
#define _tstrrchr strrchr
#endif

#ifdef _UNICODE /* This declaration had to be added. */
#define _tstrstr wcsstr
#else
#define _tstrstr strstr
#endif

#ifdef _UNICODE /* This declaration had to be added. */
#define _memtchr wmemchr
#else
#define _memtchr memchr
#endif

/*
* Define a macro that delays for an amount of time proportional
* to the integer parameter. The delay is a CPU delay and does not
* voluntarily yield the processor. This simulates computation.
*/

#define delay_cpu(n) {\
int i=0, j=0;\
/* Do some wasteful computations that will not be optimized to nothing */\
while (i < n) {\
j = (int)(i*i + (float)(2*j)/(float)(i+1));\
i++;\
}\
}

posted on 2013-05-20 17:53  wolflion  阅读(493)  评论(0编辑  收藏  举报

导航