è¿éä»ç»çæ¯å©ç¨APIå½æ°ä¿®æ¹çªå£çèæ¯å¾ã
ç¨åºä»£ç
[DllImport("user32.dll",   EntryPoint="SystemParametersInfo")]  Â
  public   static   extern   int   SystemParametersInfo   (  Â
  int   uAction,  Â
  int   uParam,  Â
  string   lpvParam,  Â
  int   fuWinIni  Â
  );  Â
  SystemParametersInfo(20,   0,   @"C:/temp.bmp",   0x2); Â
å¨è¿ééè¦æ³¨æçæ¯SystemParametersInfoåªå¯¹bmpæ ¼å¼å¾çææï¼å¦æç´æ¥å§jpgåç¼æ¹æbmpæ¯æ æçï¼æ以éè¦æå¾ç转æ¢bmpã
ç¨åºä»£ç
    Bitmap bm=new Bitmap("temp.jpg");
    bm.Save("temp.bmp",System.Drawing.Imaging.ImageFormat.Bmp);
ä¸ä¼ æºç ï¼
ç¨åºä»£ç
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
using System.IO;
namespace Desktop
{
    /// <summary>
    /// DeskT çæè¦è¯´æã
    /// </summary>
    public class DeskT : System.Windows.Forms.Form
    {
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Button button2;
        private System.Windows.Forms.TextBox textBox1;
        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.GroupBox groupBox2;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.PictureBox pictureBox1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.OpenFileDialog openFileDialog1;
        private string filepath;
        /// <summary>
        ///Â å¿ éç设计å¨åéã
        /// </summary>
        private System.ComponentModel.Container components = null;
        [DllImport("user32.dll", CharSet=CharSet.Auto)]
        public static  extern int SystemParametersInfo (int uAction , int uParam , string lpvParam , int fuWinIni) ;
        public DeskT()
        {
            //
            // Windows çªä½è®¾è®¡å¨æ¯ææå¿ éç
            //
            InitializeComponent();
            //
            // TODO: å¨Â InitializeComponent è°ç¨åæ·»å ä»»ä½æé å½æ°ä»£ç
            //
        }
        /// <summary>
        ///Â æ¸ çæææ£å¨ä½¿ç¨çèµæºã
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if (components != null)Â
                {
                    components.Dispose();
                }
            }
            base.Dispose( disposing );
        }
        #region Windows Form Designer generated code
        /// <summary>
        /// 设计å¨æ¯ææéçæ¹æ³Â - ä¸è¦ä½¿ç¨ä»£ç ç¼è¾å¨ä¿®æ¹
        /// æ¤æ¹æ³çå 容ã
        /// </summary>
        private void InitializeComponent()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.label2 = new System.Windows.Forms.Label();
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.label1 = new System.Windows.Forms.Label();
            this.groupBox2 = new System.Windows.Forms.GroupBox();
            this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
            this.groupBox1.SuspendLayout();
            this.SuspendLayout();
            //Â
            // button1
            //Â
            this.button1.Location = new System.Drawing.Point(312, 62);
            this.button1.Name = "button1";
            this.button1.TabIndex = 0;
            this.button1.Text = "éæ©èæ¯";
            this.button1.Click += new System.EventHandler(this.button1_Click);
            //Â
            // button2
            //Â
            this.button2.Location = new System.Drawing.Point(312, 120);
            this.button2.Name = "button2";
            this.button2.TabIndex = 1;
            this.button2.Text = "æ´æ¢èæ¯";
            this.button2.Click += new System.EventHandler(this.button2_Click);
            //Â
            // textBox1
            //Â
            this.textBox1.Location = new System.Drawing.Point(16, 64);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(272, 21);
            this.textBox1.TabIndex = 2;
            this.textBox1.Text = "";
            //Â
            // groupBox1
            //Â
            this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                                    this.label2,
                                                                                    this.pictureBox1,
                                                                                    this.label1,
                                                                                    this.groupBox2,
                                                                                    this.button1,
                                                                                    this.button2,
                                                                                    this.textBox1});
            this.groupBox1.Location = new System.Drawing.Point(16, 16);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(392, 240);
            this.groupBox1.TabIndex = 3;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "æ´æ¢èæ¯å¾ç";
            //Â
            // label2
            //Â
            this.label2.Location = new System.Drawing.Point(8, 128);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(72, 23);
            this.label2.TabIndex = 6;
            this.label2.Text = "é¢è§å¾ç:";
            //Â
            // pictureBox1
            //Â
            this.pictureBox1.Location = new System.Drawing.Point(104, 120);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new System.Drawing.Size(184, 104);
            this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            this.pictureBox1.TabIndex = 5;
            this.pictureBox1.TabStop = false;
            //Â
            // label1
            //Â
            this.label1.Location = new System.Drawing.Point(24, 24);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(64, 23);
            this.label1.TabIndex = 4;
            this.label1.Text = "èæ¯å¾ç:";
            //Â
            // groupBox2
            //Â
            this.groupBox2.Location = new System.Drawing.Point(8, 104);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new System.Drawing.Size(376, 8);
            this.groupBox2.TabIndex = 3;
            this.groupBox2.TabStop = false;
            //Â
            // Form1
            //Â
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
            this.ClientSize = new System.Drawing.Size(432, 269);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                          this.groupBox1});
            this.MaximizeBox = false;
            this.Name = "Form1";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
            this.Text = "设置èæ¯";
            this.groupBox1.ResumeLayout(false);
            this.ResumeLayout(false);
        }
        #endregion
//Â Â Â Â Â Â Â Â ///Â <summary>
//        /// åºç¨ç¨åºçä¸»å ¥å£ç¹ã
//Â Â Â Â Â Â Â Â ///Â </summary>
//Â Â Â Â Â Â Â Â [STAThread]
//        static void Main()Â
//Â Â Â Â Â Â Â Â {
//            Application.Run(new DeskT());
//Â Â Â Â Â Â Â Â }
        private void button2_Click(object sender, System.EventArgs e)
        {
            int nResult ;
            if (File.Exists(filepath))
            {
                nResult = SystemParametersInfo(20, 0, filepath,  0x1 | 0x2 );
                if(nResult==0)
                    MessageBox.Show("没ææ´æ°æå!");
                else
                    MessageBox.Show("æ£å¨æ´æ¢èæ¯å¾ç...");
            }
            else
                MessageBox.Show("æ件ä¸åå¨!");
        }
        private void button1_Click(object sender, System.EventArgs e)
        {
            openFileDialog1.InitialDirectory = @"C:/";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = openFileDialog1.FileName;
                string[] strA=textBox1.Text.Split('.');
                Bitmap bm=new Bitmap(textBox1.Text);
                if(strA[1]!="bmp")
                {
                    filepath=strA[0]+".bmp";
                    bm.Save(filepath,System.Drawing.Imaging.ImageFormat.Bmp);
                }
                else
                    filepath=textBox1.Text;
                this.pictureBox1.Image=bm;
            }
        }
    }
}
å°å: http://www.officemail.net.cn/trackback.asp?tbID=166
Â