Leaked source code of windows server 2003
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.

224 lines
6.1 KiB

  1. #include <windows.h>
  2. #ifdef CHICAGO_PRODUCT
  3. #include <regstr.h>
  4. #endif
  5. #include "mplayer.h"
  6. #ifdef CHICAGO_PRODUCT
  7. TCHAR szRegPath[] = TEXT(REGSTR_PATH_WINDOWSAPPLETS "\\Media Player");
  8. #else
  9. TCHAR szRegPath[] = TEXT("Software\\Microsoft\\Media Player");
  10. #endif
  11. /* WriteRegistryData
  12. *
  13. * Writes a bunch of information to the registry
  14. *
  15. * Parameters:
  16. *
  17. * pEntryNode - The node under szRegPath which should be created
  18. * or opened for this data. If this is NULL, the value is
  19. * written directly under szRegPath.
  20. *
  21. * pEntryName - The name of the value under pEntryNode to be set.
  22. *
  23. * Type - Type of data to read (e.g. REG_SZ).
  24. *
  25. * pData - Pointer to the value data to be written. If this is NULL,
  26. * the value under pEntryNode is deleted.
  27. *
  28. * Size - Size, in bytes, of the buffer pointed to by pData.
  29. *
  30. *
  31. * This routine is fairly generic, apart from the name of the top-level node.
  32. *
  33. * The data are stored in the following registry tree:
  34. *
  35. * HKEY_CURRENT_USER
  36. *
  37. * Software
  38. *
  39. * Microsoft
  40. *
  41. * Windows NT
  42. *
  43. * CurrentVersion
  44. *
  45. * Media Player
  46. *
  47. * AVIVideo
  48. *
  49. * DisplayPosition
  50. *
  51. * SysIni
  52. *
  53. *
  54. * Return:
  55. *
  56. * Registry status return (NO_ERROR is good)
  57. *
  58. *
  59. * Andrew Bell (andrewbe) wrote it, 10 September 1992
  60. *
  61. */
  62. DWORD WriteRegistryData( LPTSTR pEntryNode,
  63. LPTSTR pEntryName,
  64. DWORD Type,
  65. LPBYTE pData,
  66. DWORD Size )
  67. {
  68. DWORD Status;
  69. HKEY hkeyRegPath;
  70. HKEY hkeyEntryNode;
  71. /* Open or create the top-level node. For Media Player this is:
  72. * "Software\\Microsoft\\Windows NT\\CurrentVersion\\Media Player"
  73. */
  74. Status = RegCreateKeyEx( HKEY_CURRENT_USER, szRegPath, 0,
  75. NULL, 0, KEY_WRITE, NULL, &hkeyRegPath, NULL );
  76. if( Status == NO_ERROR )
  77. {
  78. /* Open or create the sub-node.
  79. */
  80. if( pEntryNode )
  81. Status = RegCreateKeyEx( hkeyRegPath, pEntryNode, 0,
  82. NULL, 0, KEY_WRITE, NULL, &hkeyEntryNode, NULL );
  83. else
  84. hkeyEntryNode = hkeyRegPath;
  85. if( Status == NO_ERROR )
  86. {
  87. if( pData )
  88. {
  89. Status = RegSetValueEx( hkeyEntryNode,
  90. pEntryName,
  91. 0,
  92. Type,
  93. pData,
  94. Size );
  95. if( Status != NO_ERROR )
  96. {
  97. DPF1( "RegSetValueEx (%"DTS") failed: Error = %d\n", pEntryName, Status );
  98. }
  99. }
  100. else
  101. {
  102. Status = RegDeleteValue( hkeyEntryNode, pEntryName );
  103. if( Status != NO_ERROR )
  104. {
  105. DPF1( "RegDeleteValue (%"DTS") failed: Error = %d\n", pEntryName, Status );
  106. }
  107. }
  108. if( pEntryNode )
  109. RegCloseKey( hkeyEntryNode );
  110. }
  111. else
  112. {
  113. DPF1( "RegCreateKeyEx (%"DTS") failed: Error = %d\n", pEntryNode, Status );
  114. }
  115. RegCloseKey( hkeyRegPath );
  116. }
  117. else
  118. {
  119. DPF1( "RegCreateKeyEx (%"DTS") failed: Error = %d\n", szRegPath, Status );
  120. }
  121. return Status;
  122. }
  123. /* ReadRegistryData
  124. *
  125. * Reads information from the registry
  126. *
  127. * Parameters:
  128. *
  129. * pEntryNode - The node under Media Player which should be opened
  130. * for this data. If this is NULL, the value is
  131. * written directly under szRegPath.
  132. *
  133. * pEntryName - The name of the value under pEntryNode to be retrieved.
  134. *
  135. * pType - Pointer to a buffer to receive type of data read. May be NULL.
  136. *
  137. * pData - Pointer to a buffer to receive the value data.
  138. *
  139. * Size - Size, in bytes, of the buffer pointed to by pData.
  140. *
  141. * Return:
  142. *
  143. * Registry status return (NO_ERROR is good)
  144. *
  145. *
  146. * Andrew Bell (andrewbe) wrote it, 10 September 1992
  147. *
  148. */
  149. DWORD ReadRegistryData( LPTSTR pEntryNode,
  150. LPTSTR pEntryName,
  151. PDWORD pType,
  152. LPBYTE pData,
  153. DWORD DataSize )
  154. {
  155. DWORD Status;
  156. HKEY hkeyRegPath;
  157. HKEY hkeyEntryNode;
  158. DWORD Size;
  159. /* Open the top-level node. For Media Player this is:
  160. * "Software\\Microsoft\\Windows NT\\CurrentVersion\\Media Player"
  161. */
  162. Status = RegOpenKeyEx( HKEY_CURRENT_USER, szRegPath, 0,
  163. KEY_READ, &hkeyRegPath );
  164. if( Status == NO_ERROR )
  165. {
  166. /* Open the sub-node:
  167. */
  168. if( pEntryNode )
  169. Status = RegOpenKeyEx( hkeyRegPath, pEntryNode, 0,
  170. KEY_READ, &hkeyEntryNode );
  171. else
  172. hkeyEntryNode = hkeyRegPath;
  173. if( Status == NO_ERROR )
  174. {
  175. Size = DataSize;
  176. /* Read the entry from the registry:
  177. */
  178. Status = RegQueryValueEx( hkeyEntryNode,
  179. pEntryName,
  180. 0,
  181. pType,
  182. pData,
  183. &Size );
  184. if( pEntryNode )
  185. RegCloseKey( hkeyEntryNode );
  186. }
  187. else
  188. {
  189. DPF1( "RegOpenKeyEx (%"DTS") failed: Error = %d\n", pEntryNode, Status );
  190. }
  191. RegCloseKey( hkeyRegPath );
  192. }
  193. else
  194. {
  195. DPF1( "RegOpenKeyEx (%"DTS") failed: Error = %d\n", szRegPath, Status );
  196. }
  197. return Status;
  198. }
  199.