Q:

LoadImage() with variable path?

How do I get LoadImage(); to work with a variable file path? I have the desired file path in the variable bg, and I'm calling the function like so:
bmp = LoadImage(hInst,bg,IMAGE_BITMAP,640,480,LR_LOADFROMFILE); 
Yet bmp does not render any image when used with:  BitBlt(hDC,0,0,640,480,memDC,0,0,SRCCOPY);

If I can't use LoadImage();, what equivalent is there that can handle non-constant file names?

[EDIT]
Apparently, the error was caused by another bit of code, and not the LoadImage() function. Disragerd.

A:

It seems to be the timer. The documentation about the SetTimer function says that the second parameter (nIDEvent) must be a nonzero value. So, I imagine your timer is never firing, the execmain() function is never called, and so your bg string is never set.
When you replace bg by a string literal, it works, because the WM_PAINT message does not depend on the timer, it is always called at least once when the window is created.

