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.

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