The Oven

Project World => Win10PE SE HomePage => Topic started by: paraglider on March 20, 2016, 12:07:40 PM

Title: win10pese x86 and desktop wallpaper
Post by: paraglider on March 20, 2016, 12:07:40 PM
I find that initially, the desktop shows the selected wallpaper. However after the graphics driver initializes the desktop goes black although it does resize the taskbar correctly. This is on a dual monitor setup.

Is there anything that FixScreen could do to reload the wallpaper?
Title: Re: win10pese x86 and desktop wallpaper
Post by: was_JFX on March 20, 2016, 04:36:56 PM
It actually resets the wallpaper using following code.

Code: [Select]
If Not SystemParametersInfo_(#SPI_GETDESKWALLPAPER, 256, *Wallpaper, 0)
  If RegOpenKeyEx_(#HKEY_CURRENT_USER, "Control Panel\Desktop", 0, #KEY_QUERY_VALUE, @hKey) = #ERROR_SUCCESS
    dwsize = 512
    RegQueryValueEx_(hKey, @"Wallpaper", 0, 0, *Wallpaper, @dwsize)         
    RegCloseKey_(hKey)
  EndIf
EndIf
SystemParametersInfo_(#SPI_SETDESKWALLPAPER, 0, *Wallpaper, #SPIF_UPDATEINIFILE)

Which seams to work for single monitor.
Any idea how to deal with multi monitor setup?
Title: Re: win10pese x86 and desktop wallpaper
Post by: paraglider on March 20, 2016, 09:46:35 PM
I tried your code in my own exe with some debugging. Looks like SPI_GETDESKWALLPAPER returns the expected wallpaper. SPI_SETDESKWALLPAPER also return OK but does nothing. Also tried adding SPIF_SENDWININICHANGE and that made no difference.

If I manually kill the explorer process then after explorer reloads the wallpaper is set.
Title: Re: win10pese x86 and desktop wallpaper
Post by: was_JFX on March 21, 2016, 10:35:46 AM
There is a new API for Windows 8: IDesktopWallpaper::SetWallpaper (https://msdn.microsoft.com/en-us/library/windows/desktop/hh706962(v=vs.85).aspx)

Does this problem only happens with win10pese x86 on multi monitor setup, or is x64 effected, too?
Title: Re: win10pese x86 and desktop wallpaper
Post by: paraglider on March 21, 2016, 12:09:46 PM
Seems to be ok in a virtual machine with one monitor.

I also tried:

   CoInitialize(NULL);

   HRESULT hr;
   IActiveDesktop *pActiveDesktop;

   hr = CoCreateInstance(CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER, IID_IActiveDesktop, (void**)&pActiveDesktop);
   if (S_OK == hr)
   {
#ifdef _UNICODE
      WCHAR * wszImageLocation = wallpaper;
#else
      WCHAR wszImageLocation[MAX_PATH];

      MultiByteToWideChar(CP_ACP, 0, wallpaper, -1, wszImageLocation, MAX_PATH);
#endif
      HRESULT hr = pActiveDesktop->SetWallpaper(wszImageLocation, 0);
      DebugOut(_T("SetWallpaper, hr=0x%08X\r\n"), hr);
      hr = pActiveDesktop->ApplyChanges(AD_APPLY_SAVE);
      DebugOut(_T("ApplyChanges(AD_APPLY_SAVE), hr=0x%08X\r\n"), hr);
      hr = pActiveDesktop->ApplyChanges(AD_APPLY_ALL);
      DebugOut(_T("ApplyChanges(AD_APPLY_ALL), hr=0x%08X\r\n"), hr);
      hr = pActiveDesktop->Release();
   }

   IDesktopWallpaper *pDesktopWallpaper = NULL;
   hr = CoCreateInstance(CLSID_DesktopWallpaper, NULL, CLSCTX_INPROC_SERVER, IID_IDesktopWallpaper, (void**)&pDesktopWallpaper);
   if (FAILED(hr))
   {
      DebugOut(_T("CoCreateInstance(CLSID_DesktopWallpaper, hr=0x%08X\r\n"), hr);
   }
   else
   {
      DebugOut(_T("CoCreateInstance(CLSID_DesktopWallpaper) ok\r\n"));
#ifdef _UNICODE
      WCHAR * wszImageLocation = wallpaper;
#else
      WCHAR wszImageLocation[MAX_PATH];

      MultiByteToWideChar(CP_ACP, 0, wallpaper, -1, wszImageLocation, MAX_PATH);
#endif
      HRESULT hr = pDesktopWallpaper->SetWallpaper(NULL, wszImageLocation);
      DebugOut(_T("SetWallpaper, hr=0x%08X\r\n"), hr);

      pDesktopWallpaper->Release();
   }

pActiveDesktop->SetWallpaper reports OK but does nothing.

CoCreateInstance(CLSID_DesktopWallpaper,.. ) gives HR=0x80040154 - class not registered.