WindowsAPI每日一练(2) 使用应用程序句柄
WindowsAPI每日一练系列 :https://www.cnblogs.com/LexMoon/category/1246238.html
WindowsAPI每日一练() WinMain
WindowsAPI每日一练(2) 使用应用程序句柄
#include<windows.h> int WINAPI wWinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
UNREFERENCED_PARAMETER(hInstance);
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
UNREFERENCED_PARAMETER(nCmdShow); //使用应用程序句柄 const int MAXSIZE_APPBUF = ;
TCHAR wAppTitle[MAXSIZE_APPBUF];
LoadString(hInstance,IDS_APP_TITLE,wAppTitle,MAXSIZE_APPBUF); //获得桌面句柄
HWND hWnd=GetDesktopWindow(); //显示第一行信息
// ::MessageBox(hWnd,"Hello Window","Hello Window",MB_YESNO);
MessageBox(hWnd,"Hello Windows",wAppTitle,MB_YESNO);
return ;
}
这个例子是在前面的基础上修改的,主要添加了使用应用程序实例句柄。在第19行里定义了一个保存应用程序标题的缓冲区,然后在第20行里调用函数LoadString从应用程序的资源里加载字符串,它的第一个参数就使用到hInstance句柄。因此应用程序句柄是表示程序在资源上唯一的标识符。
LoadString问题:
作用:从 资源 里加载字符串资源到CString对象里。
声明:
WINUSERAPI int WINAPI LoadStringA( __in_opt HINSTANCE hInstance, __in UINT uID, __out_ecount(cchBufferMax) LPSTR lpBuffer, __in int nBufferMax);
参数:
返回值:
说明
系统要求
int LoadString(HINSTANCE hInstance,//应用程序实例句柄
UINT uID,//资源ID
LPTSTR lpBuffer,//存放字符串的缓冲区
int nBufferMax//缓冲区大小
)
作用:
先在资源中加入字符串资源(不管是字符串还是窗口还是按钮),都有一个名字,比如IDC_BUTTON1
然后用这个函数把这个名字作为参数,就可以取出资源中的字符串了
如:一、在resource.h中,#define FIREWALL_ALREADY_START 61452
二、在*.rc文件中:
STRINGTABLE DISCARDABLE
BEGIN
FIREWALL_ALREADY_START "防火墙已经启动"
END
三、
CString str;
str.LoadString(FIREWALL_ALREADY_START);
WindowsAPI每日一练(2) 使用应用程序句柄的更多相关文章
- WindowsAPI每日一练(1) MessageBoxA
WindowsAPI每日一练系列 :https://www.cnblogs.com/LexMoon/category/1246238.html WindowsAPI每日一练(1) WinMain 要跟 ...
- 每日一小练——Armstrong数
上得厅堂.下得厨房,写得代码,翻得围墙,欢迎来到睿不可挡的每日一小练! 题目:Armstrong数 内容: 在三位的正整数中,比如abc.有一些能够满足a^3+b^3+c^3=abc的条件,也就是说各 ...
- python每日一练:0007题
第 0007 题: 有个目录,里面是你自己写过的程序,统计一下你写过多少行代码.包括空行和注释,但是要分别列出来. # -*- coding:utf-8 -*- import os def count ...
- [python每日一练]--0012:敏感词过滤 type2
题目链接:https://github.com/Show-Me-the-Code/show-me-the-code代码github链接:https://github.com/wjsaya/python ...
- Python 每日一练 | Flask 实现半成品留言板
留言板Flask实现 引言 看了几天网上的代码,终于写出来一个半成品的Flask的留言板项目,为什么说是半成品呢?因为没能实现留言板那种及时评论刷新的效果,可能还是在重定向上有问题 或者渲染写的存在问 ...
- Python 每日一练(4)
引言 今天继续是python每日一练的几个专题,主要涵盖简单的敏感词识别以及图片爬虫 敏感词识别 这个敏感词的识别写的感觉比较简单,总的概括之后感觉功能可以简略成if filter_words in ...
- Python 每日一练(2)
引言 我又双叒叕的来啦,新博客的第二篇文章,这次是继之前公众号上每日一练的第二个,这次是专题实对于文件的一些处理的练习 主要有以下几类: 1.实现英文文章字频统计 2.统一剪裁某一指定目录下的所有图片 ...
- CSS3每日一练之内容处理-嵌套编号
出处:http://www.w3cfuns.com/thread-5592229-1-17.html 1.大标题一 1.子标题 2.子标题 3.子标题2.大标题二 1.子标题 2. ...
- CSS3每日一练之选择器-结构性伪类选择器
<!DOCTYPE HTML> <html> <head> <meta charset="gb2312"> <title> ...
随机推荐
- asp.net mvc 路由检测工具
初学mvc,路由搞不清楚,可以通过一款插件 查看匹配的路由. 工具名<RouteDebugger> 可以在nuget中查询RouteDebugger后,安装.或者在控制台进行安装: pm& ...
- UnicodeEncodeError: 'latin-1' codec can't encode characters in position 41-50: ordinal not in range(256)
在处理标题或网址为中文的文件或网页的时候,报UnicodeEncodeError: 'latin-1' codec can't encode characters in position 41-50: ...
- re:从零开始的数位dp
起源:唔,,前几天打cf,edu50那场被C题虐了,决定学学数位dp.(此文持续更新至9.19) ps:我也什么都不会遇到一些胡话大家不要喷我啊... 数位dp问题:就是求在区间l到r上满足规定条件的 ...
- SVN版本管理系统的使用(CentOS+Subversion+Apache+Jsvnadmin+TortoiseSVN)
1.服务器: 192.168.4.221root 用 户操作安装 装 apache# yum install httpd httpd-devel# service httpd start# chkco ...
- react material-ui 添加jss插件
jss.config.js import { create } from "jss"; import preset from "jss-preset-default&qu ...
- package.json文件配置信息
1.概述 每个项目的根目录下面,一般都有一个package.json文件,定义了这个项目所需要的各种模块,以及项目的配置信息(比如名称.版本.许可证等元数据).npm install命令根据这个配置文 ...
- laravel5.4+vue+element简单搭建(gulp+laravel Elixir)(转)
如今laravel来到5.4版本,更方便引入vue了,具体步骤如下: 下图为我动到的文件 1.下载laravel5.4 2.命令行(laravel5.4目录下):composer install 3. ...
- mac 远程连接 云服务器
之前mac 命令行连接云端服务器,一直失败,今天问题突然间解决了,如果遇到类似的问题,按照方法解决不了,可以在下面留言,共同探讨. 首先,在云端先判断一下云端服务器是否安装了 ssh服务器:op ...
- [redis] redis cli的学习记录
文档: https://redis.io/topics/rediscli help命令: The command can be used in two forms: . help @<categ ...
- 【Python基础】zip函数的使用
zip函数的使用 描述 zip() 函数用于将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的列表. 如果各个迭代器的元素个数不一致,则返回列表长度与最短的对象相同, ...