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.

103 lines
2.5 KiB

  1. /*
  2. mci.c
  3. A console app to test the mciSendString API
  4. Created by NigelT in a moment of frustration with the GUI world.
  5. */
  6. #include "mci.h"
  7. #include "mcicda.h"
  8. extern VOID winmmSetDebugLevel(int level);
  9. // extern VOID mcicdaSetDebugLevel(int level);
  10. char cmd[256];
  11. char ResultString[256];
  12. char ErrorString[256];
  13. void SendCommand(char *command);
  14. void Usage(void);
  15. BOOL Parse(char *command);
  16. int main(int argc, char *argv[])
  17. {
  18. FILE *fp;
  19. if (argc > 1) {
  20. // do the command line thing and exit
  21. fp = fopen(argv[1], "r");
  22. if (fp == NULL) {
  23. strcpy(cmd, argv[1]);
  24. strcat(cmd, ".mci");
  25. fp = fopen(cmd, "r");
  26. if (fp == NULL) {
  27. printf("\nCould not open %s or %s", argv[1], cmd);
  28. exit(1);
  29. }
  30. }
  31. do {
  32. if (fgets(cmd, sizeof(cmd), fp) == NULL) break;
  33. // strip the newline char from the end
  34. cmd[strlen(cmd)-1] = '\0';
  35. printf("\nCommand: %s", cmd);
  36. if (!Parse(cmd)) break;
  37. } while(1);
  38. } else {
  39. // do the keyboard thing until we get bored
  40. do {
  41. printf("\nCommand: ");
  42. gets(cmd);
  43. if (!Parse(cmd)) break;
  44. } while(1);
  45. }
  46. return 0;
  47. }
  48. BOOL Parse(char *command)
  49. {
  50. if (strcmpi(command, "q") == 0) {
  51. return FALSE;
  52. } else if (strcmpi(command, "?") == 0) {
  53. Usage();
  54. } else if (strnicmp(command, "dmm", 3) == 0) {
  55. winmmSetDebugLevel(atoi(command+3));
  56. // } else if (strnicmp(command, "dcd", 3) == 0) {
  57. // mcicdaSetDebugLevel(atoi(command+3));
  58. } else {
  59. SendCommand(command);
  60. }
  61. return TRUE;
  62. }
  63. void SendCommand(char *command)
  64. {
  65. DWORD Result;
  66. Result = mciSendString(command, ResultString, sizeof(ResultString), 0);
  67. printf("\nResult : %08XH %s", Result, ResultString);
  68. if (Result != 0) {
  69. mciGetErrorString(Result, ErrorString, sizeof(ErrorString));
  70. printf("\nError : %s", ErrorString);
  71. }
  72. }
  73. void Usage()
  74. {
  75. printf("\nUsage:");
  76. printf("\nMCI <filename> Play an MCI script");
  77. printf("\nMCI Enter command mode");
  78. printf("\n\nCommands:");
  79. printf("\nq \t\tQuit");
  80. printf("\ndmm <n> \t\tSet WINMM debug level to <n>");
  81. // printf("\ndcd <n> \t\tSet MCICDA debug level to <n>");
  82. printf("\n? \t\tThis helpful little missive");
  83. printf("\n<mci command>\t\tSome MCI command string");
  84. }