用C++Builder实现桌布自动更新

出处:Examlink收集整理 作者:唐易龙 日期:2007年06月08日 15时29分
   

  在了解了与桌布相关的注册表的设置情况后,那我们就进入具体的桌布设置吧!
  
  #include
  
  //先在注册表里添好桌布样式,在设置桌布
  
  TRegistry *Registry = new TRegistry;
  try
  {
   Registry->OpenKey(“\\Control Panel\\Desktop”,false);
   Registry->WriteString("TileWallpaper","0");
   //设置桌布样式
  
   Registry->WriteString("WallpaperStyle",wallStyle);
  }
  __finally
  {
   delete Registry;
  }
  
  }
  
  //设置桌布
  
  SystemParametersInfo(SPI_SETDESKWALLPAPER, 0,FileName.c_str(),SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
  
  在此,我们已经解决了最为关键的问题,剩下的关于设置定时器那就简单了,只需用一个定时器组件即可完成.
  
  代码如下:
  
  void __fastcall TForm1::Timer1Timer(TObject *Sender)
  
  {
  
  if (ListBox1->Items->Count<=0)
  
  {
  
  return ;
  
  }
  
  if (index>=ListBox1->Items->Count)
  
  {
  
  index=0;
  
  }
  
  //如果是JPG格式就将其转换为BMP格式,将其存到临时文件夹中
  
  if(UpperCase(ListBox1->Items->Strings[index]).Pos(".JPG")||
  UpperCase(ListBox1->Items->Strings[index]).Pos(".JPEG"))
  
  {
  
  AnsiString fileName=ExtractFileName(ListBox1->Items->Strings[index]);
  
  int len=fileName.LastDelimiter(".");
  
  fileName=fileName.SubString(0,len-1)+".bmp";
  
  unsigned int *size=new unsigned int(256);
  
  char * buffer=new char[256];
  
  GetTempPath(*size,buffer);
  
  fileName=AnsiString(buffer)+fileName;
  
  JPEGToBMP(ListBox1->Items->Strings[index],fileName);    

最后更新时间:2008-03-28 12:39:15
文章评论
共有 0 位网友发表了评论
用户名: 新注册) 密码: 匿名评论 [查看所有评论]

评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
您可以用以下几种方式找到此文章

考试全流程