COMMON.H
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:2k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  2. /*                  Copyright Microsoft Corp. 1992-1996                 */
  3. /*                      Remote Machine pipe sample                      */
  4. /*                                                                      */
  5. /*  FILE    :   common.h                                                */
  6. /*                                                                      */
  7. /*  PURPOSE :   Definitions used in the program                         */
  8. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  9. #ifndef __COMMON_PIPE_SAMPLE__      // If this file has be included before  
  10. #define __COMMON_PIPE_SAMPLE__      // Don't include it again
  11. #include <shellapi.h>               // CommandLineToArgvw is defined here
  12. #include <tchar.h>                  // Included to support UNICODE/ANSI
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. // Common type definition and defines used in the program
  16. // Return values from the program to the OS
  17. #define EXECUTION_FAILED    -1
  18. #define EXECUTION_OK        0
  19. // Exception handler macro
  20. #define DO_EXCEPTION        1       // Execute the exception block
  21. #define SCRAMBLE    1               // Action to take - Encode the file
  22. #define UNSCRAMBLE  2               // Action to take - Decode the file
  23. #define PROTOCOL_SEQUENCE   TEXT("ncacn_np")
  24. #define END_POINT           TEXT("\pipe\pipe_sample")
  25. // This struct is used by the client to keep track of the state
  26. typedef struct {
  27.     FILE        *hOld;          // Handle to the old file
  28.     FILE        *hNew;          // Handle to the new file
  29.     _TUCHAR     *pszOldName;       // Name of the old file
  30.     _TUCHAR     *pszNewName;       // Name of the new file
  31. } pipe_state;
  32. // Macro for printing out error message and exit the program if an 
  33. // error occured
  34. #define EXIT_IF_FAIL(x, string){   
  35.     ((x) != RPC_S_OK)?_tprintf(TEXT("%s returned with error: %dn"), 
  36.     TEXT(string), (x)),exit(x):0;} 
  37. #endif  //  __COMMON_PIPE_SAMPLE__