屏幕保护有三个参数
/p 显示预览
/s 显示设置
/c 屏幕保护
用args[0]就能读出来
当判断是"/p"可以不管.
当判断是"/s"的时候就新建一个窗口,然后将屏幕保护的参数保存到某ini中
当判断是其他的时候就显示一个全屏窗口,并将窗口置顶,再设置鼠标移动事件退出程序
编译后生成的exe文件把它改成src文件,复制到windows/system32下就可以在windows里设置了...
/**屏保程序--源代码及关键源代码注解如下:*/#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <graphics.h>
#include <math.h>
#include <bios.h>
#include<stdlib.h>
void Clock_f()/*时钟*/
{
int gd=DETECT,gm,no,rad=210
struct time t
float theta,x,y,x1,y1,theta1,theta2
char des[40],ch
initgraph(&gd,&gm,"")
setcolor(14)
circle(320,240,180)
circle(320,240,15)
setcolor(BLACK)
circle(320,240,170)
circle(320,240,165)
circle(320,240,158)
circle(320,240,16)
setcolor(11)
for(theta=0.0,no=0no<60no++,theta+=.1047)
{
if(no%5==0)
{
x=320+158*cos(theta)
y=240+158*sin(theta)
}
else
{
x=320+165*cos(theta)
y=240+165*sin(theta)
}
x1=320+170*cos(theta)
y1=240+170*sin(theta)
line(x,y,x1,y1)
}
settextjustify(CENTER_TEXT,CENTER_TEXT)
setcolor(YELLOW)
for(no=1,theta=5.236no<=12no++,theta+=.524)
{
x=320+rad*cos(theta)
y=240+rad*sin(theta)
settextstyle(GOTHIC_FONT,HORIZ_DIR,5)
sprintf(des,"%d",no)
outtextxy(x,y,des)
}
gettime(&t)
theta1=(.0175*6*t.ti_min)-1.5708
theta2=(.0175*30*(t.ti_hour%12+t.ti_min/60.0))-1.5708
while(bioskey(1)==0)
{
gettime(&t)
theta=(.0175*6*t.ti_sec)-1.5708
x=320+15*cos(theta)
y=240+15*sin(theta)
x1=320+150*cos(theta)
y1=240+150*sin(theta)
setcolor(11)
setlinestyle(SOLID_LINE,1,1)
line(x,y,x1,y1)
sound(7000)
delay(100)
nosound()
delay(900)
setcolor(BLACK)
line(x,y,x1,y1)
setlinestyle(SOLID_LINE,1,3)
x=320+15*cos(theta1)
y=240+15*sin(theta1)
x1=320+150*cos(theta1)
y1=240+150*sin(theta1)
line(x,y,x1,y1)
x=320+15*cos(theta2)
y=240+15*sin(theta2)
x1=320+100*cos(theta2)
y1=240+100*sin(theta2)
line(x,y,x1,y1)
theta1=(.0175*6*(t.ti_min+t.ti_sec/60.0))-1.5708
x=320+15*cos(theta1)
y=240+15*sin(theta1)
x1=320+150*cos(theta1)
y1=240+150*sin(theta1)
setcolor(14)
line(x,y,x1,y1)
circle(320,240,15)
theta2=(.0175*30*(t.ti_hour%12+t.ti_min/60.0))-1.5708
x=320+15*cos(theta2)
y=240+15*sin(theta2)
x1=320+100*cos(theta2)
y1=240+100*sin(theta2)
line(x,y,x1,y1)
}
getch()
closegraph()
}
void Boom_f(void)/*礼花*/
{
int gd=DETECT, gm
int maxx=0, maxy=0, midx=0, midy=0, a=0, b=0, x=0, y=0, k=0
initgraph(&gd, &gm, "")
maxx=getmaxx(), maxy=getmaxy(), midx=maxx/2, midy=maxy/2
randomize()
while(bioskey(1)==0)
{
x=60
y=50
for(b=-100b<=100b+=10)
{
k=random(15)
if(k==0)k=1
for(a=0a<=50a++)
{
{
putpixel((midx+a)+b, (midy+a)+b, k)
putpixel((midx+a)+b, (midy-a)+b, k)
putpixel((midx-a)+b, (midy+a)+b, k)
putpixel((midx-a)+b, (midy-a)+b, k)}
putpixel((midx)+b, (midy+a)+b, k+8)
putpixel((midx)+b, (midy-a)+b, k+8)
putpixel((midx+a)+b, (midy)+b, k+8)
putpixel((midx-a)+b, (midy)+b, k+8)
putpixel((midx+a)+b+x, (midy+a)+b+y, k)
putpixel((midx+a)+b+x, (midy-a)+b+y, k)
putpixel((midx-a)+b+x, (midy+a)+b+y, k)
putpixel((midx-a)+b+x, (midy-a)+b+y, k)
putpixel((midx)+b+x, (midy+a)+b+y, k+8)
putpixel((midx)+b+x, (midy-a)+b+y, k+8)
putpixel((midx+a)+b+x, (midy)+b+y, k+8)
putpixel((midx-a)+b+x, (midy)+b+y, k+8)
putpixel((midx+a)+b-x, (midy+a)+b-y, k)
putpixel((midx+a)+b-x, (midy-a)+b-y, k)
putpixel((midx-a)+b-x, (midy+a)+b-y, k)
putpixel((midx-a)+b-x, (midy-a)+b-y, k)
putpixel((midx)+b-x, (midy+a)+b-y, k+8)
putpixel((midx)+b-x, (midy-a)+b-y, k+8)
putpixel((midx+a)+b-x, (midy)+b-y, k+8)
putpixel((midx-a)+b-x, (midy)+b-y, k+8)
putpixel((midx+a)+b+x, (midy+a)+b-y, k)
putpixel((midx+a)+b+x, (midy-a)+b-y, k)
putpixel((midx-a)+b+x, (midy+a)+b-y, k)
putpixel((midx-a)+b+x, (midy-a)+b-y, k)
putpixel((midx)+b+x, (midy+a)+b-y, k+8)
putpixel((midx)+b+x, (midy-a)+b-y, k+8)
putpixel((midx+a)+b+x, (midy)+b-y, k+8)
putpixel((midx-a)+b+x, (midy)+b-y, k+8)
putpixel((midx+a)+b-x, (midy+a)+b+y, k)
putpixel((midx+a)+b-x, (midy-a)+b+y, k)
putpixel((midx-a)+b-x, (midy+a)+b+y, k)
putpixel((midx-a)+b-x, (midy-a)+b+y, k)
putpixel((midx)+b-x, (midy+a)+b+y, k+8)
putpixel((midx)+b-x, (midy-a)+b+y, k+8)
putpixel((midx+a)+b-x, (midy)+b+y, k+8)
putpixel((midx-a)+b-x, (midy)+b+y, k+8)
/*beginning if(a<36)*/
circle((midx+a)+b, (midy+a)+b, k)
circle((midx+a)+b, (midy-a)+b, k)
circle((midx-a)+b, (midy+a)+b, k)
circle((midx-a)+b, (midy-a)+b, k)
circle((midx)+b, (midy+a)+b, k+8)
circle((midx)+b, (midy-a)+b, k+8)
circle((midx+a)+b, (midy)+b, k+8)
circle((midx-a)+b, (midy)+b, k+8)
circle((midx+a)+b+x, (midy+a)+b+y, k)
circle((midx+a)+b+x, (midy-a)+b+y, k)
circle((midx-a)+b+x, (midy+a)+b+y, k)
circle((midx-a)+b+x, (midy-a)+b+y, k)
circle((midx)+b+x, (midy+a)+b+y, k+8)
circle((midx)+b+x, (midy-a)+b+y, k+8)
circle((midx+a)+b+x, (midy)+b+y, k+8)
circle((midx-a)+b+x, (midy)+b+y, k+8)
circle((midx+a)+b-x, (midy+a)+b-y, k)
circle((midx+a)+b-x, (midy-a)+b-y, k)
circle((midx-a)+b-x, (midy+a)+b-y, k)
circle((midx-a)+b-x, (midy-a)+b-y, k)
circle((midx)+b-x, (midy+a)+b-y, k+8)
circle((midx)+b-x, (midy-a)+b-y, k+8)
circle((midx+a)+b-x, (midy)+b-y, k+8)
circle((midx-a)+b-x, (midy)+b-y, k+8)
circle((midx+a)+b+x, (midy+a)+b-y, k)
circle((midx+a)+b+x, (midy-a)+b-y, k)
circle((midx-a)+b+x, (midy+a)+b-y, k)
circle((midx-a)+b+x, (midy-a)+b-y, k)
circle((midx)+b+x, (midy+a)+b-y, k+8)
circle((midx)+b+x, (midy-a)+b-y, k+8)
circle((midx+a)+b+x, (midy)+b-y, k+8)
circle((midx-a)+b+x, (midy)+b-y, k+8)
circle((midx+a)+b-x, (midy+a)+b+y, k)
circle((midx+a)+b-x, (midy-a)+b+y, k)
circle((midx-a)+b-x, (midy+a)+b+y, k)
circle((midx-a)+b-x, (midy-a)+b+y, k)
circle((midx)+b-x, (midy+a)+b+y, k+8)
circle((midx)+b-x, (midy-a)+b+y, k+8)
circle((midx+a)+b-x, (midy)+b+y, k+8)
circle((midx-a)+b-x, (midy)+b+y, k+8)
delay(25)
cleardevice()
}
}
}
closegraph()
}
void main(void)
{
int nChoice
do
{
printf("\n\t1. CLOCK\n")
printf("\t2. BOOM\n")
printf("\t3. EXIT\n")
scanf("%d",&nChoice)
switch(nChoice)
{
case 1:
Clock_f()
break
case 2:
Boom_f()
break
case 3:
break
default:
printf("input again\n")
}
}while(nChoice!=3)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)