想做个屏保的功能...上网查了些资料...尝试着写出来然后运行
但是结果是完全没有效果..
不知道是哪里出了错
也用了 try...catch...但是没有任何提示...
希望有人做过的话来帮帮忙解决吧...
// 屏保状态
const uint SPI_SETSCREENSAVEACTIVE = 0x0011;
// 获取屏幕壁纸地址
const uint SPI_GETDESKWALLPAPER = 0x0073; [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool SystemParametersInfo(uint uAction, uint uParam, StringBuilder lpvParam, uint init); //设置屏保
public static void SetScreener()
{
try
{
bool ok;
StringBuilder str = new StringBuilder(100);
ok = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 1, str, 0);
}
catch (Exception)
{ throw;
}
} //取消屏保
public static void CancelScreener()
{
try
{
bool ok;
StringBuilder str = new StringBuilder(100);
ok = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, str, 0);
}
catch (Exception)
{ throw;
}
}
PS: 不要太关注于头像...那只是一张图片而已...
但是结果是完全没有效果..
不知道是哪里出了错
也用了 try...catch...但是没有任何提示...
希望有人做过的话来帮帮忙解决吧...
// 屏保状态
const uint SPI_SETSCREENSAVEACTIVE = 0x0011;
// 获取屏幕壁纸地址
const uint SPI_GETDESKWALLPAPER = 0x0073; [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool SystemParametersInfo(uint uAction, uint uParam, StringBuilder lpvParam, uint init); //设置屏保
public static void SetScreener()
{
try
{
bool ok;
StringBuilder str = new StringBuilder(100);
ok = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 1, str, 0);
}
catch (Exception)
{ throw;
}
} //取消屏保
public static void CancelScreener()
{
try
{
bool ok;
StringBuilder str = new StringBuilder(100);
ok = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, str, 0);
}
catch (Exception)
{ throw;
}
}
PS: 不要太关注于头像...那只是一张图片而已...
应该没到启动时间吧。 或者没激活程序。 参考下吧