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.

184 lines
4.0 KiB

  1. /*
  2. * Sniff Test for oemuni.lib
  3. * 14-Jan-1993 Jonle , created
  4. */
  5. #include <nt.h>
  6. #include <ntrtl.h>
  7. #include <nturtl.h>
  8. #include <windows.h>
  9. #include <stdio.h>
  10. #include <conio.h>
  11. #include <string.h>
  12. #include <oemuni.h>
  13. void TestDirNode(PCHAR DirName, PCHAR FName);
  14. VOID SetDirectory( PCHAR Name);
  15. VOID SetEnvironment(PCHAR Name,PCHAR Value);
  16. void Pause(void);
  17. #define MAXSTR MAX_PATH *2
  18. char achEnvTMP[MAXSTR+1];
  19. char achWinDir[MAXSTR+1];
  20. char achSysDir[MAXSTR+1];
  21. char achCurDir[MAXSTR+1];
  22. char ach[MAXSTR+1];
  23. char achTmp[MAXSTR+1];
  24. DWORD
  25. __cdecl
  26. main( void)
  27. {
  28. DWORD dw;
  29. dw = GetEnvironmentVariableOem("TMP", achEnvTMP, MAXSTR);
  30. if (!dw || dw > MAXSTR-1)
  31. printf("GetEnvironmentVariableOem(TMP) failed dw=%ld\n",dw);
  32. else
  33. printf("TMP=<%s>\n",achEnvTMP);
  34. dw = GetWindowsDirectoryOem(achWinDir, MAXSTR);
  35. if (!dw || dw > MAXSTR-1)
  36. printf("GetWindowsDirectory failed dw=%ld\n",dw);
  37. else
  38. printf("WinDir=<%s>\n",achWinDir);
  39. dw = GetSystemDirectoryOem(achSysDir, MAXSTR);
  40. if (!dw || dw > MAXSTR-1)
  41. printf("GetSystemDirectory(achSysDir failed dw=%ld\n",dw);
  42. else
  43. printf("SysDir=<%s>\n",achWinDir);
  44. dw = GetCurrentDirectory(MAXSTR, achCurDir);
  45. if (!dw || dw > MAXSTR-1)
  46. printf("GetCurrentDirectory(achCurDir dw=%ld\n",dw);
  47. else
  48. printf("CurDir=<%s>\n",achWinDir);
  49. SetDirectory(achEnvTMP);
  50. SetDirectory(achWinDir);
  51. SetDirectory(achSysDir);
  52. SetDirectory(achCurDir);
  53. Pause();
  54. strcpy(ach, achCurDir);
  55. strcat(ach, "\\foo");
  56. TestDirNode(ach, "foo.foo");
  57. SetDirectory(achCurDir);
  58. Pause();
  59. dw = GetTempPathOem(MAXSTR, ach);
  60. if (!dw || dw > MAXSTR)
  61. printf("GetTempPathOem - Failed\n");
  62. else {
  63. printf("GetTempPathOem<%s>\n",ach);
  64. if (!GetTempFileNameOem(".", "OEM", 0, achTmp))
  65. printf("GetTempFileNameOem - Failed\n");
  66. else
  67. printf("GetTempFileNameOem<%s>\n",ach);
  68. TestDirNode(ach, achTmp);
  69. }
  70. SetDirectory(achCurDir);
  71. Pause();
  72. }
  73. void TestDirNode(PCHAR DirName, PCHAR FName)
  74. {
  75. HANDLE hFile;
  76. if (CreateDirectoryOem( DirName, NULL))
  77. printf("CreateDirectoryOem <%s>\n",DirName);
  78. else
  79. printf("CreateDirectoryOem <%s>- Fail\n",DirName);
  80. SetDirectory(DirName);
  81. hFile = CreateFileOem( FName,
  82. GENERIC_READ | GENERIC_WRITE,
  83. FILE_SHARE_READ | FILE_SHARE_WRITE,
  84. NULL,
  85. CREATE_NEW,
  86. FILE_ATTRIBUTE_NORMAL,
  87. 0);
  88. if (hFile == (HANDLE) 0xFFFFFFFF) {
  89. printf("CreateFileOem<%s>- Fail\n", FName);
  90. }
  91. else {
  92. printf("CreateFileOem<%s>\n", FName);
  93. CloseHandle(hFile);
  94. }
  95. if (DeleteFileOem(FName))
  96. printf("DeleteFileOem <%s>\n",FName);
  97. else
  98. printf("DeleteFileOem <%s>- Fail\n",FName);
  99. SetDirectory("\\");
  100. if (RemoveDirectoryOem(DirName))
  101. printf("RemoveDirectoryOem <%s>\n",DirName);
  102. else
  103. printf("RemoveDirectoryOem <%s>- Fail\n",DirName);
  104. }
  105. VOID
  106. SetDirectory(
  107. PCHAR Name
  108. )
  109. {
  110. CHAR achValue[512];
  111. if (SetCurrentDirectoryOem( Name))
  112. printf( "SetCurrentDirectoryOem <%s>\n", Name ? Name : "NULL");
  113. else
  114. printf( "SetCurrentDirectoryOem- failed\n");
  115. if (GetCurrentDirectoryOem( sizeof(achValue)-1, achValue))
  116. printf( "GetCurrentDirectoryOem <%s>\n", achValue);
  117. else
  118. printf( "GetCurrentDirectoryOem - failed\n");
  119. }
  120. VOID
  121. SetEnvironment(
  122. PCHAR Name,
  123. PCHAR Value
  124. )
  125. {
  126. CHAR achValue[512];
  127. if (SetEnvironmentVariableOem( Name, Value ))
  128. printf( "SetEnvironmentVariableOem <%s=%s>\n", Name, Value ? Value : "NULL");
  129. else
  130. printf( "SetEnvironmentVariableOem - failed\n" );
  131. if (GetEnvironmentVariableOem( Name, achValue, sizeof(achValue)-1))
  132. printf( "GetEnvironmentVariableOem <%s=%s>\n", Name, achValue ? achValue : "NULL");
  133. else
  134. printf( "GetEnvironmentVariableOem - failed\n");
  135. }
  136. void Pause(void)
  137. {
  138. printf("Press any key ....\n");
  139. getch();
  140. }