自动更改桌面背景 c/c++ win32
这个程序仅供编程参考
若想在平时用,请下载微软的wallpaper changer
我这个程序实现了定时更换桌面背景的功能
命令行 wallpaper "your images' directory path" time_in_minute
编程要点
findfirstfile findnextfile 查找图像文件
SystemParametersInfo 修改系统信息,在这儿当然是桌面背景
注册表操作 保存信息
如果做得实用,应加入开机启动功能,自然还要gui
//wallpaper.c
//by onezeros@yahoo.cn||Zhijie Lee
//usage:wallpaper "full directory path" interval
// interval is in minutes
#include <windows.h>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
/* argc=3;
argv[1]="E:\\picture\\testbmp";
argv[2]="1";
*/ LPCSTR currentDir;
LPCSTR currentImage;
int interval;
HKEY hKey;
WIN32_FIND_DATAA FileData;
HANDLE hFind;
//initialize parameters
if(argc==1){
//find parameters in registry
if(RegOpenKeyA(HKEY_LOCAL_MACHINE,(LPCSTR)"Software\\wallpaper",
&hKey)!=ERROR_SUCCESS||
RegQueryValueExA(hKey,(LPCSTR)"interval",0,NULL,
(LPBYTE)interval,NULL)!=ERROR_SUCCESS||
RegQueryValueExA(hKey,(LPCSTR)"directory",0,NULL,
(LPBYTE)currentDir,NULL)!=ERROR_SUCCESS||
RegQueryValueExA(hKey,(LPCSTR)"image",0,NULL,
(LPBYTE)currentImage,NULL)!=ERROR_SUCCESS){
//if connot be found ,wrong usage
cout<<"wrong usage"<<endl
<<"Please use it like this"<<endl
<<"wallpaper \"D:\\Files\\Images\" 30"<<endl
<<"30 is the interval in minutes or"<<endl
<<"wallpaper \"D:\\Files\\Images\""<<endl
<<"with 30 minutes as default interval"<<endl;
exit(1);
}else{
hFind=FindFirstFileA(currentImage,&FileData);
if(hFind==INVALID_HANDLE_VALUE){
cout<<"connot open file";
exit(1);
}
}
}else if(argc==3){
interval=60000*atoi(argv[2]);
currentDir=(LPCSTR)argv[1];
SetCurrentDirectoryA(currentDir);
hFind = FindFirstFileA((LPCSTR)"*.jpg",&am
相关文档:
Boss说,要看OpenGL,看了快一个月,总算出了个像样的东西,用C写了个3D迷宫,
虽然只有350行
代码,不过边学边写,足足写了一周时间,还是小有成就感的,活活活!
&n ......
c 函数指针
以前什么函数指针,指针函数仅仅是概念上的理解,最近写个程序有这么个需求,其实也不是有这么个需求,而是这样写可以省去很多事....search了下,找到一篇好文
函数指针是什么?
先来看函数调用是怎么回事。一个函数占用一段连续内存。当调用一个函数时,实际上是跳转到函数入口地址,执 ......
1. 下载SQLitewindows版
我们可以从下列网站下载sqlite的windows版。
http://www.sqlite.com.cn/bbs/topicdisp.asp?tid=182&topage=1#gotolast
下载这个三个文件:
SQLite 3.3.7 下载
windows版
sqlite-3_3_7.zip 这个是SQLite的windows可执行文件
sqlitedll-3_3_7.zip 这个 ......
链表中有两个关键的操作:创建和删除。今天我就对这两个操作进行介绍,
从这两个操作中学习到链表的基本用法。
1. Create
Create() 是一个链表基础,只有建立好链表才能对它进行相应的查找,删除 等。
基本算法:
1.初始化
head=NULL;
......
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <windows.h>
#include <iostream>
using namespace std;
class student{
private:
char name[20],addr[40];
char id_number[40],phone[20];
public:
void searchstud_info();
void ......