公共配置对话框

通过API实现C#对硬件的控制(一) 最近在做项目的过程中,涉及到对硬件启用及禁用的功能(在指定时间段内才能启用硬件)。因为C#自身对硬件的操作基本为零,为此,搜索了一下MSDN中与设备相关的API函数。还果然就有。下面一一列举出各函数的原型及相关的说明文档。并将其转为C#代码实现。函数一: RegisterDeviceNotification功能:注册设备或者设备类型,在指定的窗口返回相关的信息原型:HDEVNO 阅读详情

using System;
using System.Drawing;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Configuration;
using System.Windows.Forms;
using System.Data;

namespace DataLibrary
{
 /// <summary>
 /// 配置管理
 /// </summary>
 public class DisposalConduct : System.Windows.Forms.Form
 {
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  private System.Windows.Forms.Button closeButton;
  private System.ComponentModel.Container components = null;
  private System.Windows.Forms.Label label1;
  private System.Windows.Forms.Label label2;
  private System.Windows.Forms.Label label3;
  private System.Windows.Forms.Label label4;
  private System.Windows.Forms.TextBox textBox1;
  private System.Windows.Forms.TextBox textBox2;
  private System.Windows.Forms.TextBox textBox3;
  private System.Windows.Forms.TextBox textBox4;
  private System.Windows.Forms.Button button1;
  private System.Windows.Forms.TextBox textBox5;
  private System.Windows.Forms.Label label5;
  private DisposalConductService DisposalConductService1;

  /// <summary>
  /// 配置管理
  /// </summary>
  public DisposalConduct()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();

   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
   string SystemDir=System.Environment.SystemDirectory;
   DisposalConductService1= new DisposalConductService(SystemDir+"//CBERP_Dis.DLL") ;
   this.textBox1.Text=DisposalConductService1.GetValue("ServerName","(local)").ToString();
   this.textBox2.Text=DisposalConductService1.GetValue("SqlAccount","sa").ToString();
   this.textBox3.Text=DisposalConductService1.GetValue("PassWord","jiayu520").ToString();
   this.textBox5.Text=this.textBox3.Text;
   this.textBox4.Text=DisposalConductService1.GetValue("DataBase","CBERP").ToString();
  }

  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region 设计界面生成代码
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
   this.closeButton = new System.Windows.Forms.Button();
   this.label1 = new System.Windows.Forms.Label();
   this.label2 = new System.Windows.Forms.Label();
   this.label3 = new System.Windows.Forms.Label();
   this.label4 = new System.Windows.Forms.Label();
   this.textBox1 = new System.Windows.Forms.TextBox();
   this.textBox2 = new System.Windows.Forms.TextBox();
   this.textBox3 = new System.Windows.Forms.TextBox();
   this.textBox4 = new System.Windows.Forms.TextBox();
   this.button1 = new System.Windows.Forms.Button();
   this.textBox5 = new System.Windows.Forms.TextBox();
   this.label5 = new System.Windows.Forms.Label();
   this.SuspendLayout();
   //
   // closeButton
   //
   this.closeButton.Location = new System.Drawing.Point(277, 92);
   this.closeButton.Name = "closeButton";
   this.closeButton.Size = new System.Drawing.Size(66, 25);
   this.closeButton.TabIndex = 7;
   this.closeButton.Text = "关闭";
   this.closeButton.Click += new System.EventHandler(this.closeButton_Click);
   //
   // label1
   //
   this.label1.AutoSize = true;
   this.label1.Location = new System.Drawing.Point(12, 16);
   this.label1.Name = "label1";
   this.label1.Size = new System.Drawing.Size(66, 17);
   this.label1.TabIndex = 4;
   this.label1.Text = "服务器名:";
   //
   // label2
   //
   this.label2.AutoSize = true;
   this.label2.Location = new System.Drawing.Point(18, 43);
   this.label2.Name = "label2";
   this.label2.Size = new System.Drawing.Size(60, 17);
   this.label2.TabIndex = 4;
   this.label2.Text = "SQL帐号:";
   //
   // label3
   //
   this.label3.AutoSize = true;
   this.label3.Location = new System.Drawing.Point(18, 70);
   this.label3.Name = "label3";
   this.label3.Size = new System.Drawing.Size(60, 17);
   this.label3.TabIndex = 4;
   this.label3.Text = "SQL密码:";
   //
   // label4
   //
   this.label4.AutoSize = true;
   this.label4.Location = new System.Drawing.Point(12, 124);
   this.label4.Name = "label4";
   this.label4.Size = new System.Drawing.Size(66, 17);
   this.label4.TabIndex = 4;
   this.label4.Text = "数据库名:";
   //
   // textBox1
   //
   this.textBox1.Location = new System.Drawing.Point(102, 14);
   this.textBox1.Name = "textBox1";
   this.textBox1.Size = new System.Drawing.Size(162, 21);
   this.textBox1.TabIndex = 1;
   this.textBox1.Text = "";
   //
   // textBox2
   //
   this.textBox2.Location = new System.Drawing.Point(102, 41);
   this.textBox2.Name = "textBox2";
   this.textBox2.Size = new System.Drawing.Size(162, 21);
   this.textBox2.TabIndex = 2;
   this.textBox2.Text = "";
   //
   // textBox3
   //
   this.textBox3.Location = new System.Drawing.Point(102, 68);
   this.textBox3.Name = "textBox3";
   this.textBox3.PasswordChar = '*';
   this.textBox3.Size = new System.Drawing.Size(162, 21);
   this.textBox3.TabIndex = 3;
   this.textBox3.Text = "";
   //
   // textBox4
   //
   this.textBox4.Location = new System.Drawing.Point(102, 122);
   this.textBox4.Name = "textBox4";
   this.textBox4.Size = new System.Drawing.Size(162, 21);
   this.textBox4.TabIndex = 5;
   this.textBox4.Text = "";
   //
   // button1
   //
   this.button1.Location = new System.Drawing.Point(277, 46);
   this.button1.Name = "button1";
   this.button1.Size = new System.Drawing.Size(66, 26);
   this.button1.TabIndex = 6;
   this.button1.Text = "保存";
   this.button1.Click += new System.EventHandler(this.button1_Click);
   //
   // textBox5
   //
   this.textBox5.Location = new System.Drawing.Point(102, 95);
   this.textBox5.Name = "textBox5";
   this.textBox5.PasswordChar = '*';
   this.textBox5.Size = new System.Drawing.Size(162, 21);
   this.textBox5.TabIndex = 4;
   this.textBox5.Text = "";
   //
   // label5
   //
   this.label5.AutoSize = true;
   this.label5.Location = new System.Drawing.Point(12, 97);
   this.label5.Name = "label5";
   this.label5.Size = new System.Drawing.Size(66, 17);
   this.label5.TabIndex = 4;
   this.label5.Text = "确认密码:";
   //
   // DisposalConduct
   //
   this.AcceptButton = this.button1;
   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
   this.ClientSize = new System.Drawing.Size(355, 157);
   this.Controls.Add(this.button1);
   this.Controls.Add(this.textBox1);
   this.Controls.Add(this.textBox2);
   this.Controls.Add(this.textBox3);
   this.Controls.Add(this.textBox4);
   this.Controls.Add(this.textBox5);
   this.Controls.Add(this.label1);
   this.Controls.Add(this.closeButton);
   this.Controls.Add(this.label2);
   this.Controls.Add(this.label3);
   this.Controls.Add(this.label4);
   this.Controls.Add(this.label5);
   this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
   this.MaximizeBox = false;
   this.MinimizeBox = false;
   this.Name = "DisposalConduct";
   this.ShowInTaskbar = false;
   this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
   this.Text = "运行环境设置";
   this.ResumeLayout(false);

  }
  #endregion

  private void closeButton_Click(object sender, System.EventArgs e)
  {
   this.Close();
   this.Dispose();
  }

  private void button1_Click(object sender, System.EventArgs e)
  {
   if(this.textBox3.Text!=this.textBox5.Text)
    MessageBox.Show("密码和确认密码不同!");
   else
   {
    this.DisposalConductService1.UpdateValue("ServerName",this.textBox1.Text);
    this.DisposalConductService1.UpdateValue("SqlAccount",this.textBox2.Text);
    this.DisposalConductService1.UpdateValue("PassWord",this.textBox3.Text);
    this.DisposalConductService1.UpdateValue("DataBase",this.textBox4.Text);
    MessageBox.Show("设置保存成功!");
    DataLibrary.SqlConnect sqlconn = new SqlConnect();
    sqlconn.ConnString= "server="+DisposalConductService1.GetValue("ServerName","(local)")
     +";user id="+DisposalConductService1.GetValue("SqlAccount","sa")
     +";password="+DisposalConductService1.GetValue("PassWord","jiayu520")
     +";Database="+DisposalConductService1.GetValue("Database","CBERP");
   }
  }
 }
}

用C#程序实现键盘和鼠标的模拟 using System;using System.Runtime.InteropServices;using System.Text;namespace ConsoleApplication8{class Class1{[STAThread]static void Main(string[] args){// Display current status of keys.Console.Wr 阅读详情

相关推荐

通过API实现C#对硬件的控制(二)

通过上一篇“通过API实现C#对硬件的控制(一)” 我们掌握了我们所需要的相关API知识点。为此,我们现在来构建我们自己的外部调用类:Externs。由于有上一篇的详细说明,该处不再一一说明相关的函数知识点。下面是该类的代码:using System;using System.Collections.Generic;using System.Text;using System.Runt

cocosoft随记 4431

C#按钮移动

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; namespace 按钮移动 {...

qq_42889230的博客 1941

如何通过C#实现单据号码的自动增加。

下面,我给出一段代码。里面具有完整的注释。 using System; namespace BaseLayer{ ///  /// 单据编号,产生自增编号,如:入参为"DJ000002",将返回"DJ000003" ///  public class SheetNumber {  ///   /// 单据编号,产生自增编号,如:入参为"DJ000002",将返回"DJ000003"  ///   

cocosoft随记 4241

System.Drawing之point

1.Point 结构---结合上一章鼠标键盘控制 代表一个在二维平面中定义一个点的有x坐标和y坐标的有序整数对 命名空间:   System.Drawing 程序集:  System.Drawing(System.Drawing.dll 中) 实例: class Action { public Point CODE_INPUTE

basycai的博客 8183

JavaSpringBoot + VUE 相关开发环境配置合集

1.Java环境-JDK安装 参照:Java基础1-环境篇:JDK安装与环境变量配置 Java基础1-环境篇:JDK安装与环境变量配置_第一段代码的博客-优快云博客_jdk 2.Web服务器-Tomcat安装 原创Java服务器Tomcat安装和配置 3.Maven(后面为了项目兼容性,使用了3.0.5版本) 原创Maven安装和配置(Maven3.0.5) 4.nginx 原创nginx轻量级Web服务器安装和配置 5 数据库mysql 原创数据库Mysql安装和配置 ...

第一段代码的博客 3163

自然二进制数与格雷码的相互转换

自然二进制数与格雷码两者优势: 自然二进制数的编码方式简单明了,容易理解,在加减运算中能够直接进行,同时十分方便进行一些位运算操作(如移位、取反等)。 格雷码计数时只有一位变化,可有效减少计数器状态的冗余转换,同时在传输数据时能够减小传输错误的概率,此外带权重编码处理更加方便。 在一定程度上自然二进制数与格雷码优缺点基本相反,综上所述,自然二进制数和格雷码各有优劣之处,需要根据具体应用场景选择合适的编码方式。简单来说,在计数器和编码器中,倾向于使用格雷码;而在进行加减运算时,则倾向于使用自然二进制数。

Loudrs的博客 7493

Web MessageBox

  public class MessageBox {    private  MessageBox()  {     }  ///   /// 显示消息提示对话框  ///   /// 当前页面指针,一般为this  /// 提示信息  public static void  Show(System.Web.UI.Page page,string msg)  {   page.Registe

『 Ghost 』 1071

成本150元的高性能RDP协议瘦客户机

云终端市场是一个跨度很大的市场。既有数千元的品牌的瘦客户机,也有几百元的瘦客户机,还有200-300元的支持RDP协议的多用户云终端。但是200-300元的多用户终端,在显示性能上不尽人意,一般用于地产中介门店,工厂产线的电子看板等场合。有没有性能更好,价格更低的方案呢? 答案是有。 这个方案就是 二手的x86 瘦客户机 + DoraOS瘦客户机系统免费版(仅支持RDP)。 首先我们看硬件,在某宝搜索 升腾C92 ,找到最低配置的( CPU:J1800,内存:2G,硬盘:8G)。价格都在150以内。

云飞扬的桌面云 7411

c# opcda数据采集mqtt数据转发,

http://note.youdao.com/noteshare?id=238dfcb12fe853fdc3287e0e75c0c4a5

qq_41666269的博客 2258

cadence Virtuoso ADE原理图库中的VCVS(压控电压源)使用

Symbol: vcvs (Voltage Controlled Voltage Source) Vop−Von=egain⋅(Vip−Vin)V_{op}-V_{on}=egain\cdot(V_{ip}-V_{in})Vop​−Von​=egain⋅(Vip​−Vin​) 所以可以得出 ⟹Vop=egain⋅(Vip−Vin)+Von\Longrightarrow V_{op}=egain\cdot(V_{ip}-V_{in})+V_{on}⟹Vop​=egain⋅(Vip​−Vin​)+Von​ 使

大学生视野 2万+

陀螺仪与加速度计的姿态融合——互补滤波

本篇文章我们来讲讲如何将陀螺仪和加速度计的数据结合起来,获取更准确的姿态数据,使用的是互补滤波的方法。

小白白学电子 2万+

基于VisualStudio11开发Windows8的Metro sample讲解(1)MessageBox

我们所了解的MessageBox。 函数原型:essageBox.Show(Text,Title,MessageBoxButtons,MessageBoxIcon ,MessageBoxDefaultButtons)   参数说明:   (1)Text:必选项,消息框的正文。   (2)Title:可选项,消息框的标题。   (3)MessageBoxButtons:可选项,消息框的按钮设置,默认

尹成的技术博客 7260

开源libmodbus编译为32位和64位动态库

libmodbus 是支持Linux,Mac OS X,window 的一个开源库,支持modbus TCP和RTU 两种模式。

lemontree1945的博客 1923

python函数

Python 里面,函数成为一段代码的表示,它是一段具有特定功能的、可以重用的语句组,它也是一种功能的抽象,一般函数都表达特定功能。 函数的定义: def <函数名>(<参数>) : <函数体> return <返回值> 在函数定义的时候首先使用def保留字声明,后面是定义的函数的名字及参数,下面是函数体,用来完成需要这个函数完成的功能,最后是返回值,它是指当前函数运行之后的要返回的结果,使用return保留字声明,值得注意的是,在一个函数的定义中,返回值是

weixin_46354181的博客 332

86、高斯过程:学习、应用与自动相关性确定

本文介绍了高斯过程回归的基本原理及其在实际应用中的关键技术,重点探讨了通过最大化对数似然函数来学习模型超参数的方法,并详细阐述了自动相关性确定(ARD)技术如何用于评估输入变量的重要性。文章涵盖了从协方差函数定义、梯度计算到优化算法的应用流程,并通过流程图和表格形式总结了核心步骤与公式。此外,还讨论了贝叶斯处理方式及异方差问题的建模策略,展示了高斯过程在复杂数据建模中的灵活性与强大能力。

android的专栏 114

ML307R OpenCPU TCP使用

实现现象 平台下发数据,板子在收到数据之后,马上再发送到平台,通过串口助手可以看到已经接收到数据。ML307R TCP 是使用LWIP的标准的socket通信,具体TCP流程可以自行百度。实验目的:实现把接收的数据再发送到服务端。因为是4G,所以必须用外网的。

面朝大海春暖花开 2232

C语言基础进阶之 MessageBox()用法简介

http://blog.sina.com.cn/s/blog_7414b2930100vfwl.html  MessageBox()   功能显示一个消息对话框。   语法MessageBox(text,title{,icon{,button{,default}}})   参数title:string类型,指定消息对话框的标题text:指定消息对话框中显示的消息

cswhit的博客 1万+

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

GetFileOpenName()

GetFileOpenName() 功能显示打开文件对话框,让用户选择要打开的文件。 语法:GetFileOpenName(title,pathname,filename{,extension{,filter}}) 参数title:string类型,指定对话框的标题pathname:string类型变量,用于保存该对话框返回的文件路径及文件名 file...

weixin_33714884的博客 1603

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

4、python 函数

函数的概念在各种语言中都有提及且应用广泛。 简单来说,函数,就是一组可以实现某个或者多种功能的代码,通过函数名组织起来,可以通过调用函数名来重复使用。 python中函数有内建函数和用户自定义的函数,函数的定义: 一、函数的参数 函数在创建的时候可以设置不同的参数,调用的时候也需要根据参数的类型传入参数,分为形参和实参: 形参: 形参变量只有在被调用时才分配内存单元,在调用结束时,...

tianzemeizhi的博客 385

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

java replace 忽略大小写_ASP中让Replace替换不区分大小写的方法

我们先来看一看 Replace 的详细参数描述返回字符串,其中指定数目的某子字符串被替换为另一个子字符串。语法Replace(expression, find, replacewith[, compare[, count[, start]]])Replace 函数的语法有以下参数:参数 描述expression 必选项。 字符串表达式 包含要替代的子字符串。find 必选项。被搜索的子字符串。re...

weixin_42514616的博客 620

GetFileOpenName()、GetFilesavename

GetFileOpenName() 功能显示打开文件对话框,让用户选择要打开的文件。语法:GetFileOpenName(title,pathname,filename{,extension{,filter}})、GetFilesavename(title,pathname,filename{,extension{,filter}}) 参数title:string类型,指定对话框的标题pat...

weixin_30414635的博客 354

python中函数包括参数函数吗_Python中的函数---函数的定义和参数

本文是廖雪峰教程的笔记。函数的定义定义函数时,需要确定函数名和参数个数 def fun(x1,x2,x3):;如果有必要,可以先对参数的数据类型做检查;函数体内部可以用return随时返回函数结果;函数执行完毕也没有return语句时,自动return None。函数可以同时返回多个值,但其实就是一个tuple。函数的参数Python的函数具有非常灵活的参数形态,既可以实现简单的调用,又可以传入非...

weixin_39714849的博客 556

C++调用大数组出现栈溢出的问题解决方法,堆和栈的完全解析

总结:除非特别要求,不应开一个大于>100的数组,是很不明智的! 主要有两个办法: 一 改为堆变量: int* pa = malloc(sizeof(int)*1000*1000); 然后可以将pa当数组用。(数组和指针在C里基本等同) 当然,不用了记得free pa。 二 修改系统限制 这个栈变量= 1000*1000*4 = 4M。(约等于) 如果这个函数不频繁调用,也不递

FeelTouch Labs 2万+

通过API实现C#对硬件的控制(三)

有了前两篇后,我们在这里面建立一个测试项目。简单的设备管理器:)界面如下图:源码项目下载地址:http://download.csdn.net/source/352079。

cocosoft随记 4025

使用回车代替Tab键的功能代码

  ///   /// 键盘处理事件  /// 主要实现的功能是重写键盘命令事件。使用户在使用的时候,如果当前焦点不是在Button(按钮)上的话,就可以用Enter代替Tab键了。  ///   ///   ///   ///   protected override bool ProcessCmdKey(ref Message msg,Keys keyData)  {   if ( (!(Ac

cocosoft随记 3433

通过全局鼠标键盘事件实现应用程序的自动锁定

        我们在进行信息系统开发的时候,有时为了系统数据保密性、安全性得到提升。需要考虑到如果在用户长时间内没有对鼠标及键盘进行操作时,让应用程序自动锁定。并将当前用户所操作的界面隐藏。那么,为了实现该功能,我们需要对整个计算机内部的鼠标及键盘的操作进行记录。如果长时间内记录没有发生变化,则可以对系统进行锁定。一、关键类的实现        在.NET现有的类库中,并没有实现对全局(

cocosoft随记 3025
上一篇: C#对底层数据操作的通用类
下一篇: 公共配置底层代码
甴曱
博客等级 码龄24年 184粉丝 29原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值