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.

81 lines
1.7 KiB

  1. /*
  2. * AVICAP32:
  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 "profile.h"
  21. static HKEY GetKeyA(LPCSTR appname, BOOL fCreate)
  22. {
  23. HKEY key = 0;
  24. char achName[MAX_PATH];
  25. lstrcpyA(achName, KEYNAMEA);
  26. lstrcpynA(achName + NUMELMS(KEYNAMEA) - 1, appname,
  27. NUMELMS(achName) - NUMELMS(KEYNAMEA) + 1);
  28. if ((!fCreate && RegOpenKeyA(ROOTKEY, achName, &key) == ERROR_SUCCESS)
  29. || (fCreate && RegCreateKeyA(ROOTKEY, achName, &key) == ERROR_SUCCESS)) {
  30. }
  31. return(key);
  32. }
  33. #define GetKey GetKeyA
  34. /*
  35. * read a UINT from the profile, or return default if
  36. * not found.
  37. */
  38. UINT
  39. mmGetProfileIntA(LPCSTR appname, LPCSTR valuename, INT uDefault)
  40. {
  41. DWORD dwType;
  42. INT value = uDefault;
  43. DWORD dwData;
  44. int cbData;
  45. HKEY key = GetKeyA(appname, FALSE);
  46. if (key) {
  47. cbData = sizeof(dwData);
  48. if (RegQueryValueExA(
  49. key,
  50. (LPSTR)valuename,
  51. NULL,
  52. &dwType,
  53. (PBYTE) &dwData,
  54. &cbData) == ERROR_SUCCESS) {
  55. if (dwType == REG_DWORD || dwType == REG_BINARY) {
  56. value = (INT)dwData;
  57. } else if (dwType == REG_SZ) {
  58. value = atoi((LPSTR) &dwData);
  59. }
  60. }
  61. RegCloseKey(key);
  62. }
  63. return((UINT)value);
  64. }
  65. #endif // DAYTONA