1

I am currently trying to change my desktop background using SystemParametersInfo() vs doesnt give me any errors when I type my stuff in but when I run the program I get this warning with the yellow triangle and it says there was some kind of exception thrown at KernelBase.dll and then it says that some PDB has not been loaded. I did this a long time ago and was able to get it to work but i dont remember how anymore can anyone help me out? here is what I have written

SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "C:/Windows/Downloaded Program Files/Flowers.jpg", SPIF_UPDATEINIFILE);

does anyone know why this is happening and how to fix it? Any help is appreciated, thanks

sharpchain
  • 355
  • 2
  • 7
  • 15
  • The actual error contents and not just a description of it would be more helpful. The call as it stands looks OK. Are you doing anything else besides changing the background? Is the program running under a different user or with different permissions? Are you sure the error actually comes from this `SystemParametersInfo()` call? – Ionut Oct 06 '16 at 05:54

2 Answers2

4

You need to add L to the file path. L"C:/Windows/Downloaded Program Files/Flowers.jpg" .

#include "stdafx.h"
#include <windows.h>

int main() {

    int return_value = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, L"d:/flower1.jpg", SPIF_UPDATEINIFILE);

    return 0;
}
Software_Designer
  • 8,490
  • 3
  • 24
  • 28
0

A better description of the error would definitely help more. For starters though, you should replace all of the forward slashes with double black slashes "\\".

SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "C:\\Windows\\Downloaded Program Files\\Flowers.jpg", SPIF_UPDATEINIFILE);

That looks right, however there's no telling what the actual cause of the error is without a little more information. Also a PDB file does not affect a program, that's for debugging a file.

nrocboc
  • 11
  • 3