c#: 任务栏进度显示(TaskbarManager)

Win7及以上系统支持任务栏进度条,为有进度类应用显示进度于任务栏,甚为方便。

以c#之WinForm实现其,大多采用Windows API Code Pack这个方案,加多引用,比较繁琐,而我总也打不开了其页面。

鄙人不喜欢多引用东西,即寻求方法抽取其相关代码,简化其应用。费些工夫,实现效果。

 

一、TaskbarManager

此为抽取必要代码而组成同名类,全部代码如下:

//抽取TaskBar代码,用其设置任务栏进度部分
//Copyright (c) Microsoft Corporation.  All rights reserved.using System;
using System.Diagnostics;
using System.Runtime.InteropServices;namespace wApp
{/// <summary>/// Represents an instance of the Windows taskbar/// </summary>public class TaskbarManager{// Hide the default constructorprivate TaskbarManager(){}// Best practice recommends defining a private object to lock onprivate static object _syncLock = new object();private static TaskbarManager _instance;/// <summary>/// Represents an instance of the Windows Taskbar/// </summary>public static TaskbarManager Instance{get{if (_instance == null){lock (_syncLock){if (_instance == null)_instance = new TaskbarManager();}}return _instance;}}/// <summary>/// Indicates whether this feature is supported on the current platform./// </summary>public static bool IsPlatformSupported{get { return Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.CompareTo(new Version(6, 1)) >= 0; }}/// <summary>/// Displays or updates a progress bar hosted in a taskbar button of the main application window /// to show the specific percentage completed of the full operation./// </summary>/// <param name="currentValue">An application-defined value that indicates the proportion of the operation that has been completed at the time the method is called.</param>/// <param name="maximumValue">An application-defined value that specifies the value currentValue will have when the operation is complete.</param>public void SetProgressValue(int currentValue, int maximumValue){if (IsPlatformSupported)TaskbarList.Instance.SetProgressValue(OwnerHandle,Convert.ToUInt32(currentValue),Convert.ToUInt32(maximumValue));}/// <summary>/// Displays or updates a progress bar hosted in a taskbar button of the given window handle /// to show the specific percentage completed of the full operation./// </summary>/// <param name="windowHandle">The handle of the window whose associated taskbar button is being used as a progress indicator./// This window belong to a calling process associated with the button's application and must be already loaded.</param>/// <param name="currentValue">An application-defined value that indicates the proportion of the operation that has been completed at the time the method is called.</param>/// <param name="maximumValue">An application-defined value that specifies the value currentValue will have when the operation is complete.</param>public void SetProgressValue(int currentValue, int maximumValue, IntPtr windowHandle){if (IsPlatformSupported)TaskbarList.Instance.SetProgressValue(windowHandle,Convert.ToUInt32(currentValue),Convert.ToUInt32(maximumValue));}/// <summary>/// Sets the type and state of the progress indicator displayed on a taskbar button of the main application window./// </summary>/// <param name="state">Progress state of the progress button</param>public void SetProgressState(TaskbarProgressBarState state){if (IsPlatformSupported)TaskbarList.Instance.SetProgressState(OwnerHandle, (TaskbarProgressBarStatus)state);}/// <summary>/// Sets the type and state of the progress indicator displayed on a taskbar button /// of the given window handle /// </summary>/// <param name="windowHandle">The handle of the window whose associated taskbar button is being used as a progress indicator./// This window belong to a calling process associated with the button's application and must be already loaded.</param>/// <param name="state">Progress state of the progress button</param>public void SetProgressState(TaskbarProgressBarState state, IntPtr windowHandle){if (IsPlatformSupported)TaskbarList.Instance.SetProgressState(windowHandle, (TaskbarProgressBarStatus)state);}private IntPtr _ownerHandle;/// <summary>/// Sets the handle of the window whose taskbar button will be used/// to display progress./// </summary>internal IntPtr OwnerHandle{get{if (_ownerHandle == IntPtr.Zero){Process currentProcess = Process.GetCurrentProcess();if (currentProcess != null && currentProcess.MainWindowHandle != IntPtr.Zero)_ownerHandle = currentProcess.MainWindowHandle;}return _ownerHandle;}}}/// <summary>/// Represents the thumbnail progress bar state./// </summary>public enum TaskbarProgressBarState{/// <summary>/// No progress is displayed./// </summary>NoProgress = 0,/// <summary>/// The progress is indeterminate (marquee)./// </summary>Indeterminate = 0x1,/// <summary>/// Normal progress is displayed./// </summary>Normal = 0x2,/// <summary>/// An error occurred (red)./// </summary>Error = 0x4,/// <summary>/// The operation is paused (yellow)./// </summary>Paused = 0x8}/// <summary>/// Provides internal access to the functions provided by the ITaskbarList4 interface,/// without being forced to refer to it through another singleton./// </summary>internal static class TaskbarList{private static object _syncLock = new object();private static ITaskbarList4 _taskbarList;internal static ITaskbarList4 Instance{get{if (_taskbarList == null){lock (_syncLock){if (_taskbarList == null){_taskbarList = (ITaskbarList4)new CTaskbarList();_taskbarList.HrInit();}}}return _taskbarList;}}}[GuidAttribute("56FDF344-FD6D-11d0-958A-006097C9A090")][ClassInterfaceAttribute(ClassInterfaceType.None)][ComImportAttribute()]internal class CTaskbarList { }[ComImportAttribute()][GuidAttribute("c43dc798-95d1-4bea-9030-bb99e2983a1a")][InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]internal interface ITaskbarList4{// ITaskbarList
        [PreserveSig]void HrInit();[PreserveSig]void AddTab(IntPtr hwnd);[PreserveSig]void DeleteTab(IntPtr hwnd);[PreserveSig]void ActivateTab(IntPtr hwnd);[PreserveSig]void SetActiveAlt(IntPtr hwnd);// ITaskbarList2
        [PreserveSig]void MarkFullscreenWindow(IntPtr hwnd,[MarshalAs(UnmanagedType.Bool)] bool fFullscreen);// ITaskbarList3
        [PreserveSig]void SetProgressValue(IntPtr hwnd, UInt64 ullCompleted, UInt64 ullTotal);[PreserveSig]void SetProgressState(IntPtr hwnd, TaskbarProgressBarStatus tbpFlags);[PreserveSig]void RegisterTab(IntPtr hwndTab, IntPtr hwndMDI);[PreserveSig]void UnregisterTab(IntPtr hwndTab);[PreserveSig]void SetTabOrder(IntPtr hwndTab, IntPtr hwndInsertBefore);[PreserveSig]void SetTabActive(IntPtr hwndTab, IntPtr hwndInsertBefore, uint dwReserved);[PreserveSig]HResult ThumbBarAddButtons(IntPtr hwnd,uint cButtons,[MarshalAs(UnmanagedType.LPArray)] ThumbButton[] pButtons);[PreserveSig]HResult ThumbBarUpdateButtons(IntPtr hwnd,uint cButtons,[MarshalAs(UnmanagedType.LPArray)] ThumbButton[] pButtons);[PreserveSig]void ThumbBarSetImageList(IntPtr hwnd, IntPtr himl);[PreserveSig]void SetOverlayIcon(IntPtr hwnd,IntPtr hIcon,[MarshalAs(UnmanagedType.LPWStr)] string pszDescription);[PreserveSig]void SetThumbnailTooltip(IntPtr hwnd,[MarshalAs(UnmanagedType.LPWStr)] string pszTip);[PreserveSig]void SetThumbnailClip(IntPtr hwnd,IntPtr prcClip);// ITaskbarList4void SetTabProperties(IntPtr hwndTab, SetTabPropertiesOption stpFlags);}internal enum TaskbarProgressBarStatus{NoProgress = 0,Indeterminate = 0x1,Normal = 0x2,Error = 0x4,Paused = 0x8}internal enum ThumbButtonMask{Bitmap = 0x1,Icon = 0x2,Tooltip = 0x4,THB_FLAGS = 0x8}[Flags]internal enum ThumbButtonOptions{Enabled = 0x00000000,Disabled = 0x00000001,DismissOnClick = 0x00000002,NoBackground = 0x00000004,Hidden = 0x00000008,NonInteractive = 0x00000010}internal enum SetTabPropertiesOption{None = 0x0,UseAppThumbnailAlways = 0x1,UseAppThumbnailWhenActive = 0x2,UseAppPeekAlways = 0x4,UseAppPeekWhenActive = 0x8}[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]internal struct ThumbButton{/// <summary>/// WPARAM value for a THUMBBUTTON being clicked./// </summary>internal const int Clicked = 0x1800;[MarshalAs(UnmanagedType.U4)]internal ThumbButtonMask Mask;internal uint Id;internal uint Bitmap;internal IntPtr Icon;[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]internal string Tip;[MarshalAs(UnmanagedType.U4)]internal ThumbButtonOptions Flags;}/// <summary>/// HRESULT Wrapper/// </summary>public enum HResult{/// <summary>/// S_OK/// </summary>Ok = 0x0000,/// <summary>/// S_FALSE/// </summary>False = 0x0001,/// <summary>/// E_INVALIDARG/// </summary>InvalidArguments = unchecked((int)0x80070057),/// <summary>/// E_OUTOFMEMORY/// </summary>OutOfMemory = unchecked((int)0x8007000E),/// <summary>/// E_NOINTERFACE/// </summary>NoInterface = unchecked((int)0x80004002),/// <summary>/// E_FAIL/// </summary>Fail = unchecked((int)0x80004005),/// <summary>/// E_ELEMENTNOTFOUND/// </summary>ElementNotFound = unchecked((int)0x80070490),/// <summary>/// TYPE_E_ELEMENTNOTFOUND/// </summary>TypeElementNotFound = unchecked((int)0x8002802B),/// <summary>/// NO_OBJECT/// </summary>NoObject = unchecked((int)0x800401E5),/// <summary>/// Win32 Error code: ERROR_CANCELLED/// </summary>Win32ErrorCanceled = 1223,/// <summary>/// ERROR_CANCELLED/// </summary>Canceled = unchecked((int)0x800704C7),/// <summary>/// The requested resource is in use/// </summary>ResourceInUse = unchecked((int)0x800700AA),/// <summary>/// The requested resources is read-only./// </summary>AccessDenied = unchecked((int)0x80030005)}
}

 

静态类实现方法(推荐使用这个)

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;namespace wApp
{/// <summary>/// Represents an instance of the Windows taskbar/// </summary>public static class TaskbarManager{/// <summary>/// Sets the handle of the window whose taskbar button will be used/// to display progress./// </summary>private static IntPtr ownerHandle = IntPtr.Zero;static TaskbarManager(){var currentProcess = Process.GetCurrentProcess();if (currentProcess != null && currentProcess.MainWindowHandle != IntPtr.Zero)ownerHandle = currentProcess.MainWindowHandle;}/// <summary>/// Indicates whether this feature is supported on the current platform./// </summary>private static bool IsPlatformSupported{get { return Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.CompareTo(new Version(6, 1)) >= 0; }}/// <summary>/// Displays or updates a progress bar hosted in a taskbar button of the main application window /// to show the specific percentage completed of the full operation./// </summary>/// <param name="currentValue">An application-defined value that indicates the proportion of the operation that has been completed at the time the method is called.</param>/// <param name="maximumValue">An application-defined value that specifies the value currentValue will have when the operation is complete.</param>public static void SetProgressValue(int currentValue, int maximumValue){if (IsPlatformSupported && ownerHandle != IntPtr.Zero)TaskbarList.Instance.SetProgressValue(ownerHandle,Convert.ToUInt32(currentValue),Convert.ToUInt32(maximumValue));}/// <summary>/// Displays or updates a progress bar hosted in a taskbar button of the given window handle /// to show the specific percentage completed of the full operation./// </summary>/// <param name="windowHandle">The handle of the window whose associated taskbar button is being used as a progress indicator./// This window belong to a calling process associated with the button's application and must be already loaded.</param>/// <param name="currentValue">An application-defined value that indicates the proportion of the operation that has been completed at the time the method is called.</param>/// <param name="maximumValue">An application-defined value that specifies the value currentValue will have when the operation is complete.</param>public static void SetProgressValue(int currentValue, int maximumValue, IntPtr windowHandle){if (IsPlatformSupported)TaskbarList.Instance.SetProgressValue(windowHandle,Convert.ToUInt32(currentValue),Convert.ToUInt32(maximumValue));}/// <summary>/// Sets the type and state of the progress indicator displayed on a taskbar button of the main application window./// </summary>/// <param name="state">Progress state of the progress button</param>public static void SetProgressState(TaskbarProgressBarState state){if (IsPlatformSupported && ownerHandle != IntPtr.Zero)TaskbarList.Instance.SetProgressState(ownerHandle, (TaskbarProgressBarStatus)state);}/// <summary>/// Sets the type and state of the progress indicator displayed on a taskbar button /// of the given window handle /// </summary>/// <param name="windowHandle">The handle of the window whose associated taskbar button is being used as a progress indicator./// This window belong to a calling process associated with the button's application and must be already loaded.</param>/// <param name="state">Progress state of the progress button</param>public static void SetProgressState(TaskbarProgressBarState state, IntPtr windowHandle){if (IsPlatformSupported)TaskbarList.Instance.SetProgressState(windowHandle, (TaskbarProgressBarStatus)state);}}/// <summary>/// Represents the thumbnail progress bar state./// </summary>public enum TaskbarProgressBarState{/// <summary>/// No progress is displayed./// </summary>NoProgress = 0,/// <summary>/// The progress is indeterminate (marquee)./// </summary>Indeterminate = 0x1,/// <summary>/// Normal progress is displayed./// </summary>Normal = 0x2,/// <summary>/// An error occurred (red)./// </summary>Error = 0x4,/// <summary>/// The operation is paused (yellow)./// </summary>Paused = 0x8}/// <summary>/// Provides internal access to the functions provided by the ITaskbarList4 interface,/// without being forced to refer to it through another singleton./// </summary>internal static class TaskbarList{private static object _syncLock = new object();private static ITaskbarList4 _taskbarList;internal static ITaskbarList4 Instance{get{if (_taskbarList == null){lock (_syncLock){if (_taskbarList == null){_taskbarList = (ITaskbarList4)new CTaskbarList();_taskbarList.HrInit();}}}return _taskbarList;}}}[GuidAttribute("56FDF344-FD6D-11d0-958A-006097C9A090")][ClassInterfaceAttribute(ClassInterfaceType.None)][ComImportAttribute()]internal class CTaskbarList { }[ComImportAttribute()][GuidAttribute("c43dc798-95d1-4bea-9030-bb99e2983a1a")][InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]internal interface ITaskbarList4{// ITaskbarList
        [PreserveSig]void HrInit();[PreserveSig]void AddTab(IntPtr hwnd);[PreserveSig]void DeleteTab(IntPtr hwnd);[PreserveSig]void ActivateTab(IntPtr hwnd);[PreserveSig]void SetActiveAlt(IntPtr hwnd);// ITaskbarList2
        [PreserveSig]void MarkFullscreenWindow(IntPtr hwnd,[MarshalAs(UnmanagedType.Bool)] bool fFullscreen);// ITaskbarList3
        [PreserveSig]void SetProgressValue(IntPtr hwnd, UInt64 ullCompleted, UInt64 ullTotal);[PreserveSig]void SetProgressState(IntPtr hwnd, TaskbarProgressBarStatus tbpFlags);[PreserveSig]void RegisterTab(IntPtr hwndTab, IntPtr hwndMDI);[PreserveSig]void UnregisterTab(IntPtr hwndTab);[PreserveSig]void SetTabOrder(IntPtr hwndTab, IntPtr hwndInsertBefore);[PreserveSig]void SetTabActive(IntPtr hwndTab, IntPtr hwndInsertBefore, uint dwReserved);[PreserveSig]HResult ThumbBarAddButtons(IntPtr hwnd,uint cButtons,[MarshalAs(UnmanagedType.LPArray)] ThumbButton[] pButtons);[PreserveSig]HResult ThumbBarUpdateButtons(IntPtr hwnd,uint cButtons,[MarshalAs(UnmanagedType.LPArray)] ThumbButton[] pButtons);[PreserveSig]void ThumbBarSetImageList(IntPtr hwnd, IntPtr himl);[PreserveSig]void SetOverlayIcon(IntPtr hwnd,IntPtr hIcon,[MarshalAs(UnmanagedType.LPWStr)] string pszDescription);[PreserveSig]void SetThumbnailTooltip(IntPtr hwnd,[MarshalAs(UnmanagedType.LPWStr)] string pszTip);[PreserveSig]void SetThumbnailClip(IntPtr hwnd,IntPtr prcClip);// ITaskbarList4void SetTabProperties(IntPtr hwndTab, SetTabPropertiesOption stpFlags);}internal enum TaskbarProgressBarStatus{NoProgress = 0,Indeterminate = 0x1,Normal = 0x2,Error = 0x4,Paused = 0x8}internal enum ThumbButtonMask{Bitmap = 0x1,Icon = 0x2,Tooltip = 0x4,THB_FLAGS = 0x8}[Flags]internal enum ThumbButtonOptions{Enabled = 0x00000000,Disabled = 0x00000001,DismissOnClick = 0x00000002,NoBackground = 0x00000004,Hidden = 0x00000008,NonInteractive = 0x00000010}internal enum SetTabPropertiesOption{None = 0x0,UseAppThumbnailAlways = 0x1,UseAppThumbnailWhenActive = 0x2,UseAppPeekAlways = 0x4,UseAppPeekWhenActive = 0x8}[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]internal struct ThumbButton{/// <summary>/// WPARAM value for a THUMBBUTTON being clicked./// </summary>internal const int Clicked = 0x1800;[MarshalAs(UnmanagedType.U4)]internal ThumbButtonMask Mask;internal uint Id;internal uint Bitmap;internal IntPtr Icon;[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]internal string Tip;[MarshalAs(UnmanagedType.U4)]internal ThumbButtonOptions Flags;}/// <summary>/// HRESULT Wrapper/// </summary>public enum HResult{/// <summary>/// S_OK/// </summary>Ok = 0x0000,/// <summary>/// S_FALSE/// </summary>False = 0x0001,/// <summary>/// E_INVALIDARG/// </summary>InvalidArguments = unchecked((int)0x80070057),/// <summary>/// E_OUTOFMEMORY/// </summary>OutOfMemory = unchecked((int)0x8007000E),/// <summary>/// E_NOINTERFACE/// </summary>NoInterface = unchecked((int)0x80004002),/// <summary>/// E_FAIL/// </summary>Fail = unchecked((int)0x80004005),/// <summary>/// E_ELEMENTNOTFOUND/// </summary>ElementNotFound = unchecked((int)0x80070490),/// <summary>/// TYPE_E_ELEMENTNOTFOUND/// </summary>TypeElementNotFound = unchecked((int)0x8002802B),/// <summary>/// NO_OBJECT/// </summary>NoObject = unchecked((int)0x800401E5),/// <summary>/// Win32 Error code: ERROR_CANCELLED/// </summary>Win32ErrorCanceled = 1223,/// <summary>/// ERROR_CANCELLED/// </summary>Canceled = unchecked((int)0x800704C7),/// <summary>/// The requested resource is in use/// </summary>ResourceInUse = unchecked((int)0x800700AA),/// <summary>/// The requested resources is read-only./// </summary>AccessDenied = unchecked((int)0x80030005)}
}

 

二、使用方法

它有一静态公用变量Instance,直引用即可;或以静态类直接引用,而不再加以.Instance。以引用静态类为例:

        private void trackBar_ValueChanged(object sender, EventArgs e){TaskbarManager.SetProgressValue(trackBar.Value, trackBar.Maximum);}private void btnNoProgress_Click(object sender, EventArgs e){TaskbarManager.SetProgressState(TaskbarProgressBarState.NoProgress);}private void btnIndeterminate_Click(object sender, EventArgs e){TaskbarManager.SetProgressState(TaskbarProgressBarState.Indeterminate);}private void btnNormal_Click(object sender, EventArgs e){TaskbarManager.SetProgressState(TaskbarProgressBarState.Normal);TaskbarManager.SetProgressValue(trackBar.Value, trackBar.Maximum);}private void btn_Click(object sender, EventArgs e){TaskbarManager.SetProgressState(TaskbarProgressBarState.Error);TaskbarManager.SetProgressValue(trackBar.Value, trackBar.Maximum);}private void btnPaused_Click(object sender, EventArgs e){TaskbarManager.SetProgressState(TaskbarProgressBarState.Paused);TaskbarManager.SetProgressValue(trackBar.Value, trackBar.Maximum);}

 

三、效果如下图示:

 

 

 

参考资料:

Windows 7 progress bar in taskbar in C#? - Stack Overflow

dbarros/WindowsAPICodePack: A fork of the Windows API Code Pack with additional fixes and features by yours truly.

转载于:https://www.cnblogs.com/crwy/p/10091034.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/464005.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

今天,过了27年后,IE浏览器停用了

前言随着Windows的官宣&#xff0c;ie浏览器将于6月16日正式退役。https://www.microsoft.com/zh-cn/download/internet-explorer.aspx那个曾几何时的浏览器之王&#xff0c;经历一次又一次操作系统的迭代&#xff0c;直至新兴浏览器的出现后沦为浏览器鄙视链的最后一层&#x…

boost库学习入门篇

学习及使用Boost库已经有一段时间了&#xff0c;Boost为我的日常开发中带来了极大的方便&#xff0c;也使得我越来越依赖于boost库了。但boost功能太多&#xff0c;每次使用还是得翻看以前的 资料&#xff0c;所以为了以后可以更方便的使用&#xff0c;在此对常用的功能作一个…

开源 STM32 USB-CAN项目

照理来说&#xff0c;USB-CAN这种东西应该已经被做的烂大街的工具&#xff0c;国内居然没有一个拿得出手的开源方案。某立功和PCAN动辄2000的价格也是离谱。淘宝上各种虚拟串口方案、替换dll兼容某立功软件的各种方案....价格都倒是便宜&#xff0c;性能和可靠性嘛.......就不多…

Go语言web框架 gin

Go语言web框架 GIN gin是go语言环境下的一个web框架, 它类似于Martini, 官方声称它比Martini有更好的性能, 比Martini快40倍, Ohhhh….看着不错的样子, 所以就想记录一下gin的学习. gin的github代码在这里: gin源码. gin的效率获得如此突飞猛进, 得益于另一个开源项目httproute…

8位ADC是256还是255?

昨天的文章发了之后&#xff0c;有朋友找到我&#xff0c;给我讨论了很多关于ADC细节。晚上给个朋友在51上调ADC0808芯片有一个朋友是做硬件的&#xff0c;他有从事过专业仪器设备&#xff0c;常年有使用ADC的经验&#xff0c;他给我的观点是&#xff0c;8位ADC对应的就是256。…

boost库在ubuntu下的安装

系统是ubuntu虚拟机&#xff0c;安装的是boost_1_60_0。 &#xff08;1&#xff09;首先去下载最新的boost代码包&#xff0c;网址www.boost.org。 &#xff08;2&#xff09;进入到自己的目录&#xff0c;解压&#xff1a; bzip2 -d boost_1_60_0.tar.bz2 tar xvf boost_1_…

所谓的0拷贝不就是为了让CPU休息吗?深入理解mmap

1.开场白环境&#xff1a;处理器架构&#xff1a;arm64内核源码&#xff1a;linux-5.11ubuntu版本&#xff1a;20.04.1代码阅读工具&#xff1a;vimctagscscope我们知道&#xff0c;linux系统中用户空间和内核空间是隔离的&#xff0c;用户空间程序不能随意的访问内核空间数据&…

boost::function的用法(一)

boost::function的用法 本片文章主要介绍boost::function的用法。 boost::function 就是一个函数的包装器(function wrapper)&#xff0c;用来定义函数对象。 1. 介绍 Boost.Function 库包含了一个类族的函数对象的包装。它的概念很像广义上的回调函数。其有着和函数指针相同的…

nhibernate学习之集合组合依赖

1.学习目标还是学习compenent的用法&#xff0c;上节实现了简单字段的组合&#xff0c;这节中将讨论两个问题&#xff1a;1.依赖对象有一个指向容器对象的引用。2。集合依赖2.开发环境和必要准备开发环境为:windows 2003,Visual studio .Net 2005,Sql server 2005 developer ed…

追更这个做嵌入式的大佬

在知乎上看到一个做嵌入式91年小年轻&#xff0c;分享给大家在他看来&#xff0c;嵌入式也是一个很吃香的技术&#xff0c;在周末写这篇文章的时候&#xff0c;也刚收到一个朋友的微信消息&#xff0c;他说自己拿到了70多万的年包offer。大家想追更作者的原文&#xff0c;可以点…

CentOS6.5安装ElasticSearch6.2.3

CentOS6.5安装ElasticSearch6.2.3 1、Elastic 需要 Java 8 环境。&#xff08;安装步骤&#xff1a;http://www.cnblogs.com/hunttown/p/5450463.html&#xff09; 2、安装包下载&#xff1a; #官网地址 https://www.elastic.co/downloads/elasticsearch 3、新建用户 Elastic高…

这道字符串反转的题目,你能想到更好的方法吗?

周末有一个朋友问了一个笔试题目&#xff0c;当时还直播写了答案&#xff0c;但是总觉得写得不够好&#xff0c;现在把题目放出来。大家看看有没有什么更好的解法题目有一个字符串&#xff0c;如下&#xff0c;要求对字符串做反转后输出//input the sky is blue//output blue …

流媒体服务器搭建实例——可实现录音,录像功能

由于我也是刚开始接触这个东东&#xff0c;原理什么的不是很清楚&#xff0c;这里我就不说了&#xff0c;免得误人子弟&#xff0c;嘿嘿&#xff01;第一步&#xff0c;下载FlashMediaServer3.5&#xff0c;网上有很多资源&#xff0c;这里就不提供了&#xff0c;大家google一下…

一个女孩子居然做了十年硬件。​。。

本文转自面包板社区。--正文--2011年&#xff0c;一个三本大学的电子信息专业的大三女学生跟2个通信专业的大二男生组成了一组代表学校参加2011年“瑞萨杯”全国大学生电子设计大赛&#xff0c;很意外的获得了湖北赛区省三等奖&#xff0c;虽然很意外&#xff0c;但还是挺高兴的…

之前字符串反转的题目

之前发的字符串反转的题目这道字符串反转的题目&#xff0c;你能想到更好的方法吗&#xff1f;有很多人评论了&#xff0c;有的人还写了自己的解题思路&#xff0c;还有人写了自己的代码还有其中呼声很高的压栈解法我相信很多人在笔试的时候一定会遇到这类题目&#xff0c;给你…

hdu 3488

可以作为KM 二分图最大权匹配模板 View Code #include <stdio.h>#include <iostream>#include <string.h>using namespace std;const int N210;const int inf0x2fffffff;const int Max20000;int match[N],n,m,lack,w[N][N],lx[N],ly[N];bool vx[N],vy[N];bo…

心情不好,我就这样写代码

在 GitHub 上有一个项目&#xff0c;它描述了「最佳垃圾代码」的十九条关键准则。从变量命名到注释编写&#xff0c;这些准则将指导你写出最亮眼的烂代码。为了保持与原 GitHub 项目一致的风格&#xff0c;下文没有进行转换。读者们可以以相反的角度来理解所有观点&#xff0c;…

递归是会更秀strtok

前几天发的字符串反转题目&#xff0c;后面有一个新同学用了递归的方法来实现&#xff0c;看了下&#xff0c;真的是很秀。之前字符串反转的题目代码如下#include "stdio.h" #include "string.h" char input[] {"the sky is blue cris 1212321 apple…

ios开发网络篇—HTTP协议 - 转

一.URL 1.基本介绍 URL的全称是Uniform Resource Locator(统一资源定位符) &#xff0c;通过1个URL&#xff0c;能找到互联网唯一的1个资源 &#xff0c;URL就是资源的地址&#xff0c;位置&#xff0c;互联网上的每个资源都有一个唯一的URL 2.URL中常见的协议 (1)HTTP&#…

总结的一些内存问题

前言之前在实习时&#xff0c;听了 OOM 的分享之后&#xff0c;就对 Linux 内核内存管理充满兴趣&#xff0c;但是这块知识非常庞大&#xff0c;没有一定积累&#xff0c;不敢写下&#xff0c;担心误人子弟&#xff0c;所以经过一个一段时间的积累&#xff0c;对内核内存有一定…