C#调用Windows API简单实例

 时间:2024-10-13 08:16:33

1、usingSystem;usingSystem.Collections.Generic;usingSystem.Compon髫潋啜缅entModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Runtime.InteropServices;namespaceWinAPISample{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}privatevoidbtnClear_Click(objectsender,EventArgse){SHEmptyRecycleBin(Form.ActiveForm.Handle,"", 0x00000000);}privatevoidbtnMax_Click(objectsender,EventArgse){ShowWindow(Form.ActiveForm.Handle, 3);}privatevoidbtnMin_Click(objectsender,EventArgse){ShowWindow(Form.ActiveForm.Handle, 2);}privatevoidbtnNormal_Click(objectsender,EventArgse){ShowWindow(Form.ActiveForm.Handle, 1);}privatevoidbtnBrowser_Click(objectsender,EventArgse){ShellExecute(Form.ActiveForm.Handle,"Open",this.tbURL.Text,"","", 1);} ///<summary>///清空回收站///</summary>[DllImport("shell32.dll", EntryPoint ="SHEmptyRecycleBin", CharSet =CharSet.Auto)]publicstaticexternlongSHEmptyRecycleBin(IntPtrhwnd,stringpszRootPath,longdwFlags);///<summary>///打开浏览器///</summary>[DllImport("shell32.dll", EntryPoint ="ShellExecute", CharSet =CharSet.Auto)]publicstaticexternintShellExecute(IntPtrhwnd,stringlpOperation,stringlpFile,stringlpParameters,stringlpDirectory,intnShowCmd);///<summary>///最大化窗口,最小窗口,正常大小窗口///</summary>[DllImport("user32.dll", EntryPoint ="ShowWindow", CharSet =CharSet.Auto)]publicstaticexternintShowWindow(IntPtrhwnd,intnCmdShow);}}

C#调用Windows API简单实例
  • 用七巧板怎样拼一把插地上的大刀?
  • 怎样画南瓜灯的简笔画教程
  • 手工制作收纳桶
  • 怎么样玩七巧板拼数字1
  • 魔力宝贝手游怎么刷声望
  • 热门搜索
    江西 旅游 金佛山旅游 萍乡旅游 亳州旅游景点大全 国外旅游价格 去香港的旅游团 青岛旅游报价 栾川旅游景点 广州旅游路线 赤峰旅游攻略