Dear All,

 

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.IO;
  9. using System.Runtime.InteropServices;
  10. using System.Net;
  11.  
  12.  
  13. namespace WindowsFormsApplication5
  14. {
  15.     public partial class Form1 : Form
  16.     {
  17.         public Form1()
  18.         {
  19.             InitializeComponent();
  20.         }
  21.  
  22.        
  23.         [DllImport("user32.dll",CharSet = CharSet.Auto)]
  24.         private static extern int SystemParametersInfo(int uAction,int uParam,string lpvParam ,intuWinlni);
  25.  
  26.         private void Form1_Load(object sender, EventArgs e)
  27.         {
  28.  
  29.             WebClient WebWay = new WebClient();
  30.             string url = "";    //圖片的url
  31.             string NewFileName = ""; //圖片存檔於您的電腦時的新名稱   ※需適時加副檔名          
  32.             string FilePath = @"D:\" + NewFileName;   //存檔路徑,理所當然...邏輯區與資料夾需都存在=_=
  33.  
  34.             WebWay.DownloadFile(url, FilePath);   //利用WebWay這個方法下載至本機  參數...(下載路徑,存檔路徑)
  35.            
  36.  
  37.  
  38.             if (File.Exists(FilePath))  //判別檔案是否存在於對應的路徑
  39.             {
  40.  
  41.                 int Desktop = 0;
  42.  
  43.                 Desktop = SystemParametersInfo(201, FilePath, 0x1 | 0x2);  //存在成立,修改桌布  (uActuin 20 參數為修改wallpaper
  44.  
  45.             }
  46.             this.Close();   //執行結束 自動關閉> w <
  47.            
  48.  
  49.         }
  50.     }
  51. }
     
     
     
     
                                             ***** 記錄Domon的學習歷程*****

 

arrow
arrow
    全站熱搜

    Domon 發表在 痞客邦 留言(0) 人氣()