Time of Update: 2018-12-07
Code highlighting produced by Actipro CodeHighlighter
Time of Update: 2018-12-07
Code highlighting produced by Actipro CodeHighlighter
Time of Update: 2018-12-07
鉤子其實就是調用一下API而已:1、安裝鉤子: SetWindowsHookEx 函數原形:HHOOK SetWindowsHookEx( int idHook, // 鉤子類型, HOOKPROC lpfn, // 鉤子函數地址 INSTANCE hMod, // 鉤子所在的執行個體的控制代碼,
Time of Update: 2018-12-07
一、 摘要: 這篇文章將告訴你如何開發與.NET屬性視窗互動的RAD組件 二、 內容: 簡介 屬性視窗可以做什麼 基礎知識:使用Attribute來訂製屬性視窗的顯示 擴充屬性和字串轉換:TypeConverter和屬性視窗 編寫和顯示訂製的類型 提供可互動的屬性視圖 我們同樣可以使用它 結論 三、 簡介 在Visual Basic中,屬性視窗是真正實現快速應用開發的一個關鍵工具(RAD:Rapid Application Development)。在Visual Studio
Time of Update: 2018-12-07
關於C#靜態建構函式的幾點說明靜態建構函式是C#的一個新特性,其實好像很少用到。不過當我們想初始化一些靜態變數的時候就需要用到它了。這個建構函式是屬於類的,而不是屬於哪裡執行個體的,就是說這個建構函式只會被執行一次。也就是在建立第一個執行個體或引用任何靜態成員之前,由.NET自動調用。 class SimpleClass{ // Static constructor static SimpleClass() { // }} 在使用靜態建構函式的時候應該注
Time of Update: 2018-12-07
在 C# 中,(int),Int32.Parse() 和 Convert.toInt32()、Int32.TryParse()四種方法有何區別? int 關鍵字表示一種整型,是32位的,它的 .NET Framework 類型為 System.Int32。Int32.TryParse()不拋異常,會返回true或false來說明解析是否成功,如果解析錯誤,調用方將會得到0值。 (int)表示使用顯式強制轉換,是一種類型轉換。當我們從 int 類型到
Time of Update: 2018-12-07
Time of Update: 2018-12-07
一, 什麼叫異常? 異常就是程式運行時的錯誤,它違反了一個系統約束或應用程式約束,或出 現了在正常操作時未預料的情形。如用0去除一個數時就會發生異常。二, try…catch…finally…語句的結構? 未例: try { Statement; } catch(…) { Statement; } finally {
Time of Update: 2018-12-07
對於實值型別,如果對象的值相等,則相等運算子 (==) 返回 true,否則返回 false。對於string 以外的參考型別,如果兩個對象引用同一個對象,則 == 返回 true。對於 string 類型,== 比較字串的值。 ==操作比較的是兩個變數的值是否相等。 equals()方法比較的是兩個對象的內容是否一致.equals也就是比較參考型別是否是對同一個對象的引用。
Time of Update: 2018-12-07
一、帶一個參數Thread thrd = new Thread (new ParameterizedThreadStart(StartWriteToText));thrd.Start (strParameter);static void StartWriteToText(object objParameter){ // ....} private static void StartThreadWriteToText(object objParameter){ ThreadParameter
Time of Update: 2018-12-07
伺服器端:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->using System;using System.Collections.Generic;using System.Text;using System.Net;using System.Net.Sockets;namespace UDPServer{ class Program
Time of Update: 2018-12-07
很多程式員不知道C中的“宏”到底是什麼意思?特別是當宏有參數的時候,經常把宏和函數混淆。我想在這裡我還是先講講“宏”,宏只是一種定義,他定義了一個語句塊,當程式編譯時間,編譯器首先要執行一個“替換”來源程式的動作,把宏引用的地方替換成宏定義的語句塊,就像文字檔替換一樣。這個動作術語叫“宏的展開”。使用宏是比較“危險”的,因為你不知道宏展開後會是什麼一個樣子。例如下面這個宏:#define MAX(a, b) a>b?a:b當我們這樣使用宏時,沒有什麼問題: MAX( num1
Time of Update: 2018-12-07
#region 繪製圓角矩形地區 internal static GraphicsPath CreateRoundedRectanglePath(Rectangle rect, int cornerRadius) { GraphicsPath roundedRect = new GraphicsPath(); roundedRect.AddArc(rect.X, rect.Y, cornerRadius * 2,
Time of Update: 2018-12-07
五、 基礎知識:使用Attribute來訂製屬性視窗的顯示 控制顯示的機制和用IDL定義的組件是一樣的,不過是增加了中繼資料特性。控制顯示使用最普遍的特性是BrowsableAttribute。預設狀態下,屬性視窗顯示對象中定義的所有的公開的、可讀的(即public、有get或者set方法的)屬性,並且把他們放在“雜項(Misc)”類別中。下面是一個簡單的組件例子: public class SimpleComponent : System.ComponentModel.Component {
Time of Update: 2018-12-07
七、 編寫和顯示訂製的類型 屬性視窗中的編輯有如下三種工作方式:一,有些場合可以作為字串來編輯,然後由TypeConverter來實作類別型的轉換。二,可以顯示一個下拉式清單來選擇值。三,一個省略按鈕提供其他的UI介面來編輯值,比如FileDialog和FontPicker。我們已經講過了字串形式,接著我們就來看下拉式清單。 .NET framework已經包含了好幾種下拉式清單的例子,如Color,AccessibleRole,Dock等屬性。我們從可以看到下拉式清單的具體實現。 圖4.
Time of Update: 2018-12-07
利用WINDOWS訊息迴圈的機制傳遞自訂的結構體在編程的過程中可能經常會用到,在這裡我就編寫了一個簡單的結構體的傳遞代碼,需要注意的是類是不能夠傳遞的,能進行傳遞的只能是結構體using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using
Time of Update: 2018-12-07
(一)寫入 1.建立檔案 建立一個註冊表格式檔案: *.reg,內容如下: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Test] "server"="192.168.66.22" "database"="NorthWind" "user"="XiaoWang" "Password"="123456" 其中: I.
Time of Update: 2018-12-07
六、 擴充屬性和字串轉換:TypeConverter和屬性視窗 .NET屬性視窗最重要的一個特性就是可以顯示嵌套的屬性,這樣就提供了比屬性類別更加細化和更有邏輯的分類。嵌套屬性對於類目顯示和排序顯示都是適用的。這樣可以讓屬性列表更加緊湊。比如我們用帶有子屬性X和Y的一個Location屬性來代替Top和Left兩個屬性就更加合理。 不過,如何來決定一個屬性可以展開呢?這些不是由屬性視窗來決定,而是取決於屬性自己的類型。在.NET
Time of Update: 2018-12-07
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Runtime.InteropServices;namespace WindowsApplication3{ public partial class
Time of Update: 2018-12-07
//今天 DateTime.Now.Date.ToShortDateString(); //昨天,就是今天的日期減一 DateTime.Now.AddDays(-1).ToShortDateString(); //明天,同理,加一 DateTime.Now.AddDays(1).ToShortDateString(); //本周(要知道本周的第一天就得Crowdsourced Security