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
  • 魔力宝贝手游怎么刷声望
  • 热门搜索
    什么是工作狂 现在什么项目赚钱 时空扭曲徽章有什么用 孤僻的意思 神出鬼没的意思 旅行包什么牌子好 videos是什么意思 xr是什么意思 祝福的诗句 下嫁是什么意思