手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

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简单实例
© 手抄报圈