高分,跪着爬着求代码,C#改变桌面背景图片. 高分,跪着爬着求代码,C#改变桌面背景图片.各位哥哥,请给详细的代码,详细的. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1、SystemParametersInfo 设定背景的API2、System.Drawing.Bitmap bm=new System.Drawing.Bitmap(strPathJpg); bm.Save(strPathBmp,System.Drawing.Imaging.ImageFormat.Bmp);,把jpg转成bmpusing System; using System.IO; using System.Runtime.InteropServices; using System.Text;using System.Windows;using System.Windows.Forms;namespace Desktop{ /// <summary> /// ClassDesktop 的摘要说明。 /// </summary> public class ClassDesktop { public string strPath=""; [DllImport("user32.dll", EntryPoint="SystemParametersInfo")] public static extern int SystemParametersInfo ( int uAction, int uParam, string lpvParam, int fuWinIni ); public ClassDesktop() { // // TODO: 在此处添加构造函数逻辑 // } public ClassDesktop(string strpath) { strPath=strpath; // // TODO: 在此处添加构造函数逻辑 // } /// <summary> /// 设置桌面背景 /// </summary> /// <param name="Path"></param> public void Desktop(string Path) { if (File.Exists(Path)) SystemParametersInfo(20, 0, Path, 0x2); // 0x1 | 0x2 } public void Font() { // System.IntPtr p=GetDC(0); //System.Drawing.Graphics g=System.Drawing.Graphics.FromHdc(p); } public void setDesktop() { //取得每天需要显示的图片 string strPathJpg=""; string strPathBmp=""; strPathJpg=Application.StartupPath+"\\"+DateTime.Today.Day.ToString()+".jpg "; strPathBmp=Application.StartupPath+"\\"+DateTime.Today.Day.ToString()+".bmp"; if (File.Exists(strPathBmp)) { this.Desktop(strPathBmp); } else { if (File.Exists(strPathJpg)) { // } else { MessageBox.Show(strPathJpg); return; } } //MessageBox.Show(strPathJpg); } }}引自:http://hi.baidu.com/cocoxili/blog/item/ed79e219cc5d104043a9ada8.html 关于运行程序过程中出现[遇到了用户定义的断点]错误 今天面试的题目 求助:最小化至托盘 遇到一个小问题,望兄弟们帮助! C# au3的基本函数功能如何在C#中使用 将从前用一个c/c++混合的win32程序移植到.net下(c#),如何能够尽量压缩工作量呢?谢先 有谁知道吗?谢谢! 紧急求救:怎么解决程序内存自动不断增长? 一个弱弱的问题,如何根据列的名字得到datagrid当前行的数据 如何判断机器在某时段内无人使用?或者说无任何响应事件发生?? 整了大半天的一个问题,要吐血了... 加快combobox的导入速度。
2、System.Drawing.Bitmap bm=new System.Drawing.Bitmap(strPathJpg);
bm.Save(strPathBmp,System.Drawing.Imaging.ImageFormat.Bmp);,把jpg转成bmpusing System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
using System.Windows.Forms;
namespace Desktop
{
/// <summary>
/// ClassDesktop 的摘要说明。
/// </summary>
public class ClassDesktop
{
public string strPath=""; [DllImport("user32.dll", EntryPoint="SystemParametersInfo")]
public static extern int SystemParametersInfo (
int uAction,
int uParam,
string lpvParam,
int fuWinIni
); public ClassDesktop()
{
//
// TODO: 在此处添加构造函数逻辑
//
} public ClassDesktop(string strpath)
{
strPath=strpath;
//
// TODO: 在此处添加构造函数逻辑
//
}
/// <summary>
/// 设置桌面背景
/// </summary>
/// <param name="Path"></param>
public void Desktop(string Path)
{
if (File.Exists(Path))
SystemParametersInfo(20, 0, Path, 0x2); // 0x1 | 0x2
}
public void Font()
{
// System.IntPtr p=GetDC(0);
//System.Drawing.Graphics g=System.Drawing.Graphics.FromHdc(p);
}
public void setDesktop()
{
//取得每天需要显示的图片
string strPathJpg="";
string strPathBmp="";
strPathJpg=Application.StartupPath+"\\"+DateTime.Today.Day.ToString()+".jpg ";
strPathBmp=Application.StartupPath+"\\"+DateTime.Today.Day.ToString()+".bmp";
if (File.Exists(strPathBmp))
{
this.Desktop(strPathBmp);
}
else
{
if (File.Exists(strPathJpg))
{
//
}
else
{
MessageBox.Show(strPathJpg);
return;
}
} //MessageBox.Show(strPathJpg); }
}
}引自:http://hi.baidu.com/cocoxili/blog/item/ed79e219cc5d104043a9ada8.html