C# Winform WPF DeskBand 窗體嵌入任務欄,在任務欄顯示文字

来源:https://www.cnblogs.com/s0611163/archive/2017/12/29/8142913.html
-Advertisement-
Play Games

最近寫了個小程式,用於將固態硬碟的寫入量等信息顯示在任務欄,最開始使用Windows API也可以實現,但是當任務欄托盤增加的時候,會被遮蓋,最終採用了DeskBand來實現,填了很多坑。 參考的GitHub地址:https://github.com/dsafa/CSDeskBand DeskBan ...


    最近寫了個小程式,用於將固態硬碟的寫入量等信息顯示在任務欄,最開始使用Windows API也可以實現,但是當任務欄托盤增加的時候,會被遮蓋,最終採用了DeskBand來實現,填了很多坑。

    參考的GitHub地址:https://github.com/dsafa/CSDeskBand

    DeskBand相關代碼如下:

COLORREF:

// This code snippet was used by SharpShell.
//

using System.Drawing;
using System.Runtime.InteropServices;

namespace MyDiskInfo.Interop
{
    [StructLayout(LayoutKind.Sequential)]
    public struct COLORREF
    {
        public COLORREF(Color color)
        {
            Dword = (uint)color.R + (((uint)color.G) << 8) + (((uint)color.B) << 16);
        }

        public uint Dword;
        public Color Color
        {
            get
            {
                return Color.FromArgb(
                    (int)(0x000000FFU & Dword),
                    (int)(0x0000FF00U & Dword) >> 8,
                    (int)(0x00FF0000U & Dword) >> 16);
            }
        }
    }
}
View Code

DESKBANDINFO:

using System;
using System.Runtime.InteropServices;

namespace MyDiskInfo.Interop
{
    /// <summary>
    /// Receives information about a band object. This structure is used with the deprecated IDeskBand::GetBandInfo method.
    /// </summary>
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    public struct DESKBANDINFO
    {
        /// <summary>
        /// Set of flags that determine which members of this structure are being requested. 
        /// </summary>
        /// <remarks>
        /// This will be a combination of the following values:
        ///     DBIM_MINSIZE    ptMinSize is being requested.
        ///     DBIM_MAXSIZE    ptMaxSize is being requested.
        ///     DBIM_INTEGRAL   ptIntegral is being requested.
        ///     DBIM_ACTUAL     ptActual is being requested.
        ///     DBIM_TITLE      wszTitle is being requested.
        ///     DBIM_MODEFLAGS  dwModeFlags is being requested.
        ///     DBIM_BKCOLOR    crBkgnd is being requested.
        /// </remarks>
        public DBIM dwMask;

        /// <summary>
        /// Point structure that receives the minimum size of the band object. 
        /// The minimum width is placed in the x member and the minimum height 
        /// is placed in the y member. 
        /// </summary>
        public POINT ptMinSize;

        /// <summary>
        /// Point structure that receives the maximum size of the band object. 
        /// The maximum height is placed in the y member and the x member is ignored. 
        /// If there is no limit for the maximum height, (LONG)-1 should be used. 
        /// </summary>
        public POINT ptMaxSize;

        /// <summary>
        /// Point structure that receives the sizing step value of the band object. 
        /// The vertical step value is placed in the y member, and the x member is ignored. 
        /// The step value determines in what increments the band will be resized. 
        /// </summary>
        /// <remarks>
        /// This member is ignored if dwModeFlags does not contain DBIMF_VARIABLEHEIGHT. 
        /// </remarks>
        public POINT ptIntegral;

        /// <summary>
        /// Point structure that receives the ideal size of the band object. 
        /// The ideal width is placed in the x member and the ideal height is placed in the y member. 
        /// The band container will attempt to use these values, but the band is not guaranteed to be this size.
        /// </summary>
        public POINT ptActual;

        /// <summary>
        /// The title of the band.
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 255)]
        public String wszTitle;

        /// <summary>
        /// A value that receives a set of flags that define the mode of operation for the band object. 
        /// </summary>
        /// <remarks>
        /// This must be one or a combination of the following values.
        ///     DBIMF_NORMAL
        ///     The band is normal in all respects. The other mode flags modify this flag.
        ///     DBIMF_VARIABLEHEIGHT
        ///     The height of the band object can be changed. The ptIntegral member defines the 
        ///     step value by which the band object can be resized. 
        ///     DBIMF_DEBOSSED
        ///     The band object is displayed with a sunken appearance.
        ///     DBIMF_BKCOLOR
        ///     The band will be displayed with the background color specified in crBkgnd.
        /// </remarks>
        public DBIMF dwModeFlags;

        /// <summary>
        /// The background color of the band.
        /// </summary>
        /// <remarks>
        /// This member is ignored if dwModeFlags does not contain the DBIMF_BKCOLOR flag. 
        /// </remarks>
        public COLORREF crBkgnd;

        /// <summary>
        /// The view mode of the band object. This is one of the following values.
        /// </summary>
        [Flags]
        public enum DBIF
        {
            /// <summary>
            /// Band object is displayed in a horizontal band.
            /// </summary>
            DBIF_VIEWMODE_NORMAL = 0x0000,

            /// <summary>
            /// Band object is displayed in a vertical band.
            /// </summary>
            DBIF_VIEWMODE_VERTICAL = 0x0001,

            /// <summary>
            /// Band object is displayed in a floating band.
            /// </summary>
            DBIF_VIEWMODE_FLOATING = 0x0002,

            /// <summary>
            /// Band object is displayed in a transparent band.
            /// </summary>
            DBIF_VIEWMODE_TRANSPARENT = 0x0004
        }

        /// <summary>
        /// The set of flags that determine which members of this structure are being requested by the caller. One or more of the following values:
        /// </summary>
        [Flags]
        public enum DBIM
        {
            /// <summary>
            /// ptMinSize is requested.
            /// </summary>
            DBIM_MINSIZE = 0x0001,

            /// <summary>
            /// ptMaxSize is requested.
            /// </summary>
            DBIM_MAXSIZE = 0x0002,

            /// <summary>
            /// ptIntegral is requested.
            /// </summary>
            DBIM_INTEGRAL = 0x0004,

            /// <summary>
            /// ptActual is requested.
            /// </summary>
            DBIM_ACTUAL = 0x0008,

            /// <summary>
            /// wszTitle is requested.
            /// </summary>
            DBIM_TITLE = 0x0010,

            /// <summary>
            /// dwModeFlags is requested.
            /// </summary>
            DBIM_MODEFLAGS = 0x0020,

            /// <summary>
            /// crBkgnd is requested.
            /// </summary>
            DBIM_BKCOLOR = 0x0040
        }

        /// <summary>
        /// A value that receives a set of flags that specify the mode of operation for the band object. One or more of the following values:
        /// </summary>
        [Flags]
        public enum DBIMF : uint
        {
            /// <summary>
            /// The band uses default properties. The other mode flags modify this flag.
            /// </summary>
            DBIMF_NORMAL = 0x0000,

            /// <summary>
            /// Windows XP and later: The band object is of a fixed sized and position. With this flag, a sizing grip is not displayed on the band object.
            /// </summary>
            DBIMF_FIXED = 0x0001,

            /// <summary>
            /// DBIMF_FIXEDBMP
            /// Windows XP and later: The band object uses a fixed bitmap (.bmp) file as its background. Note that backgrounds are not supported in all cases, so the bitmap may not be seen even when this flag is set.
            /// </summary>
            DBIMF_FIXEDBMP = 0x0004,

            /// <summary>
            /// The height of the band object can be changed. The ptIntegral member defines the step value by which the band object can be resized.
            /// </summary>
            DBIMF_VARIABLEHEIGHT = 0x0008,

            /// <summary>
            /// Windows XP and later: The band object cannot be removed from the band container.
            /// </summary>
            DBIMF_UNDELETEABLE = 0x0010,

            /// <summary>
            /// The band object is displayed with a sunken appearance.
            /// </summary>
            DBIMF_DEBOSSED = 0x0020,

            /// <summary>
            /// The band is displayed with the background color specified in crBkgnd.
            /// </summary>
            DBIMF_BKCOLOR = 0x0040,

            /// <summary>
            /// Windows XP and later: If the full band object cannot be displayed (that is, the band object is smaller than ptActual, a chevron is shown to indicate that there are more options available. These options are displayed when the chevron is clicked.
            /// </summary>
            DBIMF_USECHEVRON = 0x0080,

            /// <summary>
            /// Windows XP and later: The band object is displayed in a new row in the band container.
            /// </summary>
            DBIMF_BREAK = 0x0100,

            /// <summary>
            /// Windows XP and later: The band object is the first object in the band container.
            /// </summary>
            DBIMF_ADDTOFRONT = 0x0200,

            /// <summary>
            /// Windows XP and later: The band object is displayed in the top row of the band container.
            /// </summary>
            DBIMF_TOPALIGN = 0x0400,

            /// <summary>
            /// Windows Vista and later: No sizing grip is ever displayed to allow the user to move or resize the band object.
            /// </summary>
            DBIMF_NOGRIPPER = 0x0800,

            /// <summary>
            /// Windows Vista and later: A sizing grip that allows the user to move or resize the band object is always shown, even if that band object is the only one in the container.
            /// </summary>
            DBIMF_ALWAYSGRIPPER = 0x1000,

            /// <summary>
            /// Windows Vista and later: The band object should not display margins.
            /// </summary>
            DBIMF_NOMARGINS = 0x2000
        }
    }
}
View Code

POINT:

// This code snippet was used by SharpShell.
//
using System.Runtime.InteropServices;

namespace MyDiskInfo.Interop
{
    /// <summary>
    /// The POINT structure defines the x- and y- coordinates of a point.
    /// </summary>
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    public struct POINT
    {
        /// <summary>
        /// The x-coordinate of the point.
        /// </summary>
        public int X;

        /// <summary>
        /// The y-coordinate of the point.
        /// </summary>
        public int Y;
    }
}
View Code

RECT:

using System.Runtime.InteropServices;

namespace MyDiskInfo.Interop
{
    [StructLayout(LayoutKind.Sequential)]
    public struct RECT
    {
        public RECT(int left, int top, int right, int bottom)
        {
            this.left = left;
            this.top = top;
            this.right = right;
            this.bottom = bottom;
        }


        public int left, top, right, bottom;

        public int Width()
        {
            return right - left;
        }

        public int Height()
        {
            return bottom - top;
        }

        public void Offset(int x, int y)
        {
            left += x;
            right += x;
            top += y;
            bottom += y;
        }

        public void Set(int left, int top, int right, int bottom)
        {
            this.left = left;
            this.top = top;
            this.right = right;
            this.bottom = bottom;
        }

        public bool IsEmpty()
        {
            return Width() == 0 && Height() == 0;
        }
    }
}
View Code

Attributes:

using System;
using System.Runtime.InteropServices;

namespace MyDiskInfo
{
    /// <summary>
    /// The display name of the extension and the description for the HelpText(displayed in status bar when menu command selected).
    /// </summary>
    [AttributeUsage(AttributeTargets.Class)]
    public class DeskBandInfoAttribute : System.Attribute
    {
        private string _displayName;
        private string _helpText;

        public string DisplayName
        {
            get { return _displayName; }
        }

        public string HelpText
        {
            get { return _helpText; }
        }

        public DeskBandInfoAttribute() { }

        public DeskBandInfoAttribute(string displayName, string helpText)
        {
            _displayName = displayName;
            _helpText = helpText;
        }
    }
}
View Code

ComImport:

using System;
using System.Runtime.InteropServices;

namespace MyDiskInfo.Interop
{
    /// <summary>
    /// Provides a simple way to support communication between an object and its site in the container.
    /// </summary>
    [ComImport]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    [Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352")]
    public interface IObjectWithSite
    {
        /// <summary>
        /// Enables a container to pass an object a pointer to the interface for its site.
        /// </summary>
        /// <param name="pUnkSite">A pointer to the IUnknown interface pointer of the site managing this object.
        /// If NULL, the object should call Release on any existing site at which point the object no longer knows its site.</param>
        void SetSite([In, MarshalAs(UnmanagedType.IUnknown)] Object pUnkSite);

        /// <summary>
        /// Retrieves the latest site passed using SetSite.
        /// </summary>
        /// <param name="riid">The IID of the interface pointer that should be returned in ppvSite.</param>
        /// <param name="ppvSite">Address of pointer variable that receives the interface pointer requested in riid.</param>
        void GetSite(ref Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out Object ppvSite);
    }

    /// <summary>
    /// Exposes a method that is used to communicate focus changes for a user input object contained in the Shell.
    /// </summary>
    [ComImport]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    [Guid("F1DB8392-7331-11D0-8C99-00A0C92DBFE8")]
    public interface IInputObjectSite
    {
        /// <summary>
        /// Informs the browser that the focus has changed.
        /// </summary>
        /// <param name="punkObj">The address of the IUnknown interface of the object gaining or losing the focus.</param>
        /// <param name="fSetFocus">Indicates if the object has gained or lost the focus. If this value is nonzero, the object has gained the focus.
        /// If this value is zero, the object has lost the focus.</param>
        /// <returns>Returns S_OK if the method was successful, or a COM-defined error code otherwise.</returns>
        [PreserveSig]
        Int32 OnFocusChangeIS([MarshalAs(UnmanagedType.IUnknown)] Object punkObj, Int32 fSetFocus);
    }

    /// <summary>
    /// The IOleWindow interface provides methods that allow an application to obtain the handle to the various windows that participate in in-place activation, and also to enter and exit context-sensitive help mode.
    /// </summary>
    [ComImport]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    [Guid("00000114-0000-0000-C000-000000000046")]
    public interface IOleWindow
    {
        /// <summary>
        /// Retrieves a handle to one of the windows participating in in-place activation (frame, document, parent, or in-place object window).
        /// </summary>
        /// <param name="phwnd">A pointer to a variable that receives the window handle.</param>
        /// <returns>This method returns S_OK on success.</returns>
        [PreserveSig]
        int GetWindow(out IntPtr phwnd);

        /// <summary>
        /// Determines whether context-sensitive help mode should be entered during an in-place activation session.
        /// </summary>
        /// <param name="fEnterMode">TRUE if help mode should be entered; FALSE if it should be exited.</param>
        /// <returns>This method returns S_OK if the help mode was entered or exited successfully, depending on the value passed in fEnterMode.</returns>
        [PreserveSig]
        int ContextSensitiveHelp(bool fEnterMode);
    }

    [ComImport]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    [Guid("012DD920-7B26-11D0-8CA9-00A0C92DBFE8")]
    public interface IDockingWindow : IOleWindow
    {
        #region IOleWindow

        [PreserveSig]
        new int GetWindow(out IntPtr phwnd);

        [PreserveSig]
        new int ContextSensitiveHelp(bool fEnterMode);

        #endregion

        /// <summary>
        /// Instructs the docking window object to show or hide itself.
        /// </summary>
        /// <param name="fShow">TRUE if the docking window object should show its window.
        /// FALSE if the docking window object should hide its window and return its border space by calling SetBorderSpaceDW with zero values.</param>
        /// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
        [PreserveSig]
        int ShowDW([In] bool fShow);

        /// <summary>
        /// Notifies the docking window object that it is about to be removed from the frame.
        /// The docking window object should save any persistent information at this time.
        /// </summary>
        /// <param name="dwReserved">Reserved. This parameter should always be zero.</param>
        /// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
        [PreserveSig]
        int CloseDW([In] UInt32 dwReserved);

        /// <summary>
        /// Notifies the docking window object that the frame's border space has changed.
        /// </summary>
        /// <param name="prcBorder">Pointer to a RECT structure that contains the frame's available border space.</param>
        /// <param name="punkToolbarSite">Pointer to the site's IUnknown interface. The docking window object should call the QueryInterface method for this interface, requesting IID_IDockingWindowSite.
        /// The docking window object then uses that interface to negotiate its border space. It is the docking window object's responsibility to release this interface when it is no longer needed.</param>
        /// <param name="fReserved">Reserved. This parameter should always be zero.</param>
        /// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
        [PreserveSig]
        int ResizeBorderDW(RECT prcBorder, [In, MarshalAs(UnmanagedType.IUnknown)] IntPtr punkToolbarSite, bool fReserved);
    }

    /// <summary>
    /// Gets information about a band object.
    /// </summary>
    [ComImport]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    [Guid("EB0FE172-1A3A-11D0-89B3-00A0C90A90AC")]
    public interface IDeskBand : IDockingWindow
    {
        #region IOleWindow

        [PreserveSig]
        new int GetWindow(out IntPtr phwnd);

        [PreserveSig]
        new int ContextSensitiveHelp(bool fEnterMode);

        #endregion

        #region IDockingWindow

        [PreserveSig]
        new int ShowDW([In] bool fShow);

        [PreserveSig]
        new int CloseDW([In] UInt32 dwReserved);

        [PreserveSig]
        new int ResizeBorderDW(RECT prcBorder, [In, MarshalAs(UnmanagedType.IUnknown)] IntPtr punkToolbarSite, bool fReserved);

        #endregion

        /// <summary>
        /// Gets state information for a band object.
        /// </summary>
        /// <param name="dwBandID">The identifier of the band, assigned by the container. The band object can retain this value if it is required.</param>
        /// <param name="dwViewMode">The view mode of the band object. One of the following values: DBIF_VIEWMODE_NORMAL, DBIF_VIEWMODE_VERTICAL, DBIF_VIEWMODE_FLOATING, DBIF_VIEWMODE_TRANSPARENT.</param>
        /// <param name="pdbi">Pointer to a DESKBANDINFO structure that receives the band information for the object. The dwMask member of this structure indicates the specific information that is being requested.</param>
        /// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
        [PreserveSig]
        int GetBandInfo(UInt32 dwBandID, DESKBANDINFO.DBIF dwViewMode, ref DESKBANDINFO pdbi);
    }

    /// <summary>
    /// Exposes methods to enable and query translucency effects in a deskband object.
    /// </summary>
    [ComImport]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    [Guid("79D16DE4-ABEE-4021-8D9D-9169B261D657")]
    public interface IDeskBand2 : IDeskBand
    {
        #region IOleWindow

        [PreserveSig]
        new int GetWindow(out IntPtr phwnd);

        [PreserveSig]
        new int ContextSensitiveHelp(bool fEnterMode);

        #endregion

        #region IDockingWindow

        [PreserveSig]
        new int ShowDW([In] bool fShow);

        [PreserveSig]
        new int CloseDW([In] UInt32 dwReserved);

        [PreserveSig]
        new int ResizeBorderDW(RECT prcBorder, [In, MarshalAs(UnmanagedType.IUnknown)] IntPtr punkToolbarSite, bool fReserved);

        #endregion

        #region IDeskBand

        [PreserveSig]
        new int GetBandInfo(UInt32 dwBandID, DESKBANDINFO.DBIF dwViewMode, ref DESKBANDINFO pdbi);

        #endregion

        /// <summary>
        /// Indicates the deskband's ability to be displayed as translucent.
        /// </summary>
        /// <param name="pfCanRenderComposited">When this method returns, contains a BOOL indicating ability.</param>
        /// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
        [PreserveSig]
        int CanRenderComposited(out bool pfCanRenderComposited);

        /// <summary>
        /// Sets the composition state.
        /// </summary>
        /// <param name="fCompositionEnabled">TRUE to enable the composition state; otherwise, FALSE.</param>
        /// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
        [PreserveSig]
        int SetCompositionState(bool fCompositionEnabled);

        /// <summary>
        /// Gets the composition state.
        /// </summary>
        /// <param name="pfCompositionEnabled">When this method returns, contains a BOOL that indicates state.</param>
        /// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
        [PreserveSig]
        int GetCompositionState(out bool pfCompositionEnabled);
    }
}
View Code

DeskBand,這裡和GitHub上的程式不同的是,DeskBand直接繼承的ElementHost類,GitHub上的好像是多例的,我想要的是單例的,所以修改了一下。這裡粘的代碼是WPF的,如果你想實現Winform的,就讓DeskBand繼承UserControl,DeskBand代碼如下:

// Copyright(c) 2017 Patrick Becker
//
//
              
您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 對文件操作,需要將文件臨時存儲在當前用戶臨時文件夾中: class Bt { public void LocalTempPath() { var tempPath = System.IO.Path.GetTempPath(); Console.WriteLine(tempPath); } } 程式運 ...
  • 一.安裝Centos虛擬機 過程省略…… 二.安裝.Net Core環境 咱直接登錄.net core官網,安裝官網提示的指令依次敲下去就行了, 添加.net 產品註入 1. sudo rpm --import https://packages.microsoft.com/keys/microsof ...
  • (1)簡述ASP.NET內置對象。 答:ASP.NET提供了內置對象有Page、Request、Response、Application、Session、Server、Mail和Cookies。這些對象使用戶更容易收集通過瀏覽器請求發送的信息、響應瀏覽器以及存儲用戶信息,以實現其他特定的狀態管理和頁 ...
  • 實現這個功能,方法很多。下麵Insus.NET列舉2個方法: class Bs { public string String1 { get; set; } public string String2 { get; set; } public void WithContains() { var out ...
  • 經常使用控制台來寫小玩意,總希望有個進度條,各種百度,終於簡單實現: 先上進度條幫助類: public class ConsoleProgress { static ConsoleProgress consoleProgress = new ConsoleProgress(); int top=0; ...
  • 如下XML文件:(算是一個屬性值比較多的xml文件。。。讀取該Xml算是我在公司實際的一個任務) 創建一個類WriteXml用來封裝讀取Xml的和屬性值方法:代碼如下 在控制臺上運行。。 運行結果如下: 好了,以上就是讀取該XML文件以及實際運行結果圖。。。。。。。 大牛們就當看個笑話啦!當然有哪裡 ...
  • [TOC] 說說ABP的依賴註入 上篇 "abp運行機制分析" 分析了ABP在啟動時,都做了那些事;這篇我們來說說ABP的最核心的一部分:依賴註入(DependencyInjection),以下簡稱DI; DI的概念我就不說了,關鍵字出來的資料非常多了,這裡就不說了,這裡主要討論的是ABP是如何做到 ...
  • winform原生combox,點擊之後,焦點一直都在,在還沒點其他地方的時候,滾動滾輪會導致值的改變。 原理很簡單:當mouse_leave的時候,取消他的焦點就可以了。 代碼如下: private void Cmb_MouseLeave(object sender, EventArgs e) { ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...