Visual C 設計多功能關機程式 2

2022-02-12 05:17:28 字數 1032 閱讀 4672

二. 設計獲取系統資訊的windows窗體

1. 介面的設計

向工程中增加乙個windows窗體並向窗體中新增如下控制項:

2. 在窗體類中引用api函式

using system.runtime.interopservices ;

using system.text ;

[ dllimport("kernel32") ]

public static extern void getwindowsdirectory(stringbuilder windir,int count) ;

[ dllimport("kernel32") ]

public static extern void getsystemdirectory(stringbuilder sysdir,int count) ;

[ dllimport("kernel32") ]

public static extern void getsysteminfo(ref cpu_info cpuinfo) ;

[ dllimport("kernel32") ]

public static extern void globalmemorystatus(ref memory_info meminfo) ;

[ dllimport("kernel32") ]

public static extern void getsystemtime(ref systemtime_info stinfo) ;

5. 編寫窗體類的方法

private void button1_click(object sender, system.eventargs e )

三. 結束語。

上面介紹了visual c#開發多功能關機程式的整個過程,該程式有一定的實用價值。通過本文的學習,我相信稍有api使用基礎的開發者可以馬上觸類旁通,很快掌握visual c#中對api的操作。上面給出的例項僅僅是乙個簡單的程式,不過有興趣的讀者可以進一步完善其功能,做出更完美的系統應用程式。

設計乙個多功能的MyTime類

題目內容 定義乙個帶過載建構函式的日期類date,資料成員有年 月 日 成員函式包括 乙個帶引數的建構函式date int,int,int 乙個不帶引數的建構函式 設定日期為1900年1月1日 乙個按 年 月 日 格式顯示日期的函式,乙個對資料成員賦值的函式void init int,int,int...

基於多功能DAQ卡的虛擬數字示波器的設計

2006 04 27 22 13 20 基於多功能daq卡的虛擬數字示波器的設計 inject script filtered 引言 虛擬儀器中有一類是基於多功能daq卡的虛擬儀器,結構簡單,開發成本低,目前已經得到了廣泛的應用。本文以乙個基於多功能daq卡的虛擬數字示波器為例,來說明如何開發基於多...

計算機組成原理 多功能ALU設計實驗

一 實驗目的與要求 實驗目的 1 學習多功能alu的工作原理,掌握運算器的設計方法 2 掌握運用verilog hdl 進行行為描述與建模的技巧和方法 實驗要求 本實驗要求設計乙個具有8種運算功能的32位alu,並能夠產生運算結果的標誌 結果為零標誌zf zero flag 溢位標誌of overf...