예제 #1
0
        private void applyWallpaperWin7(string path)
        {
            Shell32.Shell           shell      = new Shell32.ShellClass();
            Shell32.Folder          folder     = shell.NameSpace(Path.GetDirectoryName(path)) as Shell32.Folder;
            Shell32.FolderItem      folderItem = folder.ParseName(System.IO.Path.GetFileName(path));
            Shell32.FolderItemVerbs vs         = folderItem.Verbs();

            bool wallpaperSet = false;

            for (int i = 0; i < vs.Count; i++)
            {
                Shell32.FolderItemVerb ib = vs.Item(i);

                if (ib.Name.Contains("&b") || ib.Name.Contains("&B"))
                {
                    if (ib.Name.ToLower().Contains("background") || ib.Name.ToLower().Contains("背景"))
                    {
                        wallpaperSet = true;
                        ib.DoIt();
                    }
                }
            }

            if (wallpaperSet == false)
            {
                applyWallpaperXP(path);
            }
            else
            {
                downloadAndApplyWallpaperSucceeded();
            }
        }
예제 #2
0
파일: KuanDai1.cs 프로젝트: cnucky/huan
        ///<summary>
        /// 程序开始前获取连接对象
        ///</summary>
        public void Start()
        {
            try {
                SetNetworkAdapter(adslName);//获取“连接”或“断开”对象
                if (disconnect != null)
                {
                    disconnect.DoIt();
                    Thread.Sleep(2000);
                    SetNetworkAdapter(adslName);//获取“连接”对象
                    while (true)
                    {
                        if (connection != null)
                        {
                            break;
                        }
                        SetNetworkAdapter(adslName);
                        Thread.Sleep(500);
                    }
                    connection.DoIt();
                    AdslReconnect.DoAdsl(adslUserName, adslPasswd);
                }
                else
                {
                    connection.DoIt();
                    AdslReconnect.DoAdsl(adslUserName, adslPasswd);
                    SetNetworkAdapter(adslName);//获取“断开”对象
                }
            } catch {
            }
            Ping pingSender = new Ping();

            while (true)
            {
                try {
                    PingReply reply = pingSender.Send("www.google.com", 100);
                    if (reply.Status == IPStatus.Success)
                    {
                        Thread.Sleep(500);
                        break;
                    }
                } catch {
                }
            }
        }
 protected override void OnClick(EventArgs e)
 {
     base.OnClick(e);
     //
     try
     {
         _verb.DoIt();
     }
     catch { }
 }