简单的WIN32屏保开发制作(可播放视频)

黑客帝国屏保源码!快拿去试试吧!炫酷无比! 黑客帝国屏幕保护设置 1. 打开VS2013或以上版本,新建—>项目,Visual C++,win32,选择win32控制台应用程序,名称填写为"hacker"。 2. 将以下代码复制到项目源文件中 黑客帝国屏保源码 3.编译项目工程 4.找到生成的exe文件,将exe后缀改为scr(hacker.exe->hacker.scr) 5.将文件h... 阅读详情

本文不同于VC下使用ScrnSave.lib进行屏保制作的方式,

而是在VS下以其内在原理,从无到有进行一个简单的WIN32屏保开发,

只要你拥有一些简单的WIN32程序编写的经验,便可以很轻松的明白并编写出此类屏保。


首先,要实现一个屏保,我们需要实现三件事。

  • 操作系统自动运行程序
  • 全屏幕的窗口
  • 用户输入即退出
只要实现了这三件事,那么便可以称之为简单意义上的屏保了。


操作系统自动运行程序:

       这很幸运,因为只要将用户程序的后缀名改为.scr, 将其放到正确的系统目录下,便可以成为

真正的屏幕保护程序,在空闲时自动得到操作系统的调用,而不用我们花大量时间编写代码。


全屏幕的窗口:

        这个也很简单,只要我们将窗口创建为全屏显示,那么自然也没有太大问题了。

你可以这样做:

    hwnd = CreateWindow(L"BeyondScrnSaver", NULL,                                             //注意这里初始化HWND_DESKTOP,
            WS_POPUP | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 0,   //因为在窗口上播放视频,窗口显示太快会看到先显示背景,所以我先将其大小调整为0
            0, HWND_DESKTOP, NULL, hInstance, NULL);

用户输入即退出:

        只要在消息窗口过程中进行鼠标移动,点击,以及键盘输入事件的处理,便可以实现该退出过程。


好了,讲了这么多,现在我们从实现一个屏幕保护程序的窗口框架开始吧....

/*---------------------------------------------------------------------------------
【Cpp文件】:ScreenMain.cpp          Created by Beyond Ray,2014年4月
(描述):使用天下叁CG《墨龙纪》制作成简单的屏保
-----------------------------------------------------------------------------------*/

//------------------------【头文件】--------------------------------
#include 
#include 								//使用swprintf_s函数所需的头文件
#include "resource.h"							//资源文件(只用于图标)

//------------------------【全局函数声明】--------------------------
LRESULT CALLBACK	WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);			//主窗口过程函数

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
	HWND hwndFrameWnd = 0;
	HWND hwnd = 0;
	RECT rect;

	//---------------------------【设计一个窗口类】------------------------------
	WNDCLASSEX wndClass = { 0 };					//用WINDCLASSEX定义一个窗口类,并初始化
	wndClass.cbSize = sizeof(WNDCLASSEX);			//设置结构体的字节数大小
	wndClass.style = CS_HREDRAW | CS_VREDRAW;		//设置窗口的样式
	wndClass.lpfnWndProc = WndProc;					//设置指向窗口过程函数的指针
	wndClass.cbClsExtra = 0;						//窗口类的附加内存,取0就可以了
	wndClass.cbWndExtra = 0;						//窗口的附加内存,依然取0就行了
	wndClass.hInstance = hInstance;					//指定包含窗口过程的程序的实例句柄。
	wndClass.hIcon = (HICON)LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));    //本地加载自定义ico图标
	wndClass.hCursor = LoadCursor(NULL, IDC_ARROW); //指定窗口类的光标句柄。
	wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);  //指定一个白色画刷句柄	
	wndClass.lpszMenuName = NULL;					//用一个以空终止的字符串,指定菜单资源的名字。
	wndClass.lpszClassName = L"BeyondScrnSaver";	//用一个以空终止的字符串,指定窗口类的名字。
	
	//----------------------------【注册一个窗口类】------------------------------
	if (!RegisterClassEx(&wndClass))
		return -1;

	//-----------------------------【创建一个窗口】-------------------------------
	hwnd = CreateWindow(L"BeyondScrnSaver", NULL,					//注意这里初始化HWND_DESKTOP,并且在最初大小为0,
			WS_POPUP | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 0, //以防止视频还没播放前看到白屏
			0, HWND_DESKTOP, NULL, hInstance, NULL);
			
	//窗口更新显示
	MoveWindow(hwnd, 0, 0, GetSystemMetrics(SM
树莓派魔法镜子DIY:从硬件选型到软件部署全攻略 物联网(IoT)与智能家居的核心在于将数字信息无缝融入物理环境,提升生活便利与交互体验。其实现原理通常基于嵌入式系统与传感器技术,通过软硬件协同,将数据采集、处理与显示整合于单一设备。在技术价值上,这类项目不仅降低了智能设备的入门门槛,更推动了创客文化与个性化定制的发展。典型的应用场景包括家庭信息中枢、环境监控与交互式装饰等。本文以树莓派(Raspberry Pi)和单向镜为核心,详细解析如何构建一个能显示时间、天气等信息的“魔法镜子”,涵盖了从树莓派选型、屏幕与镜面光学搭配,到使用MagicMirror² 阅读详情

相关推荐

1024visualstudio美化壁纸

原图来自B站官方壁纸娘目前原图链接已被删 这是本人自己ps后的

win32纯代码编写的视频播放器

利用win32纯代码编写的一个视频播放器,可播放AVI、WMV类型的视频,对于其他类型视频需要使用解码器,上传资源里有解码器Xvid

单片机按键识别篇---单击---双击----长按

  最近做一任务需要使用一个按键实现三种功能,分别是按键单击功能,按键双击功能和按键长按功能,可能之前没有接触过这类按键复用情况,顶多也只是简单识别单击和长按,没有想过双击以上按键功能,也是绞尽脑汁,想了半天,又上网看了些例程,算是对于按键的识别有点小小的了解,感觉这个功能挺实用,在此做个随笔。 一、思路   1.识别长按操作思路:我们使用系统定时器定时,然后让系统每过一段时间去扫描按键I/O...

weixin_30311605的博客 3660

H医药公司配送中心布局仿真优化

新增2个Source,Source1命名为“货物到达”,用来进行仿真供应商原料到达,Source2命名为“订单到达”,用来进行仿真客户需求订单的到达,如下图是设置两个发生器的具体参数。通过主操作界面上的各个实体工具,如发生器、暂存区、货架、处理器、吸收器等实体工具对初始模型和优化后的方案模型进行仿真建模,建立优化前后的模型图如下图所示。通过下表可以看出,优化前操作员的总运行距离为132.11km,而优化后操作员的总运行距离为128.17km,运行距离缩短,操作员的疲劳强度降低。

m0_72514516的博客 2529

UE4 Instanced Mesh 半透明渲染顺序不对解决

以绿色方块为Instanced Mesh为例。 正确的半透应该是这样的: 这是一般蓝图Actor方块,其半透是正常的。 然而Instanced Mesh因为过多,UE4不给你缓存正确的渲染顺序。所以,在不改代码的情况下,想解决Instanced Mesh半透问题,是不可能的。不正确的半透如下: 注意到错误发生在Instanced Mesh的方块与方块之间。 但我就是要解决,...

qq_41524721的博客 5569

RuoYi(分离版) 使用代码生成器添加子模块(idea版)

文章目录准备一、使用代码生成器1.数据库2.导入表并生成代码二、导入代码文件1.新建一个模块2.导入zip代码文件3.模块环境配置添加菜单和访问地址总结 准备 前提要把系统启动起来,部分教程可以参考这边文章若依框架RuoYi前后端分离项目导入IDEA及运行启动 但是完全参考这篇文章还是不能把项目启动起来,因为这篇文章没有说明数据库。 我是用的是本地数据库,采用xampp+Navicat的组合来部署和访问数据库。打开Navicat,连接并创建数据库ry-vue并导入数据脚本ry_20191008.sql,q

dream_coke的博客 1万+

Android/AutoMotive 多用户文件操作与权限管理

本文深入探讨了Android/Automotive多用户系统的文件操作与权限管理机制。文章阐述了多用户隔离与共享的核心原理,重点介绍了如何使用adb指令精准管理不同用户的应用与数据,并提供了在Android Automotive车载场景下实现安全跨用户数据共享与权限控制的最佳实践。

weixin_29214691的博客 163

闲人闲谈PS之十二——WBS-BOM在装备制造项目中的实战解析

本文深入解析了WBS-BOM在装备制造项目中的核心应用。针对按订单设计/生产的行业痛点,WBS-BOM作为项目专属物料清单,完美连接SAP PS与PP模块,确保MRP能基于项目进行精准物料需求计算,实现从设计到生产的全链路项目化跟踪与管理。

weixin_29284885的博客 400

使用 MATLAB/Simulink + Communications Toolbox + 5G Toolbox,构建一个2×2 MIMO-OFDM通信系统

本文通过Simulink+CommunicationsToolbox构建2×2 MIMO-OFDM通信系统,重点实现信道均衡滤波器(ZF与MMSE)的设计与应用。详细介绍了系统架构、建模步骤(包括信道估计、均衡器实现)和仿真场景设计,通过BER、星座图和EVM对比分析验证了MMSE均衡器在抑制噪声和信号恢复方面的优势。文章总结了MIMO均衡的核心原理与实践经验,并提出了扩展至大规模MIMO、深度学习均衡器等优化方向,为无线通信系统设计提供实用指导。

amy_mhd的博客 127

芒果YOLO11改进17:即插即用 | 损失函数Repulsion Loss|Repulsion 解决目标遮挡场景下的目标检测,为解决密集人群检测中遮挡设计的损失函数,打造高效

即插即用 | 损失函数Repulsion Loss|Repulsion 解决目标遮挡场景下的目标检测,为解决密集人群检测中遮挡设计的损失函数,打造高效

包括YOLOv5、YOLOv7、YOLOv8等模型改进 484

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

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

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

深度学习工具包 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")

上一篇: 关于OGRE四元数和旋转的一些浅显认识`
下一篇: OGRE之第一个程序
Beyond我爱杨
博客等级 码龄13年 36粉丝 39原创
评论 6
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值