当前注册人数107614人 邮箱: 密码: 注册新用户 忘记密码
首页 C/C++/MFC C# ASP.NET VB.NET MATLAB   站内搜索 BBS讨论社区 下载代码说明/积分规则
为什么要注册?

1. 可以直接免费从本站下载代码,防止邮件发送不到您的邮箱,或登录不了国外网站

2. 可以设定关键字,当有您关心的代码收录时,邮件通知您

3. 对这里的代码进行评分和评论

4. 可以和大家一起分享你的源代码,得到更多的建议

monitor, enable, and disable hardware devices from C#

C#系统硬件设备管理(监视,启用,禁用)源代码

2007年12月10日
C# 2.0, Windows, .NET 2.0, VS, Dev
这个程序可以监视当前系统的设备列表,监视那个设备被加载或卸载,并且,还可以启用、禁用系统设备类别中的任何一个设备节点。
 
相关知识

作者之所以写这个程序的原因是因为,需要在程序中重启一个网卡设备。

程序中最主要是调用了SetupAPI.DLL类。

代码使用

using HardwareHelperLib;
HH_Lib hwh = new HH_Lib();
string[] HardwareList = hwh.GetAll();
// ....
// enable a device
hwh.SetDeviceState(devices, true);

源代码原文下载:
Hardware Helper Library for C# How to monitor, enable, and disable hardware devices from C#. There isn't really a lot of background required for you to use the library I've provided. The heart of HardwareHelperLib is the unmanaged SetupAPI.DLL that is part of the platform SDK. Properly declaring and marshalling the API was the tough part and the whole reason I'm posting this code is so you don't have to spend your whole weekend banging your head against the table too. It's ALWAYS helpful to understand how an operating system interacts with the hardware and if you've never looked at the source code for DEVCON or some of the other drivers in the DDK it certainly wouldn't hurt you, (well it might hurt a little if you've strayed from C++ in favor of C# for a few years), but regardless whether you understand the inner-workings of the class or not you still should be able to use it. The example is very simplistic. The only prerequisite assumed is that you are at least somewhat familiar with Windows messages.

源码图片

从本站下载附件及源代码(1个附件,已经成功下载376次)

最值得关注的外文源代码

An Alternate Way of Writing a Multithreaded GUI in C#
How To Get Hardware Information (CPU ID, MainBoard Info, Hard Dik Serial, System Information , ...)
EnvMan 1.2.2 - Windows Environment Variables Manager
Net Spy: Your Network Spy for Share Folder
评论(评论是增加积分的一个有效途径)
字数在300字内
请如实评论
本源代码共评论74次,此处显示最近20次评论! 查看所有评论

zhangjun  2010年03月02日
谢谢
aken088  2010年02月25日
谢谢!好东西!
cookie20  2009年10月28日
看看。。。。。
yydsg2009  2009年07月18日
学习一下
xieyong_198510  2009年07月09日
非常好!谢谢
xuevb888  2009年06月29日
谢谢!好东西!
crcruicai  2009年06月02日
学习 学习
songbo  2009年05月27日
多谢,哈哈
网络蚂蚁  2009年05月23日
C#系统硬件设备管理
wpbao  2009年05月20日
正需要这东西,谢谢
wpbao  2009年05月20日
正需要这东西,
wpbao  2009年05月20日
正需要这东西,
Daniel  2009年05月18日
very good!
vigi2008  2009年04月19日
好东西
vigi2008  2009年04月19日
好东西
wwss  2009年04月18日
OK
hzyb  2009年04月17日
下载学习,我正在研究
cjb9937  2009年04月17日
谢谢
hgy  2009年04月05日
very good !!thank you !!!
tina  2009年03月18日
正需要这方面的资料,感谢啊
字数在300字内
请如实评论
CopyRight (C) codesoso.com 2007-2009 All Rights Reserved   免责声明
京ICP备08011023号