如何启动系统的控制面板等......

本文提供了一个C#应用程序示例,演示如何通过调用Win32API函数实现不同控制面板项的打开操作。具体展示了如何使用[DllImport]属性指定非托管DLL中的静态入口点,并给出了具体的按钮点击事件处理函数来执行rundll32.exe命令行程序。

SpxImage2_thumb%5B1%5D.jpg

 

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 WindowsApplication1
{
    public partial class Form1 : System.Windows.Forms.Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        [DllImport("kernel32.dll")]
        public static extern bool WinExec(string CmdLine, int uCmdShow);
        public const int SW_RESTORE = 9;
 
        private void button1_Click(object sender, EventArgs e)
        {
            WinExec("rundll32.exe shell32.dll,Control_RunDLL", SW_RESTORE);        
        }
 
 
 
 
        private void button2_Click(object sender, EventArgs e)
        {
            WinExec("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,0", SW_RESTORE);
        }
 
        private void button3_Click(object sender, EventArgs e)
        {
            WinExec("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,1", SW_RESTORE);    
        }
 
        private void button4_Click(object sender, EventArgs e)
        {
            WinExec("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3", SW_RESTORE);
        }
    }
 
}

使用了WIN32API函数

public sealed class DllImportAttribute : System.Attribute
    System.Runtime.InteropServices 的成员
 
摘要:
 指示该属性化方法由非托管动态链接库 (DLL) 作为静态入口点公开。  

转载于:https://www.cnblogs.com/zbqy/archive/2007/02/12/648755.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值