Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.8 KiB

  1. //#pragma title( "QProcess.cpp - Query type of processor on machine" )
  2. /*
  3. Copyright (c) 1995-1998, Mission Critical Software, Inc. All rights reserved.
  4. ===============================================================================
  5. Module - QProcess.cpp
  6. System - Common
  7. Author - Rich Denham
  8. Created - 1996-11-21
  9. Description - Query type of processor on machine
  10. Updates -
  11. ===============================================================================
  12. */
  13. #include <stdio.h>
  14. #ifdef USE_STDAFX
  15. # include "stdafx.h"
  16. #else
  17. # include <windows.h>
  18. #endif
  19. #include "Common.hpp"
  20. #include "ErrDct.hpp"
  21. #include "UString.hpp"
  22. #include "TReg.hpp"
  23. #include "QProcess.hpp"
  24. extern TErrorDct err;
  25. #define REGKEY_ARCHITECTURE TEXT("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment")
  26. #define REGVAL_ARCHITECTURE TEXT("PROCESSOR_ARCHITECTURE")
  27. // Determine processor of machine
  28. ProcessorType // ret-processor type
  29. QProcessor(
  30. TCHAR const * machineName // in -Machine name
  31. )
  32. {
  33. ProcessorType processor=PROCESSOR_IS_UNKNOWN;
  34. DWORD rcOs; // OS return code
  35. TRegKey regMachine; // Registry object for target machine
  36. TRegKey regEnviron; // Registry object for selected key
  37. TCHAR strEnviron[32]; // Selected value
  38. rcOs = regMachine.Connect( HKEY_LOCAL_MACHINE, machineName );
  39. if ( rcOs )
  40. {
  41. err.SysMsgWrite( ErrW, rcOs, DCT_MSG_QPROCESSOR_REG_CONNECT_FAILED_SD,
  42. machineName, rcOs );
  43. }
  44. else
  45. {
  46. rcOs = regEnviron.Open( REGKEY_ARCHITECTURE, &regMachine );
  47. if ( rcOs )
  48. {
  49. err.SysMsgWrite( ErrW, rcOs, DCT_MSG_QPROCESSOR_REGKEY_OPEN_FAILED_SSD,
  50. machineName, REGKEY_ARCHITECTURE, rcOs );
  51. }
  52. else
  53. {
  54. rcOs = regEnviron.ValueGetStr( REGVAL_ARCHITECTURE, strEnviron, sizeof strEnviron );
  55. if ( rcOs )
  56. {
  57. err.SysMsgWrite( ErrW, rcOs, DCT_MSG_QPROCESSOR_REGKEY_OPEN_FAILED_SSD,
  58. machineName, REGKEY_ARCHITECTURE, REGVAL_ARCHITECTURE, rcOs );
  59. }
  60. else
  61. {
  62. if ( !UStrICmp( strEnviron, TEXT("x86") ) )
  63. {
  64. processor = PROCESSOR_IS_INTEL;
  65. }
  66. else if ( !UStrICmp( strEnviron, TEXT("ALPHA") ) )
  67. {
  68. processor = PROCESSOR_IS_ALPHA;
  69. }
  70. else
  71. {
  72. err.MsgWrite( ErrW,DCT_MSG_QPROCESSOR_UNRECOGNIZED_VALUE_SSSS,
  73. machineName, REGKEY_ARCHITECTURE, REGVAL_ARCHITECTURE, strEnviron );
  74. }
  75. }
  76. regEnviron.Close();
  77. }
  78. regMachine.Close();
  79. }
  80. return processor;
  81. }
  82. // QProcess.cpp - end of file