C#中如何取得并使用Windows系统图标

C# Windows Form 最小化系统托盘(Tray) 程序界面如下: 控件 :button notifyIcon contextMenuStrip点击托盘 出现提示框 询问是否真的要托盘 确认 程序托盘到windows右下角双击托盘图标 程序显示 右键托盘图标 显示菜单点击最小化按钮程序托盘程序所有代码如下:using System;using System.Collections.Generic;using 阅读详情


在系统弹出对话框中往往带有Information、Question、Warnning、Error等系统图标,由于这些图标是系统自带的,所以可以为我们自己程序所用。

System.Drawing命名空间中有一个SystemIcons类,以静态属性方式提供了使用系统图标的便捷途径:

Public Properties

 Name Description
Public property Static Application Gets an Icon object that contains the default application icon (WIN32: IDI_APPLICATION).
Public property Static Asterisk Gets an Icon object that contains the system asterisk icon (WIN32: IDI_ASTERISK).
Public property Static Error Gets an Icon object that contains the system error icon (WIN32: IDI_ERROR).
Public property Static Exclamation Gets an Icon object that contains the system exclamation icon (WIN32: IDI_EXCLAMATION).
Public property Static Hand Gets an Icon object that contains the system hand icon (WIN32: IDI_HAND).
Public property Static Information Gets an Icon object that contains the system information icon (WIN32: IDI_INFORMATION).
Public property Static Question Gets an Icon object that contains the system question icon (WIN32: IDI_QUESTION).
Public property Static Warning Gets an Icon object that contains the system warning icon (WIN32: IDI_WARNING).
Public property Static WinLogo Gets an Icon object that contains the Windows logo icon (WIN32: IDI_WINLOGO).

 

需要注意的是,它是属于System.Drawing命名空间的,就是说它是GDI+的函数。

要在WPF中使用系统图标也是一件非常困难的事,微软提供了WPF的矢量绘图系统,可是它与传统的GDI、GDI+之间的转换并不是很全面和便利, 要为WPF中的Image控件的Source指定图片数据源,你需要使用System.Windows.Interop下的Imaging来做转换:

Icon icon = System.Drawing.SystemIcons.Information;

BitmapSource source1 = Imaging.CreateBitmapSourceFromHIcon(icon.Handle,new Int32Rect(0,0,32,32), BitmapSizeOptions.FromWidth(32));

Windows 10中如何添加“我的电脑”图标 在以上代码中,我们在窗体的加载事件(MainForm_Load)中创建了一个ListViewItem对象来表示“我的电脑”图标。以下是一个简单的示例代码,演示如何创建一个窗体应用程序,并在其中添加“我的电脑”图标。如果你想使用真实的“我的电脑”图标,你可以在Windows系统文件夹中找到"shell32.dll"文件,并提取其中的图标。通过这种编程的方式,我们可以在Windows 10中添加“我的电脑”图标。完成以上步骤后,我们可以运行应用程序,看到窗体中已经添加了“我的电脑”图标。 阅读详情

相关推荐

C#实时抓取并显示系统鼠标图标的小型Windows Forms工具

一个开箱即用的C# Windows Forms项目,能持续监测并即时呈现当前系统鼠标指针图像——无论是默认箭头、链接手型、旋转等待圈、文字插入光标,还是自定义程序设置的特殊图标。底层通过调用User32.dll中的GetCursorInfo获取光标状态和句柄,再用CopyImage安全转换为Bitmap,最终在PictureBox中流畅刷新显示。项目已适配高DPI缩放,避免模糊或错位,在4K或高分屏下依然清晰准确。代码基于.NET Framework 4.7.2构建,包含完整窗体设计(Form1.desig

oauth7security的博客 241

C# 调用系统图片

在系统弹出对话框中往往带有Information、Question、Warnning、Error等系统图标,由于这些图标是系统自带的,所以可以为我们自己程序所用。 System.Drawing命名空间中有一个SystemIcons类,以静态属性方式提供了使用系统图标的便捷途径: Public Properties   Name Description

dong0037的专栏 1079

C#实现Windows托盘图标动态旋转示例

本文还有配套的精品资源,点击获取 简介:本示例展示了如何在C#中使用.NET Framework API在Windows系统托盘区域创建并动态旋转自定义图标。通过结合 System.Windows.Forms.NotifyIcon 类、 System.Windows.Forms.Timer 控件以及自定义 UserControl 绘...

weixin_42506884的博客 1412

如何为C#WinFrom编译的.exe添加个性化图标

1、在VS中点击菜单栏上的“项目”,找到最下面的属性,单击进去。3、重新编译文件即可。

qq_43279097的博客 2612

C# 取得系统默认图标

C# 取得系统默认图标 像excel图标、word图标等

C#做Windows界面常用ico图标

做C#界面的时候常常要用到一些漂亮的图标 拿出来与大家分享,希望有用.

C# 获取Windows系统ICON图标的四种方式-可提取各种文件夹、文件等等图标

本文介绍的是提取Windows系统内部Icon图标的方法,就是系统资源管理器里面显示的图标,包括文件夹、文件,如:常规文件夹的图标、特定文件夹图标(磁盘根目录、收藏夹、网络共享目录等)、各文件类型图标、应用程序文件图标。 方法一:调用.NET内部提供的ExtractAssociatedIcon方法,只能从文件获取一种规格的ICON图标,一般是Size(32,32) public static System.Drawing.Icon GetIconFromFile(string fileName) {

lzl_li的专栏 1万+

c# 一些系统icon图标

C#中可用到的icon图标,一些系统的和应用程序的图标

使用C#在系统任务栏中放置一个通知图标

默认情况下,通知区域仅显示几个图标,其余图标隐藏在溢出区域中,只有当您单击通知区域旁边的小扩展箭头时,溢出区域才可见。最后,为了显示通知区域图标,Windows 8 似乎从图标中选择了 32×32 图像,并将其缩小到 16×16 像素(或它想要的任何大小),即使图标文件包含 16×16 版本!在通知区域图标对话框中,找到该应用程序,将其行为条目更改为“显示图标和通知”,然后单击确定。程序可以使用通知图标来在通知区域(又称系统托盘)中放置正在发生的事情的视觉指示,默认情况下,通知区域位于任务栏的右端。

ljygood2的博客 1513

CODESYS做Modbus TCP主站踩坑记:从IP配置到数据映射的完整避坑指南

本文详细记录了在CODESYS中配置Modbus TCP主站的全过程,从IP配置到数据映射的常见问题及解决方案。重点解析了网络适配器选择、Slave ID误解、地址偏移陷阱等关键问题,并提供了实用的调试技巧和性能优化建议,帮助工业通信开发者高效避坑。

weixin_30642561的博客 624

别再让充电器‘罢工’了!聊聊Charger里VIN-DPM这个不起眼但关键的功能

本文深入探讨了充电IC中的VIN-DPM(输入电压动态电源管理)功能,揭示其如何智能调节充电策略以避免电源适配器过载。通过实际案例和实验室数据,展示了VIN-DPM在提升充电稳定性和效率中的关键作用,并提供了选型、设计和故障排查的实用指南。

weixin_33738578的博客 416

c# 动态获取系统图标

<br /><br />using System;<br />using System.Collections.Generic;<br />using System.Text;<br />using System.Runtime.InteropServices;<br />using System.Drawing;<br /> <br /> <br />namespace Common<br />{<br />    /// <summary><br />    /// 获取系统默认的图标<br />  

yanchao1023的专栏 1311

Windows 11 24H2 系统下,保姆级安装华为 eNSP 模拟器(含依赖软件下载与避坑指南)

本文提供Windows 11 24H2系统下华为eNSP模拟器的完整安装指南,涵盖系统配置调整、依赖软件安装及常见问题解决方案。特别针对新版系统的兼容性问题,提供详细的避坑步骤和优化建议,帮助网络工程师顺利完成eNSP模拟器的部署与使用。

weixin_42567752的博客 428

使用API获取Windows系统的文件关联图标

<br /><br />#region 读取文件图标<br />        [DllImport("shell32.dll")]<br />          static extern uint ExtractIconEx(string lpszFile, int nIconIndex, int[] phiconLarge, int[] phiconSmall, uint nIcons);<br />  <br />          /// <summary><br />          /// 

ronmy的专栏 2430

ε-差分隐私之拉普拉斯噪声机制(定义 + 证明 + 代码)

ε-差分隐私之拉普拉斯噪声机制 差分隐私的描述 1-范式的定义:使用matlab调用函数norm(x, 1) 更多范式见 范式 差分隐私的定义应该满足 拉普拉斯噪声的证明全过程如下: DP方向差分隐私证明是基本入门!!! -拉普拉斯噪声分布代码 Laplace分布的概率密度函数的形式是: 使用python - matplotlib来绘制概率分布图: import matplotlib.pyplot as plt import numpy as np def laplace_fun

毕业才是起点 1万+

【知识图谱】一文看懂知识图谱的搭建实践与科普教程(5万字完结篇)

所有可能的实体对:(“Mate40”,“华为”), (“Mate40”,“手机”), (“华为”,“手机”)。送入关系模型分类,预期输出 (“Mate40”,“华为”): 品牌, (“Mate40”,“手机”): 属于类别, (“华为”,“手机”): 无关系。,定义了图谱中概念和关系的类型层次结构,相当于知识图谱的“纲领”和“schema”。训练完成后,当模型看到新的句子,比如“苹果的MacBook笔记本性能强大”,识别出实体“苹果”(品牌)和“MacBook”(产品)后,就能正确输出关系“品牌”。

weixin_41645791的博客 2614

C# 获取系统图标

1 代码[csharp] view plain copyusing System;  using System.Collections.Generic;  using System.ComponentModel;  using System.Data;  using System.Drawing;  using System.Linq;  using System.Text;  using Sys...

bruce135lee的专栏 1836

告别‘耀斑’降落:手把手教你用PX4+激光测距仪实现固定翼精准自动着陆

本文详细介绍了如何利用PX4飞控与激光测距仪实现固定翼无人机的精准自动着陆,解决传统气压计在低空环境下的测量误差问题。通过硬件选型、安装要点、PX4参数配置及实战调校,帮助开发者实现厘米级高度感知,优化降落曲线,提升着陆稳定性与安全性。

weixin_30336061的博客 520

C#)Windows Shell 编程系列5 - 获取图标

原文 C#)Windows Shell 编程系列5 - 获取图标 (本系列文章由柠檬的(lc_mtt)原创,转载请注明出处,谢谢~)接上一节:(C#)Windows Shell 编程系列4 - 上下文菜单(iContextMenu)(二)嵌入菜单和执行命令 有关 PIDL   PIDL亦有“绝对路径”与“相对路径”的概念。表示“相对路径”的PIDL(本文简称为“相对PIDL”)只有一个ITEM...

weixin_33862188的博客 124

52、基于格的具有解密密钥暴露抗性的可撤销(分层)身份基加密方案

本文提出了首个基于格的具有解密密钥暴露抗性(DKER)的可撤销分层身份基加密(RHIBE)方案。通过引入分层密文、分层解密密钥和级别转换密钥等创新工具,克服了格结构与传统密钥重新随机化属性不匹配的难题。该方案不仅支持可扩展的密钥撤销机制,还具备密钥委托功能,为后量子密码学领域的发展提供了新的思路和方法。

efc12345678的博客 123

QGis二次开发 —— 1、win10/win11搭建Vs2017-QGis3.40.12环境(附Vs2017环境效果,附全部问题解决方法)(附:Qt助手加入QGis接口说明文档)

QGis二次开发 —— 1、Windows10搭建Vs2017-QGis环境(附Vs2017环境效果)(附:Qt助手加入QGisA接口说明文档)

1362

【WinForm】使用C# WinForm实现带有托盘图标功能的应用程序

本文介绍了使用C# Windows Forms实现托盘图标功能的方法。通过添加NotifyIcon控件和ContextMenuStrip菜单,实现了程序启动时隐藏主窗口、通过托盘图标交互的功能。关键点包括:拦截窗体关闭事件改为隐藏、左键点击切换窗口显示、右键菜单提供打开/退出选项。文中提供了完整的代码实现,涵盖了窗体初始化、事件处理等核心逻辑,使程序能够优雅地在后台运行并通过系统托盘进行控制。这种实现方式为用户提供了更友好的交互体验。

杰西笔记 1586

深度学习工具包 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# 获取系统和文件夹图标

[StructLayout(LayoutKind.Sequential)]         public struct SHFILEINFO         {             public IntPtr hIcon;             public IntPtr iIcon;             public uint dwAttributes;          

fyl_077的专栏 643

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

获取系统图标

一点不足,文件夹图标是从shell32.dll中得到的.一般情况下是没有问题的.但是当文件夹的图片时自定义的时候就无法得到了.继续研究中 using System; using System.IO; using System.Drawing; using Microsoft.Win32; using System.Runtime.InteropServices;

hrbeuwhw的专栏 995

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

C#实现系统托盘,C#窗体最小化时隐藏为任务栏图标

C#实现系统托盘,C#窗体最小化时隐藏为任务栏图标的Window appllication  1.设置窗体属性showintask=false  2.加notifyicon控件notifyicon1,为控件notifyicon1的属性icon添加一个icon图标。  3.添加窗体最小化事件(首先需要添加事件引用):  // this.sizechanged += new s

机器视觉 1009
下一篇: Expression Studio 2.0 简体中文正式版注册码
wedojava
博客等级 码龄20年 3粉丝 1原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值