1、直接上例子吧:收集系统信息msinfo32时,会有一个弹窗,现在要隐藏该弹窗,首先看没有通过句柄隐藏弹窗的现象

2、收集系统信息导入到一个位置

代码:

Process[] msinfo32process;//创建一个PROCESS类数组
msinfo32process = Process.GetProcesses();//获取当前任务管理器所有运行中程序
foreach (Process proces in msinfo32process)//遍历若存在msinfo21.exe则杀掉
{
if (proces.ProcessName == "msinfo32.exe")
{
proces.Kill();
}
}
//通过调用CMD命令进行系统信息导出为一个文件
Common.CmdExcute("msinfo32 /nfo C:\\tmp\\msinfo32.nfo");

3、下面通过操作句柄进行隐藏收集信息框

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices; namespace test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
Process[] msinfo32process;//创建一个PROCESS类数组
msinfo32process = Process.GetProcesses();//获取当前任务管理器所有运行中程序
foreach (Process proces in msinfo32process)//遍历
{
if (proces.ProcessName == "msinfo32.exe")
{
proces.Kill();
}
}
Thread msinfo32 = new Thread(msinfo);
msinfo32.Start();
}
private static void msinfo()
{
Common.CmdExcute("msinfo32 /nfo C:\\vDesk\\msinfo32.nfo");
} public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32")]
private static extern IntPtr FindWindowEx(IntPtr parent, IntPtr childAfter, string className, string windowName); [DllImport("user32.dll")] static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
private static void whatr()
{
bool stop = true; while (stop)
{
//Sometimes System.Windows.Forms.Application.ExecutablePath works for the caption depending on the system you are running under.
IntPtr hWnd = FindWindow(null, "系统信息"); //put your console window caption here
IntPtr hWnd_en = FindWindow(null, "System Information");
if (hWnd != IntPtr.Zero)
{
//Hide the window
IntPtr child = FindWindowEx(hWnd, IntPtr.Zero, "#32770", "系统信息"); ShowWindow(hWnd, 0); // 0 = SW_HIDE if (child != IntPtr.Zero)
{
ShowWindow(child, 0); // 0 = SW_HIDE
//Notice:设置之后退出线程
stop = false;
}
}
else if (hWnd_en != IntPtr.Zero)
{
IntPtr child_en = FindWindowEx(hWnd_en, IntPtr.Zero, "#32770", "System Information");
ShowWindow(hWnd_en, 0); // 0 = SW_HIDE
if (child_en != IntPtr.Zero)
{
ShowWindow(child_en, 0); // 0 = SW_HIDE
//Notice:设置之后退出线程
stop = false;
}
}
Thread.Sleep(50);
}
}
}
}

这样就可以获得句柄进行隐藏收集系统信息的弹窗

C#操作句柄的更多相关文章

  1. 操作句柄Handle(7)

    可以将Handle理解成访问对象的一个“句柄”.垃圾回收时对象可能被移动(对象地址发生改变),通过Handle访问对象可以对使用者屏蔽垃圾回收细节. Handle涉及到的相关类的继承关系如下图所示. ...

  2. VMware View 要求操作句柄的状态错误

    win10系统安装的VMware-viewclient,版本是

  3. (10)odoo控制器操作

    -----------------更新时间11:17 2016-09-18 星期日    完善讲解17:44 2016-02-17 星期三-----------------* 控制器Controlle ...

  4. (05)odoo数据库和业务操作

    以一个例子开头* To-do 向导   # 配置文件       __openerp_.py:         { 'name': 'To-do Tasks Management Assistant' ...

  5. 使用开源库MagicalRecord操作CoreData

      1. 将 MagicalRecord 文件夹拖入到工程文件中,引入 CoreData.frame 框架 2. 在 .pch 文件中引入头文件 CoreData+MagicalRecord.h 注: ...

  6. Python之路----文件操作

    文件操作 1.能调用方法的一定是对象,比如数值.字符串.列表.元组.字典,甚至文件也是对象,Python中一切皆为对象. str1 = 'hello' str2 = 'world' str3 = ' ...

  7. Windows中的句柄

    (一)句柄 在程序设计中,句柄(handle)是一种特殊的智能指针.当一个应用程序要引用其他系统(如数据库.操作系统)所管理的内存块或对象时,就要使用句柄. 句柄与普通指针的区别在于,指针包含的是引用 ...

  8. Swift3.0服务端开发(四) MySQL数据库的连接与操作

    本篇博客我们来聊聊MySQL数据库的连接与操作.如果你本地没有MySQL数据库的话,需要你先安装MySQL数据库.在Mac OS中使用brew包管理器进行MySQL的安装是及其方便的.安装MySQL的 ...

  9. C 标准库基础 IO 操作总结

    其实输入与输出对于不管什么系统的设计都是异常重要的,比如设计 C 接口函数,首先要设计好输入参数.输出参数和返回值,接下来才能开始设计具体的实现过程.C 语言标准库提供的接口功能很有限,不像 Pyth ...

随机推荐

  1. 关联查询left join中on 和where 的区别

    关于 “A LEFT JOIN B ON 条件表达式” 的一点提醒 ON 条件(“A LEFT JOIN B ON 条件表达式”中的ON)用来决定如何从 B 表中检索数据行. 如果 B 表中没有任何一 ...

  2. Apache Server与多个独立Tomcat集成

    取经自http://www.ramkitech.com/2012/03/virtual-host-apache-httpd-server-tomcat.html 继续干Tomcat和Apache Se ...

  3. 【caffe-windows】 caffe-master 之图片转换成lmdb or leveldb

    前期准备: 文件夹train:此文件夹中按类别分好子文件夹,各子文件夹里存放相应图片 文件夹test:同train,有多少类就有多少个子文件夹 trainlabels.txt : 存的是训练集的标签  ...

  4. EasyDarwin开源流媒体server将select改为epoll的方法

    本文来自EasyDarwin团队Fantasy(fantasy(at)easydarwin.org) 一. EasyDarwin网络模型介绍 EventContext负责监听全部网络读写事件.Even ...

  5. 剑指Offer面试题16(Java版):反转链表

    题目:定义一个函数,输入一个链表的头结点,反转该链表并输出反转后链表的头结点. 解决与链表相关的问题总是有大量的指针操作.而指针操作的代码总是easy出错的. 非常多的面试官喜欢出链表相关的问题,就是 ...

  6. 多线程(C++)临界区Critical Sections

    一 .Critical Sections(功能与Mutex相同,保证某一时刻只有一个线程能够访问共享资源,但是不是内核对象,所以访问速度比Mutex快,但是没有等待超时的功能,所以有可能导致死锁,使用 ...

  7. Presenting view controllers on detached view controllers is discouraged

    本文转载至 http://www.xuebuyuan.com/2117943.html Presenting view controllers on detached view controllers ...

  8. 九度OJ 1115:数字求和 (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2396 解决:1507 题目描述: 给定一个正整数a,以及另外的5个正整数,问题是:这5个整数中,小于a的整数的和是多少? 输入: 输入一行 ...

  9. This means that only a small number of nodes must be read from disk to retrieve an item.

    http://cis.stvincent.edu/html/tutorials/swd/btree/btree.html Introduction A B-tree is a specialized ...

  10. Mac下eclipse的快捷键

    一.Command类 Command+1 快速修复 Command+d 删除当前行 Command+Option+↓ 复制当前行到下一行 Command+Option+↑ 复制当前行到上一行 Comm ...