用C++Builder 5开发Windows下的屏保

屏幕保护程序(自己写的) 有关自己设计的一个屏幕保护的程序,里面包含了屏保的特效,设置以及背景图切换图片框图片。通过winform窗体设计里的几种控件与属性完成 立即下载

E_Mail:codehunter@sohu.com

摘要:本文通过一个具体的程序演示了Windows下的屏幕保护程序的实现过程。
一. 引言
视窗系统下的屏幕保护程序是一个基于命令行(Command Line)的应用程序。当屏保
程序被调用时操作系统就用具体的命令行执行该程序。本文组织和处理了所有的命令行,包
括“/p”,“/s”,“/c”,“/a”,其中“/p”表示让屏保在预览窗口中显示;“/s”表示真正运行
屏保;“/c”表示调用设置对话框;而“/a”表示调用密码设置对话框(WinNT中无效)。本
程序尽可能简单地实现一个全功能的屏保,运行Windows的屏保设置程序时你既可以修改
密码(WinNT中无效)又可以设置图片显示的频率并把频率数值保存到注册表里。当屏保
运行时图片以你设置的频率改变显示位置。笔者还留了个作业给读者,请看图1中的选择图
片文件夹这个项目,按下浏览按钮可以设置图片的路径,笔者已经实现了浏览按钮的功能并
把得到的路径也保存到注册表中,并让屏保启动时读picdir的值,picdir等于"no"时的代码
笔者已实现了,picdir不等于"no"时的代码由读者实现。也就是让读者实现一个能把picdir
目录里的图片轮流显示的屏保程序。

二. 实现方法
首先介绍几个API函数。
WinMain函数:
int WINAPI WinMain(
        HINSTANCE hInstance, // 当前实例句柄
    HINSTANCE hPrevInstance, // 前一个实例句柄
    LPSTR lpCmdLine, // 指向命令行参数的指针(本程序要利用的参数)
    int nCmdShow  // 窗口的状态
   );
GetWindowLong函数:得到指定窗口信息的函数
    LONG GetWindowLong(
         HWND hWnd, file://窗口句柄
         int nIndex  file://指定返回的信息
       );
SetWindowLong函数:改变窗口属性
    LONG SetWindowLong(
    HWND hWnd, file://窗口句柄
    int nIndex, // 指定要设定的值的信息
    LONG dwNewLong  // 新值
   );
SetParent函数:改变指定窗口的父窗口
   HWND SetParent(
    HWND hWndChild, file://要改变父窗体的窗口句柄
    HWND hWndNewParent  file://新的父窗体的句柄
   );
GetClientRect函数:得到窗口的客户区
    BOOL GetClientRect(
    HWND hWnd, // 窗口句柄
    LPRECT lpRect  file://RECT结构的地址
   );
SetWindowPos函数:改变窗口的大小,位置,顶级窗口等
BOOL SetWindowPos(
HWND hWnd, // 窗口句柄
    HWND hWndInsertAfter, // 布置窗口顺序的句柄(Z order)
    int X, // horizontal position
    int Y, // vertical position
    int cx, // width
    int cy, // height
    UINT uFlags  // 窗口位置等标记
   );
SystemParametersInfo函数:访问或设置系统级的参数
    BOOL SystemParametersInfo(
    UINT uiAction, // 指定要获取或设置的系统参数
    UINT uiParam, // depends on action to be taken
    PVOID pvParam, // depends on action to be taken
    UINT fWinIni  // 用户配置文件是否改变标记
   );
ShowCursor函数:显示或隐藏光标
int ShowCursor(
BOOL bShow  // 鼠标可见度标记 
   );
GetVersion函数:获取系统的版本信息
DWORD GetVersion(VOID)

以上API函数的具体信息可以查找有关MSSDK文档。了解了基本函数后笔者简述一
下实现方法。
1. 新建一工程,增加两个窗体,将三个窗体分别取名为MainForm,FrmConfig,
FrmControl。在MainForm和FrmControl窗体上各添加一个Timer控件和TImage控件,
把两窗体的BorderStyle设为bsNone,背景色设为黑色。在两个窗体的TImage上各加一
张图片,FrmControl大小设为:高130像素,宽160像素,Timage的Stretch属性设为真
值。FrmConfig的样式如图1。
2. 保存工程文件为screensaver.cpp,其它单元分别存为Unitmain.cpp,
Unitcontrol.cpp,Unitconfig.cpp。
3. 编写代码,具体代码见第三部分的源程序。
4. 编译成可执行文件,并把文件扩展名改为scr。
5. 最后把屏保程序拷贝到windows目录下就可以测试了。如果一切正常的话你将会看
到图片在屏幕上以随机的位置显示。
                                    图1
三. 源代码
以下是本程序的所有的源代码,其中screensaver.cpp, Unitmain.cpp是核心代码。
/*{*******************************}*/
/*{***** screensaver.cpp  ****}*/
/*{*******************************}*/
file://---------------------------------------------------------------------------
#include
#pragma hdrstop
USERES("screensaver.res");
USEFORM("Unitmain.cpp", Frmmain);
USEFORM("Unitconfig.cpp", FrmConfig);
USEFORM("Unitcontrol.cpp", FrmControl);
file://---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR p, int)//“p"是指向命令行参数的指针
{ String StartType;
  AnsiString Command=p,temp;
  HWND CPWindow =NULL;
  if(Command=="")
   StartType = "/c";
  else
   StartType=Command.SubString(1,2);//获取命令行的前两个参数
        try
        {
                 Application->Initialize();
                 if(StartType=="/c")//启动设置窗口
                   Application->CreateForm(__classid(TFrmConfig), &FrmConfig);
                 else if(StartType=="/s")启动屏保
                   Application->CreateForm(__classid(TFrmmain), &Frmmain);
                 else if(StartType=="/p")//预览
                  {
                   Application->CreateForm(__classid(TFrmControl), &FrmControl);
                   temp=Command.SubString(3,Command.Length()-2);//获取命令行中的屏保预览窗
口句柄的字符串形式
                   CPWindow =(long *)temp.ToInt();//将预览窗口句柄的字符串形式强制转换为长整形
指针

                   RECT *lookrect;//建立一个RECT结构指针
                   Long style=GetWindowLong(Application->MainForm->Handle,GWL_STYLE);//获
取FrmControl窗口的风格
                   style=style|WS_CHILD;
                   SetWindowLong(Application->MainForm->Handle,GWL_STYLE,style);//设置窗口
为子窗口
                   SetParent(Application->MainForm->Handle,CPWindow);//设置屏保预览窗口为
FrmControl的父窗口
                   GetClientRect(CPWindow,lookrect);//获取屏保预览窗口的客户区
                  
SetWindowPos(Application->MainForm->Handle,HWND_TOP,0,0,lookrect->right,lookrect->bottom ,SW
P_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW);//将FrmControl的窗口覆盖屏保预览窗口
的客户区,并显示它
                   }
                 else if(StartType=="/a")//启动密码设置窗口
                  {
                   temp=Command.SubString(3,Command.Length()-2);
                   CPWindow =(long *)temp.ToInt();
                  file://以下是动态调用mpr.dll里的PwdChangePasswordA函数的过程
                   typedef UINT(CALLBACK *FUN)(LPSTR,HWND,UINT,UINT);
                   HINSTANCE hDll=LoadLibrary("mpr.DLL");
                   FUN myfun;
                   if(hDll!=NULL)
                    {
                     myfun=(FUN)GetProcAddress(hDll,"PwdChangePasswordA");
                     if(!myfun)FreeLibrary(hDll);
                     else
                     myfun("SCRSAVE", CPWindow, 0, 0);//函数的调用
                    }
                  }
                 Application->Run();
        }
        catch (Exception &exception)
        {
                 Application->ShowException(&exception);
        }
        return 0;
}
file://---------------------------------------------------------------------------
/*{*******************************}*/
/*{*****   Unitmain.h     ****}*/
/*{*******************************}*/
file://---------------------------------------------------------------------------

#ifndef UnitmainH
#define UnitmainH
file://---------------------------------------------------------------------------
#include
#include
#include
#include
#include
#include
#include
file://---------------------------------------------------------------------------
class TFrmmain : public TForm
{
__published: // IDE-managed Components
        TTimer *Timer1;
        TImage *Image1;
        void __fastcall FormCreate(TObject *Sender);
        void __fastcall FormKeyDown(TObject *Sender, WORD &Key,
          TShiftState Shift);
        void __fastcall FormMouseDown(TObject *Sender, TMouseButton Button,
          TShiftState Shift, int X, int Y);
        void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose);
        void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
        void __fastcall Image1MouseDown(TObject *Sender,
          TMouseButton Button, TShiftState Shift, int X, int Y);
        void __fastcall Image1MouseMove(TObject *Sender, TShiftState Shift,
          int X, int Y);
        void __fastcall Timer1Timer(TObject *Sender);
private: // User declarations
       DWORD PWProtect;
       DWORD Version;
       String picdir;
       int frequence;
public: // User declarations
        __fastcall TFrmmain(TComponent* Owner);
};
file://---------------------------------------------------------------------------
extern PACKAGE TFrmmain *Frmmain;
file://---------------------------------------------------------------------------
#endif
file://---------------------------------------------------------------------------
/*{*******************************}*/
/*{*****  Unitmain.cpp   ****}*/
/*{*******************************}*/
file://---------------------------------------------------------------------------
#include
#pragma hdrstop
#include
#include "Unitmain.h"
#include
file://---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFrmmain *Frmmain;
file://---------------------------------------------------------------------------
__fastcall TFrmmain::TFrmmain(TComponent* Owner)
        : TForm(Owner)
{
}
file://---------------------------------------------------------------------------
void __fastcall TFrmmain::FormCreate(TObject *Sender)
{
    file://使窗口成为最顶层的窗口
    SetWindowPos(this->Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
    file://时窗口覆盖屏幕
    this->Width=Screen->Width;
    this->Height=Screen->Height;
    this->Top=0;
    this->Left=0;
    Version=GetVersion();
    TRegistry *Registry = new TRegistry;
  try
  {
    if(Version>0x80000000){
    Registry->RootKey =HKEY_CURRENT_USER;
    Registry->OpenKey("//Control Panel//Desktop",false);
    PWProtect=Registry->ReadInteger("ScreenSaveUsePassword");//检测是否密码保护
    Registry->CloseKey();}
    Registry->RootKey =HKEY_CURRENT_USER;
    Registry->OpenKey("//Software//CODEHUNTER", true);
    picdir=Registry->ReadString("PicDir");//得到图片目录
    frequence=Registry->ReadInteger("frequence");//得到图像显示的频率
    if(picdir=="")picdir="no";
    if(frequence<0||frequence>6)
     frequence=2;
    Timer1->Interval=1000*frequence;设置定时器
  }
  __finally
  {
    delete Registry;
    picdir="no";
  }
    file://检测是否运行于 NT下
    if(Version!=0)
    if(PWProtect&&Version>0x80000000)//如果系统要求密码保护并此系统为非NT那么把系统设为屏保
状态
     SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, 0, 0);
    file://使光标消失
    while (!ShowCursor(false)< -5);
}
file://---------------------------------------------------------------------------
void __fastcall TFrmmain::FormKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
this->Close();
}
file://---------------------------------------------------------------------------
void __fastcall TFrmmain::FormMouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
this->Close();
}
file://---------------------------------------------------------------------------
void __fastcall TFrmmain::FormCloseQuery(TObject *Sender, bool &CanClose)
{
if (PWProtect && Version>0x80000000)
      {
        bool PassChck;
       file://显示光标,并调用密码对话框
        while(!ShowCursor(True) > 5);
       file://以下是VerifyScreenSavePwd函数的动态调用
        typedef UINT(CALLBACK *FUN)(HWND);
                   HINSTANCE hDll=LoadLibrary("password.cpl");
                   FUN myfun;
                   if(hDll!=NULL)
                    {
                     myfun=(FUN)GetProcAddress(hDll,"VerifyScreenSavePwd");
                     if(!myfun)FreeLibrary(hDll);
                     else
                     PassChck=myfun(this->Handle);
                    }
        if(PassChck == false)
          {
            while(!ShowCursor(False) < -5);
            CanClose = false;
           }
      }
}
file://---------------------------------------------------------------------------

void __fastcall TFrmmain::FormClose(TObject *Sender, TCloseAction &Action)
{
while(!ShowCursor(True) > 5);
    if(PWProtect&&Version>0x80000000)
        SystemParametersInfo(SPI_SCREENSAVERRUNNING, 0, 0, 0);//退出屏保状态
}
file://---------------------------------------------------------------------------
void __fastcall TFrmmain::Image1MouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
this->Close();
}
file://---------------------------------------------------------------------------
void __fastcall TFrmmain::Image1MouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{   static int MouseMoves=0;
    MouseMoves = MouseMoves + 1;
    if(MouseMoves >4)
     {
     this->Close();
     MouseMoves = 0 ;
     }
}
file://---------------------------------------------------------------------------
void __fastcall TFrmmain::Timer1Timer(TObject *Sender)
{
if(picdir=="no")
{
int i ;
randomize();
i=rand()%2;
if(i==0)
i=-1;
else
i=1;
Image1->Top=i*(rand()%this->Height);
Image1->Left=i*(rand()%this->Width);
}
}
file://---------------------------------------------------------------------------
/*{*******************************}*/
/*{*****   Unitcontrol.h   ****}*/
/*{*******************************}*/
file://---------------------------------------------------------------------------
#ifndef UnitcontrolH
#define UnitcontrolH
file://---------------------------------------------------------------------------
#include
#include
#include
#include
#include
#include
#include
file://---------------------------------------------------------------------------
class TFrmControl : public TForm
{
__published: // IDE-managed Components
        TImage *Image1;
        TTimer *Timer1;
        void __fastcall Timer1Timer(TObject *Sender);
        void __fastcall FormCreate(TObject *Sender);
private: // User declarations
public: // User declarations
        __fastcall TFrmControl(TComponent* Owner);
};
file://---------------------------------------------------------------------------
extern PACKAGE TFrmControl *FrmControl;
file://---------------------------------------------------------------------------
#endif
file://---------------------------------------------------------------------------
/*{*******************************}*/
/*{*****   Unitcontrol.cpp ****}*/
/*{*******************************}*/
file://---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "Unitcontrol.h"
file://---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFrmControl *FrmControl;
file://---------------------------------------------------------------------------
__fastcall TFrmControl::TFrmControl(TComponent* Owner)
        : TForm(Owner)
{
}
file://---------------------------------------------------------------------------
void __fastcall TFrmControl::Timer1Timer(TObject *Sender)
{
int i ;
randomize();
i=rand()%2;
if(i==0)
i=-1;
else
i=1;
Image1->Top=i*(rand()%this->Height);
Image1->Left=i*(rand()%this->Width);
}
file://---------------------------------------------------------------------------
void __fastcall TFrmControl::FormCreate(TObject *Sender)
{
Image1->Top=0;
Image1->Left=0;
Image1->Height=this->Height ;
Image1->Width=this->Width ;
}
file://---------------------------------------------------------------------------
/*{*******************************}*/
/*{*****    Unitconfig.h   ****}*/
/*{*******************************}*/
file://---------------------------------------------------------------------------
#ifndef UnitconfigH
#define UnitconfigH
file://---------------------------------------------------------------------------
#include
#include
#include
#include
#include
#include
#include
#include
file://---------------------------------------------------------------------------
class TFrmConfig : public TForm
{
__published: // IDE-managed Components
        TPanel *Panel1;
        TButton *Button1;
        TPanel *Panel2;
        TLabel *Label1;
        TTrackBar *TrackBar1;
        TLabel *Label2;
        TLabel *Label3;
        TLabel *Label4;
        TButton *Button2;
        void __fastcall Button1Click(TObject *Sender);
        void __fastcall Button2Click(TObject *Sender);
private: // User declarations
  AnsiString picdir;
  int frequence;
public: // User declarations
        __fastcall TFrmConfig(TComponent* Owner);
};
file://---------------------------------------------------------------------------
extern PACKAGE TFrmConfig *FrmConfig;
file://---------------------------------------------------------------------------
#endif
file://---------------------------------------------------------------------------
/*{*******************************}*/
/*{*****   Unitconfig.cpp  ****}*/
/*{*******************************}*/
file://---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "Unitconfig.h"
file://---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFrmConfig *FrmConfig;
file://---------------------------------------------------------------------------
__fastcall TFrmConfig::TFrmConfig(TComponent* Owner)
        : TForm(Owner)
{
}
file://---------------------------------------------------------------------------
void __fastcall TFrmConfig::Button1Click(TObject *Sender)
{
if(SelectDirectory("Select Picture Dir","",picdir))
   Panel2->Caption=picdir;
}
file://---------------------------------------------------------------------------
void __fastcall TFrmConfig::Button2Click(TObject *Sender)
{
file://把信息写入注册表
if(picdir=="") picdir="no";
this->frequence=TrackBar1->Position;
TRegistry *Reg = new TRegistry;
  try
   {
    Reg->RootKey = HKEY_CURRENT_USER;
    if (Reg->OpenKey("//Software//CODEHUNTER", true))
    {
      Reg->WriteString("PicDir",picdir);
      Reg->WriteInteger("frequence",frequence);
      Reg->CloseKey();
    }
  }
  __finally
  {
    delete Reg;
  }
this->Close();
}
file://---------------------------------------------------------------------------
                                                                 
源代码下载(http://codehunter.1yes.net/download/lucysaver.zip)

十二星座气泡屏保C++程序源码 在借鉴别人的程序基础上,用C++开发的十二星座气泡屏保程序,包含源码及安装详细步骤,运行环境(本人测试了win7 x64(透明背景),win10(黑色背景)) 立即下载

相关推荐

C++Builder屏保程序含代码

BCB4制作的屏保程序,提供给BCB初学者

C/C++开发,计算机使用护眼程序

通过一个win小服务定期锁屏或调用屏保进行计算机使用时长提醒

技术需要分享 1031

C++简单屏保论文更适合基础简单的C++学习

API函数编写!函数简单易懂,适合学生答辩使用!

C语言之回调函数

编程时各个模块(函数)从应用到底层分成多个层,确保所有的函数调用关系是从上(main函数)到下,确保单项依赖,这样上层的模块就更容易被更换 回调函数就是将双向依赖改为单项依赖的工具 代码实现 callback调用参数(就是传进来的函数) 不同的方法 再如 #include <stdio.h> //返回值(*指针名)(参数列表) typedef int (*callback)(int,int); //回调函数 int ADD(callback p, int a, int b){

Arithmetic-logic 253

界面漂亮的VC++屏幕保镖(锁屏程序)及源代码

内容索引:VC/C++源码,系统相关,锁屏  VC++屏幕保镖,也就是常见的锁屏程序,保护你的计算机在你离开的时候不受别人干扰,这是实现的源代码,另外它的界面是不是很漂亮,这也是这个小程序的亮点哦。

Linux内核模块开发实战指南(2025版)

2025年Linux内核模块开发迎来革命性突破!本文将从零开始手把手教你构建可动态加载的AI加速驱动模块,揭秘最新内核特性与开发技巧,更包含独家性能调优方案与跨架构移植秘籍。文末附赠价值百万的调试脚本,助你轻松突破开发瓶颈!

资深全栈架构师,乐于在 优快云 分享技术见解,与大家携手共进,共攀技术巅峰! 1807

“typedef LRESULT (CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM);”的理解

——————————————朱铭雷 2010.3.18——————————————typedef LRESULT (CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM); 这行代码的含义是:定义一个指针类型WNDPROC,这个类型的指针指向一个函数,这个函数的返回值类型是LRESULT(也就是long),这个函数的调用约定是C

朱铭雷的日记本 5458

ECN实战指南:如何用SAP系统搞定工程变更(附库存处理避坑技巧)

本文详细解析了如何在SAP系统中高效执行工程变更通知(ECN),特别聚焦PP模块的操作流程与库存处理技巧。通过实战案例和系统操作指南,帮助制造业企业避免库存混乱和生产中断,实现从创建到生效的全流程管理。

m5n6o7的博客 1079

一个用渐变色填充矩形的函数

一个用渐变色填充矩形的函数

jiangxinyu的专栏 5498

MIPI D-PHY TX 一致性测试实例解析 Part 03

本文之前,已经讨论了MIPI D-PHY TX的1.3.x和1.4.x的测试项,1.5.x的测试项相对较少,主要是用于时钟和数据通道相关的时序测量

一只豌豆象的博客 5184

Cadence OrCAD Capture软件启动过程卡死且无法恢复的解决方法

如下图所示Cadence OrCAD Capture软件在启动后出现卡死的现象,且等待后无法自动恢复,需要强行关闭,再次启动依然卡死。

fydar的博客 4042

静态变量VS动态变量(自动变量) 静态存储VS动态存储 静态库VS动态库 静态函数(又称内部函数)VS外部函数

静态变量VS自动变量(动态变量): 什么是自动变量呢?自动变量就是指在函数内部定义使用的变量。他只是允许在定义他的函数内部使用它。在函数外的其他任何地方都不能使用的变量。自动变量是局部变量,即它的区域性是在定义他的函数内部有效。当然这说明自动变量也没有链接性,因为它也不允许其他的文件访问他。由于自动变量在定义他的函数的外面的任何地方都是不可见的,所以允许我们在这个函数外的其他地方或者是其他的函数

SdustLiYang的专栏 2398

【DEIM创新改进】独家下采样创新改进篇 | ECCV 2026 | DEIM 引入FSD-Down频域-空间动态下采样,在下采样过程中保留小目标的高频信息、助力小目标检测、遥感小目标检测有效涨点

🔥本文提出了一种名为FSD-Down的频域-空间动态下采样模块,用于改进DEIM网络模型在小目标检测中的性能。FSD-Down通过小波分解显式保留低频语义和高频细节,结合分组卷积、动态通道权重和可学习缩放因子,自适应强化目标边缘与纹理特征。该模块能有效减轻传统下采样造成的频率混叠和细节丢失,提升对小目标、密集目标和低对比度目标的检测能力。实验表明,FSD-Down计算开销可控,在保持实时性的同时显著提升检测精度,特别是在VisDrone和AITODv2数据集上对小目标的检测性能提升显著。

Ai缝合怪、助力小伙伴高效发论文 82

★用C++Builder 5开发Windows下的屏保

★用C++Builder 5开发Windows下的屏保 用C++Builder 5开发Windows下的屏保E_Mail:codehunter@sohu.com网址:http://codehunter.1yes.net摘要:本文通过一个具体的程序演示了Windows下的屏幕保护程序的实现过程。一. 引言视窗系统下的屏幕保护程序是一

formated的专栏 1157

Lammps模拟剪切作用下的位错滑移

Lammps模拟位错与障碍物作用。在lammps中实现周期性位错阵列模型模拟剪切作用下1/2刃位错与障碍物的交互作用

Rockyoung 3458

【华为OD机试真题】7、字符串筛选排序 | 机试真题+思路参考+代码解析(C++、Java、Py)

题目描述 >输入一个由N个大小写字母组成的字符串 按照ASCII码值从小到大进行排序 查找字符串中第K个最小ASCII码值的字母(k>=1) 输出该字母所在字符串中的位置索引(字符串的第一个位置索引为0) k如果大于字符串长度则输出最大ASCII码值的字母所在字符串的位置索引 如果有重复字母则输出字母的最小位置索引

KJ.JK 2267

用C++Builder 5开发Windows下的屏保 (转)

用C++Builder 5开发Windows下的屏保 (转)[@more@] ...

csd3176的博客 149

Python经典编程习题100例:第25例:求各个阶乘的和

不要自卑,去提升实力 互联网行业谁技术牛谁是爹 如果文章可以带给你能量,那是最好的事!请相信自己 加油o~ 本人初学Python,只为熟悉语法编写,大神请勿理会 点击下面链接 Python经典编程100例习题汇总 题目描述: 求1+2!+3!+…+20!的和。 解题思路: > 调用math模块中的factorial函数 代码: import math sum=0 for i in range(1,21): sum+=math.factorial(i) print(sum) ..

优快云 精品推荐 2735

C++Builder 资料库

1.怎样在C++Builder中创建使用DLL 2.用C++Bulider在WIN.INI中保存信息 3.如何在C++Builder中检测硬件 4.C++Builder如何响应消息及自定义消息 5.利用C++ Builder开发动画DLL 6.用C++ Builder 3制作屏幕保护程序 7.TCP/IP头格式 8.UDP 9.判断windows的Desktop及其它目录 10用C++Builde

chiengod(钱神爷)的专栏 2万+

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

如何利用C++ Builder 5.0 实现屏幕保护程序的开发

       在Windows系统中为用户提供了很多屏幕保护程序,如:“三维文字”、“三维变形物”,同时也有一些专门制作屏幕保护程序的应用软件。要是自己能够做一个有自己个性的屏幕保护程序,那该有多好。其实用户完全可以开发一个有自己风格的屏幕保护程序,那该有多好,那么屏幕保护程序是怎样工作的,又是怎样实现的呢?。         原理:屏幕保护程序的文件名是SCR 文件,其实就是一个标准的.ex

fleamboy的专栏 1090

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

]许多代码段,没准儿有你需要的 C++ Builder

[code:1:d5dc046d55] 1.怎样在C++Builder中创建使用DLL 2.用C++Bulider在WIN.INI中保存信息 3.如何在C++Builder中检测硬件 4.C++Builder如何响应消息及自定义消息 5.利用C++ Builder开发动画DLL 6.用C++ Builder 3制作屏幕保护程序 7.TCP/IP头格式 8.UDP 9.判断windows的Deskt

Stiwin Lee's Favorite 1万+

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

许多代码段,没准儿有你需要的 C++ Builder

1.怎样在C++Builder中创建使用DLL 2.用C++Bulider在WIN.INI中保存信息 3.如何在C++Builder中检测硬件 4.C++Builder如何响应消息及自定义消息 5.利用C++ Builder开发动画DLL 6.用C++ Builder 3制作屏幕保护程序 7.TCP/IP头格式 8.UDP 9.判断windows的Desktop及其它目录 10用C++Builde

zhangxvpp 1万+

C++Builder 资料库 (转载)

C++Builder 资料库 2005-03-03 15:14 13115人阅读 评论(3) 收藏 举报 1.怎样在C++Builder中创建使用DLL 2.用C++Bulider在WIN.INI中保存信息 3.如何在C++Builder中检测硬件 4.C++Builder如何响应消息及自定义消息 5.利用C++ Builder开发动画DLL 6.用C++ Builder

qq_31209383的博客 3373

C++ Builder 杂项

1.怎样在C++Builder中创建使用DLL 2.用C++Bulider在WIN.INI中保存信息 3.如何在C++Builder中检测硬件 4.C++Builder如何响应消息及自定义消息 5.利用C++ Builder开发动画DLL 6.用C++ Builder 3制作屏幕保护程序 7.TCP/IP头格式 8.UDP 9.判断windows的Desktop及其它目录 10用C++Builde

xxxl的专栏 5554

60个BCB(C++Build)初学者 应用实例

1.怎样在C++Builder中创建使用DLL 2.用C++Bulider在WIN.INI中保存信息 3.如何在C++Builder中检测硬件 4.C++Builder如何响应消息及自定义消息 5.利用C++ Builder开发动画DLL 6.用C++ Builder 3制作屏幕保护程序 7.TCP/IP头格式 8.UDP 9.判断windows的Desktop及其它目录 10用C++Builde...

AModestBoy的博客 2112
上一篇: 浅谈足球游戏的人工智能
下一篇: C++Builder 中大尺寸图象的显示技巧
icemanpro
博客等级 码龄25年 4粉丝 35原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值