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.

53 lines
1.3 KiB

  1. #include "stdafx.h"
  2. #ifndef SNAPIN
  3. #include <windows.h>
  4. #endif
  5. #include <tchar.h>
  6. #include "getreg.h"
  7. #include "expand.h"
  8. #include "GetDfrgRes.h"
  9. HINSTANCE GetDfrgResHandle(BOOL fReset)
  10. {
  11. // no need to keep getting this handle
  12. static HINSTANCE hInstRes = NULL;
  13. if (fReset) {
  14. hInstRes = NULL;
  15. return NULL;
  16. }
  17. if (hInstRes == NULL) {
  18. HKEY hValue = NULL;
  19. TCHAR cRegValue[MAX_PATH+1];
  20. DWORD dwRegValueSize = sizeof(cRegValue);
  21. //0.0E00 Get the name of the resource DLL.
  22. if(GetRegValue(&hValue,
  23. TEXT("SOFTWARE\\Microsoft\\Dfrg"),
  24. TEXT("ResourceDllName"),
  25. cRegValue,
  26. &dwRegValueSize) != ERROR_SUCCESS){
  27. // We couldn't get the resource DLL location from the registry--
  28. // let's fall back to the default
  29. _tcscpy(cRegValue, TEXT("%systemroot%\\system32\\dfrgres.dll"));
  30. }
  31. RegCloseKey(hValue);
  32. //Translate any environment variables in the string.
  33. if(!ExpandEnvVars(cRegValue)){
  34. hInstRes = NULL;
  35. return NULL;
  36. }
  37. //0.0E00 Open the resource DLL.
  38. hInstRes = LoadLibrary(cRegValue);
  39. }
  40. return hInstRes;
  41. }