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
3.0 KiB

  1. /*++
  2. Copyright (c) 1995-1999 Microsoft Corporation, All Rights Reserved
  3. Module Name:
  4. GETDES.C
  5. ++*/
  6. #include <windows.h>
  7. #include <windowsx.h>
  8. #include <winerror.h>
  9. #include <immdev.h>
  10. #include <imedefs.h>
  11. //#include "conv.h"
  12. #ifdef IDEBUG
  13. void OutputDbgWord( DWORD dwValue) {
  14. TCHAR Outdbg[9];
  15. int itmp, i;
  16. for (i=0; i<9; i++)
  17. Outdbg[i] = 0x0020;
  18. i=9;
  19. itmp = (int)dwValue;
  20. Outdbg[i--] = 0x0000;
  21. while (itmp) {
  22. if ( (itmp % 16) < 10 )
  23. Outdbg[i] = itmp % 16 + L'0';
  24. else
  25. Outdbg[i] = itmp % 16 + L'A' - 10;
  26. i --;
  27. itmp = itmp / 16;
  28. }
  29. OutputDebugString(Outdbg);
  30. }
  31. #endif
  32. /**********************************************************************/
  33. /* ReadDescript() */
  34. /* Description: */
  35. /* read description from .MB file */
  36. /**********************************************************************/
  37. BOOL ReadDescript(
  38. LPCTSTR MBFileName,
  39. LPMBDESC lpDescript)
  40. {
  41. HANDLE hMBFile;
  42. DWORD dwBytes;
  43. DWORD dwOffset;
  44. MAININDEX lpMainIndex[NUMTABLES];
  45. PSECURITY_ATTRIBUTES psa;
  46. BOOL retVal;
  47. psa = CreateSecurityAttributes();
  48. hMBFile = CreateFile(MBFileName,GENERIC_READ,FILE_SHARE_READ,psa,OPEN_EXISTING,0,NULL);
  49. FreeSecurityAttributes(psa);
  50. if(hMBFile==INVALID_HANDLE_VALUE)
  51. return(0);
  52. SetFilePointer(hMBFile,ID_LENGTH,0,FILE_BEGIN);
  53. retVal = ReadFile(hMBFile,lpMainIndex,sizeof(MAININDEX)*NUMTABLES,&dwBytes,NULL);
  54. if ( retVal == FALSE )
  55. {
  56. CloseHandle(hMBFile);
  57. return retVal;
  58. }
  59. dwOffset = lpMainIndex[TAG_DESCRIPTION-1].dwOffset;
  60. SetFilePointer(hMBFile,dwOffset,0,FILE_BEGIN);
  61. retVal = ReadFile(hMBFile,lpDescript,sizeof(MBDESC),&dwBytes,NULL);
  62. if ( retVal == FALSE )
  63. {
  64. CloseHandle(hMBFile);
  65. return retVal;
  66. }
  67. CloseHandle(hMBFile);
  68. #ifdef IDEBUG
  69. {
  70. DWORD dwtmp;
  71. OutputDebugString(L"Under ReadDescript\n");
  72. OutputDebugString(L"dwBytes=");
  73. OutputDbgWord(dwBytes);
  74. OutputDebugString(L"Sizeof(MBDESC)=");
  75. dwtmp = (DWORD)sizeof(MBDESC);
  76. OutputDbgWord(dwtmp);
  77. OutputDebugString(L"\n");
  78. OutputDebugString(L"szName=");
  79. OutputDebugString(lpDescript->szName);
  80. OutputDebugString(L"\n");
  81. OutputDebugString(L"wMaxCodes=");
  82. dwtmp = (DWORD)(lpDescript->wMaxCodes);
  83. OutputDbgWord( dwtmp );
  84. OutputDebugString(L"\n");
  85. OutputDebugString(L"wNumCodes=");
  86. dwtmp = (DWORD)(lpDescript->wNumCodes);
  87. OutputDbgWord(dwtmp);
  88. OutputDebugString(L"\n");
  89. OutputDebugString(L"byMaxElement=");
  90. dwtmp = (DWORD)(lpDescript->byMaxElement) & 0x0000000f;
  91. OutputDbgWord(dwtmp);
  92. OutputDebugString(L"\n");
  93. OutputDebugString(L"cWildChar=");
  94. dwtmp = (DWORD)(lpDescript->cWildChar);
  95. OutputDbgWord( dwtmp );
  96. OutputDebugString(L"\n");
  97. OutputDebugString(L"wNumRulers=");
  98. dwtmp = (DWORD)(lpDescript->wNumRulers);
  99. OutputDbgWord( dwtmp );
  100. OutputDebugString(L"\n");
  101. }
  102. #endif
  103. if(dwBytes < sizeof(MBDESC) )
  104. return FALSE;
  105. else
  106. return TRUE;
  107. }