更换桌面背景

using  System.Runtime.InteropServices;



        [DllImport(
" user32.dll " , CharSet  =  CharSet.Auto)]
        
public   static   extern   int  SystemParametersInfo( int  uAction,  int  uParam,  string  lpvParam,  int  fuWinIni);
//因为SystemParametersInfo只支持BMP格式图片,所以先要将图片换成BMP
 String tpath 
=  ((FileInfo)pictureList[a]).FullName;
            Bitmap bm 
=   new  Bitmap(tpath);
            String path 
=  ((FileInfo)pictureList[a]).DirectoryName;
            path 
=  path  +   " /ZwlylAutoDesktop.bmp " ;
            bm.Save(path, System.Drawing.Imaging.ImageFormat.Bmp);



            
int  nResult;
            
if  (File.Exists(tpath))
            
{
                nResult 
= SystemParametersInfo(201, path, 0x1 | 0x2);//20表示更换桌面背景

            }

            File.Delete(path);