P
peiwents
Unregistered / Unconfirmed
GUEST, unregistred user!
//I have wrote to "SetWallPaper" Function:<br>//function1:<br>BOOL SetWallPaper(LPTSTR bmpPath)<br>{<br> BOOL res;<br> LPTSTR szFilePath;<br> strcpy(szFilePath,bmpPath);<br> res=SystemParametersInfo(SPI_SETDESKWALLPAPER,0,szFilePath,SPIF_SENDWININICHANGE);<br> //why here szFilePaht's data lost?<br> return res;<br>}<br>//function2:<br>BOOL SetWallPaper(CString bmpPath)<br>{<br> BOOL res;<br> LPTSTR szFilePath;<br> szFilePath=bmpPath.GetBuffer(100);<br> res=SystemParametersInfo(SPI_SETDESKWALLPAPER,0,szFilePath,SPIF_SENDWININICHANGE);<br> bmpPath.ReleaseBuffer();<br> return res;<br>}<br>// Here i call it<br>void CWallPaperDlg::OnButton1() <br>{<br> BOOL res=SetWallPaper(_T("c://windows//Lets_tech2_800.bmp"));<br> if(!res)<br> {<br> AfxMessageBox("Set WallPaper Failed!");<br> }<br> else<br> ::AfxPostQuitMessage(0); <br>}<br>Why the 2nd function work well,but the 1st one don't?<br>