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.

113 lines
1.8 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. ini.c
  5. Abstract:
  6. IEEE1394 ARP Admin Utility.
  7. Usage:
  8. a13adm
  9. Revision History:
  10. Who When What
  11. -------- -------- ---------------------------------------------
  12. josephj 04-10-1999 Created
  13. --*/
  14. #include "common.h"
  15. BOOL
  16. GetBinaryData(
  17. TCHAR *tszPathName,
  18. TCHAR *tszSection,
  19. TCHAR *tszKey,
  20. UCHAR *pchData,
  21. UINT cbMaxData,
  22. UINT *pcbDataSize
  23. )
  24. {
  25. BOOL fRet = FALSE;
  26. INFCONTEXT InfCtxt;
  27. INFCONTEXT LineCtxt;
  28. HINF hInf = NULL;
  29. UINT uLine = 0;
  30. do
  31. {
  32. hInf = SetupOpenInfFile(tszPathName, NULL, INF_STYLE_WIN4, &uLine);
  33. if (hInf == INVALID_HANDLE_VALUE)
  34. {
  35. UINT Error = GetLastError();
  36. if (Error == 0xe0000100)
  37. {
  38. printf( "\nBadly formatted ini file %s\n", tszPathName);
  39. printf( "Make sure the file contains the following section:\n"
  40. " [Version]\n"
  41. " Signature=\"$CHICAGO$\"\n\n"
  42. );
  43. }
  44. else if (Error == 0x2)
  45. {
  46. printf("\nCould not find INI file %s\n", tszPathName);
  47. }
  48. hInf = NULL;
  49. break;
  50. }
  51. fRet = SetupFindFirstLine(
  52. hInf,
  53. tszSection,
  54. tszKey,
  55. &LineCtxt
  56. );
  57. if (!fRet)
  58. {
  59. printf( "\nError 0x%08lx finding key \"%s\" in section \"%s\"\n in file %s\n",
  60. GetLastError(), tszKey, tszSection, tszPathName);
  61. break;
  62. }
  63. fRet = SetupGetBinaryField(
  64. &LineCtxt,
  65. 1,
  66. pchData,
  67. cbMaxData,
  68. pcbDataSize
  69. );
  70. if (!fRet)
  71. {
  72. #if 0
  73. printf(
  74. TEXT("SetupGetBinaryField fails. Err = %08lu\n"),
  75. GetLastError()
  76. );
  77. #endif // 0
  78. printf( "\nError 0x%08lx reading data from key \"%s\" in section \"%s\"\n in file %s\n",
  79. GetLastError(), tszKey, tszSection, tszPathName);
  80. break;
  81. }
  82. } while (FALSE);
  83. if (hInf != NULL)
  84. {
  85. SetupCloseInfFile(hInf);
  86. hInf = NULL;
  87. }
  88. return fRet;
  89. }