使用API函数SystemParametersInfo,注意this.textBox1.text中是文件名,文件类型是bmp格式

using System.Runtime.InteropServices;

[DllImport(
"user32.dll", CharSet = CharSet.Auto)]
        
public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);

        
private void button6_Click(object sender, EventArgs e)
        
{
            
int nResult;
            
if(File.Exists(this.textBox1.Text))
            
{
                nResult 
= SystemParametersInfo(201this.textBox1.Text, 0x1 | 0x2);
                
if(nResult==0)
                    MessageBox.Show(
"error");
                
else
                    MessageBox.Show(
"ok");    
            }

        }