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.

83 lines
1.7 KiB

  1. /*
  2. * MSRLE32:
  3. *
  4. * profile.c
  5. *
  6. * win32/win16 utility functions to read and write profile items
  7. * for VFW
  8. *
  9. * ONLY mmGetProfileIntA is supported here
  10. *
  11. */
  12. #if defined(_WIN32) && defined(UNICODE)
  13. // This whole file is only used for 32 bit code. It is the implementation
  14. // that allows Win GetProfilexxx calls to use the registry.
  15. #include <windows.h>
  16. #include <windowsx.h>
  17. #include <profile.key>
  18. #include <win32.h>
  19. #include <stdlib.h> // for atoi
  20. #include "msrle.h"
  21. #ifdef DEBUG
  22. #include "profile.h"
  23. static HKEY GetKeyA(LPCSTR appname, BOOL fCreate)
  24. {
  25. HKEY key = 0;
  26. char achName[MAX_PATH];
  27. lstrcpyA(achName, KEYNAMEA);
  28. lstrcatA(achName, appname);
  29. if ((!fCreate && RegOpenKeyA(ROOTKEY, achName, &key) == ERROR_SUCCESS)
  30. || (fCreate && RegCreateKeyA(ROOTKEY, achName, &key) == ERROR_SUCCESS)) {
  31. }
  32. return(key);
  33. }
  34. #define GetKey GetKeyA
  35. /*
  36. * read a UINT from the profile, or return default if
  37. * not found.
  38. */
  39. UINT
  40. mmGetProfileIntA(LPCSTR appname, LPCSTR valuename, INT uDefault)
  41. {
  42. DWORD dwType;
  43. INT value = uDefault;
  44. DWORD dwData;
  45. int cbData;
  46. HKEY key = GetKeyA(appname, FALSE);
  47. if (key) {
  48. cbData = sizeof(dwData);
  49. if (RegQueryValueExA(
  50. key,
  51. (LPSTR)valuename,
  52. NULL,
  53. &dwType,
  54. (PBYTE) &dwData,
  55. &cbData) == ERROR_SUCCESS) {
  56. if (dwType == REG_DWORD || dwType == REG_BINARY) {
  57. value = (INT)dwData;
  58. } else if (dwType == REG_SZ) {
  59. value = atoi((LPSTR) &dwData);
  60. }
  61. }
  62. RegCloseKey(key);
  63. }
  64. return((UINT)value);
  65. }
  66. #endif // DEBUG
  67. #endif // defined(_WIN32) && defined(UNICODE)