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.

142 lines
4.7 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. tatom.c
  5. Abstract:
  6. Win32 Base API Test Program for Atom Manager calls
  7. Author:
  8. Steve Wood (stevewo) 26-Oct-1990
  9. Revision History:
  10. --*/
  11. #include <assert.h>
  12. #include <stdio.h>
  13. #include <windows.h>
  14. DWORD
  15. main(
  16. int argc,
  17. char *argv[],
  18. char *envp[]
  19. )
  20. {
  21. ATOM Atom1, Atom2, Atom3;
  22. BOOL Atom1Found, Atom2Found, Atom3Found;
  23. DWORD Atom1Length, Atom2Length, Atom3Length;
  24. TCHAR NameBuffer[ 128 ];
  25. printf( "TATOM: Entering Test Program\n" );
  26. Atom1 = AddAtom( TEXT("Atom1") );
  27. Atom2 = AddAtom( TEXT("#4095") );
  28. Atom3 = AddAtom( (LPTSTR)0x1234 );
  29. printf( "AddAtom( ""Atom1"" ) == %X\n", Atom1 );
  30. printf( "AddAtom( ""#4095"" ) == %X\n", Atom2 );
  31. printf( "AddAtom( 0x1234 ) == %X\n", Atom3 );
  32. Atom1 = AddAtom( TEXT("Atom1") );
  33. Atom2 = AddAtom( TEXT("#4095") );
  34. Atom3 = AddAtom( (LPTSTR)0x1234 );
  35. printf( "AddAtom( ""Atom1"" ) == %X\n", Atom1 );
  36. printf( "AddAtom( ""#4095"" ) == %X\n", Atom2 );
  37. printf( "AddAtom( 0x1234 ) == %X\n", Atom3 );
  38. assert( Atom1Found = (Atom1 == FindAtom( TEXT("Atom1") )) );
  39. assert( Atom2Found = (Atom2 == FindAtom( TEXT("#4095") )) );
  40. assert( Atom3Found = (Atom3 == FindAtom( (LPTSTR)0x1234 )) );
  41. printf( "FindAtom( ""Atom1"" ) == %X\n", Atom1 );
  42. printf( "FindAtom( ""#4095"" ) == %X\n", Atom2 );
  43. printf( "FindAtom( 0x1234 ) == %X\n", Atom3 );
  44. Atom1Length = GetAtomName( Atom1, NameBuffer, sizeof( NameBuffer ));
  45. #ifdef UNICODE
  46. printf( "GetAtomName( %X ) == %ws\n", Atom1, NameBuffer );
  47. #else
  48. printf( "GetAtomName( %X ) == %s\n", Atom1, NameBuffer );
  49. #endif
  50. Atom2Length = GetAtomName( Atom2, NameBuffer, sizeof( NameBuffer ));
  51. #ifdef UNICODE
  52. printf( "GetAtomName( %X ) == %ws\n", Atom2, NameBuffer );
  53. #else
  54. printf( "GetAtomName( %X ) == %s\n", Atom2, NameBuffer );
  55. #endif
  56. Atom3Length = GetAtomName( Atom3, NameBuffer, sizeof( NameBuffer ));
  57. #ifdef UNICODE
  58. printf( "GetAtomName( %X ) == %ws\n", Atom3, NameBuffer );
  59. #else
  60. printf( "GetAtomName( %X ) == %s\n", Atom3, NameBuffer );
  61. #endif
  62. printf( "DeleteAtom( %X ) == %X\n", Atom1, DeleteAtom( Atom1 ) );
  63. printf( "DeleteAtom( %X ) == %X\n", Atom1, DeleteAtom( Atom1 ) );
  64. printf( "DeleteAtom( %X ) == %X\n", Atom1, DeleteAtom( Atom1 ) );
  65. printf( "DeleteAtom( %X ) == %X\n", Atom1, DeleteAtom( Atom1 ) );
  66. printf( "DeleteAtom( %X ) == %X\n", Atom2, DeleteAtom( Atom2 ) );
  67. printf( "DeleteAtom( %X ) == %X\n", Atom3, DeleteAtom( Atom3 ) );
  68. Atom1 = GlobalAddAtom( TEXT("Atom1") );
  69. Atom2 = GlobalAddAtom( TEXT("#4095") );
  70. Atom3 = GlobalAddAtom( (LPTSTR)0x1234 );
  71. printf( "GlobalAddAtom( ""Atom1"" ) == %X\n", Atom1 );
  72. printf( "GlobalAddAtom( ""#4095"" ) == %X\n", Atom2 );
  73. printf( "GlobalAddAtom( 0x1234 ) == %X\n", Atom3 );
  74. Atom1 = GlobalAddAtom( TEXT("Atom1") );
  75. Atom2 = GlobalAddAtom( TEXT("#4095") );
  76. Atom3 = GlobalAddAtom( (LPTSTR)0x1234 );
  77. printf( "GlobalAddAtom( ""Atom1"" ) == %X\n", Atom1 );
  78. printf( "GlobalAddAtom( ""#4095"" ) == %X\n", Atom2 );
  79. printf( "GlobalAddAtom( 0x1234 ) == %X\n", Atom3 );
  80. assert( Atom1Found = (Atom1 == GlobalFindAtom( TEXT("Atom1") )) );
  81. assert( Atom2Found = (Atom2 == GlobalFindAtom( TEXT("#4095") )) );
  82. assert( Atom3Found = (Atom3 == GlobalFindAtom( (LPTSTR)0x1234 )) );
  83. printf( "GlobalFindAtom( ""Atom1"" ) == %X\n", Atom1 );
  84. printf( "GlobalFindAtom( ""#4095"" ) == %X\n", Atom2 );
  85. printf( "GlobalFindAtom( 0x1234 ) == %X\n", Atom3 );
  86. Atom1Length = GlobalGetAtomName( Atom1, NameBuffer, sizeof( NameBuffer ));
  87. #ifdef UNICODE
  88. printf( "GlobalGetAtomName( %X ) == %ws\n", Atom1, NameBuffer );
  89. #else
  90. printf( "GlobalGetAtomName( %X ) == %s\n", Atom1, NameBuffer );
  91. #endif
  92. Atom2Length = GlobalGetAtomName( Atom2, NameBuffer, sizeof( NameBuffer ));
  93. #ifdef UNICODE
  94. printf( "GlobalGetAtomName( %X ) == %ws\n", Atom2, NameBuffer );
  95. #else
  96. printf( "GlobalGetAtomName( %X ) == %s\n", Atom2, NameBuffer );
  97. #endif
  98. Atom3Length = GlobalGetAtomName( Atom3, NameBuffer, sizeof( NameBuffer ));
  99. #ifdef UNICODE
  100. printf( "GlobalGetAtomName( %X ) == %ws\n", Atom3, NameBuffer );
  101. #else
  102. printf( "GlobalGetAtomName( %X ) == %s\n", Atom3, NameBuffer );
  103. #endif
  104. printf( "GlobalDeleteAtom( %X ) == %X\n", Atom1, GlobalDeleteAtom( Atom1 ) );
  105. printf( "GlobalDeleteAtom( %X ) == %X\n", Atom1, GlobalDeleteAtom( Atom1 ) );
  106. printf( "GlobalDeleteAtom( %X ) == %X\n", Atom1, GlobalDeleteAtom( Atom1 ) );
  107. printf( "GlobalDeleteAtom( %X ) == %X\n", Atom1, GlobalDeleteAtom( Atom1 ) );
  108. printf( "GlobalDeleteAtom( %X ) == %X\n", Atom2, GlobalDeleteAtom( Atom2 ) );
  109. printf( "GlobalDeleteAtom( %X ) == %X\n", Atom3, GlobalDeleteAtom( Atom3 ) );
  110. printf( "TATOM: Exiting Test Program\n" );
  111. return 0;
  112. }