-
C# 启动外部计算器计算数据
C# 启动外部计算器计算数据,private void button1_Click(object sender, EventArgs e)
{//启动计算器计算数据(从当前程序向其他程序发送键击数据)
ProcessStartInfo MyStartInfo = new ProcessStartInfo();
MyStartInfo.FileName = "Calc.exe";
Process MyProcess = new Process();
MyProcess.StartInfo = MyStartInfo;
MyProcess.Start();
System.Threading.Thread.Sleep(100);
IntPtr MyHandle = FindWindow("SciCalc", "计算器");
if (MyHandle == IntPtr.Zero)
{
MessageBox.Show("计算器程序没有运行","信息提示",MessageBoxButtons.OK);
return;
}
SetForegroundWindow(MyHandle);
SendKeys.SendWait("88");
SendKeys.SendWait("*");
SendKeys.SendWait("8");
SendKeys.SendWait("=");
}
- 2023-04-17 08:10:03下载
- 积分:1
-
C# 创建一个泛型接口
C# 创建一个泛型接口的例子,创建一个泛型接口的代码和方法如下:
public interface IGenericInterface {
T CreateInstance(); //接口中调用CreateInstance方法
}
//实现上面泛型接口的泛型类
//派生约束where T : TI(T要继承自TI)
//构造函数约束where T : new()(T可以实例化)
public class Factory : IGenericInterface where T : TI, new()
{
public TI CreateInstance()//创建一个公共方法CreateInstance
{
return new T();
}
}
class Program
{
static void Main(string[] args)
{
//实例化接口
IGenericInterface factory =
Factory();
//输出指定泛型的类型
Console.WriteLine(factory.CreateInstance().GetType().ToString());
Console.ReadLine();
}
}
- 2022-03-11 00:59:39下载
- 积分:1
-
C# FTP客户端模块 上传下载文件显示进度
C# FTP客户端模块 上传下载文件显示进度,本示例可通过HTTP、FTP下载文件,可通过FTP上传文件,请设定好服务器IP地址再测试,进度条在窗口的最上方。
percent = (float)totalDownloadedByte / (float)totalBytes * 100;
label1.Text = "当前补丁下载进度" + percent.ToString() + "%";
Application.DoEvents(); //必须加注这句代码,否则label1将因为循环执行太快而来不及显示信息
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);//用户,密码
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;//向服务器发出下载请求命令
reqFTP.ContentLength = finfo.Length;//为request指定上传文件的大小
- 2022-03-23 13:46:25下载
- 积分:1
-
C# 为textBox文本框控件添加颜色光环
C# 为文本框控件添加颜色光环,是不是把textBox装扮得很漂亮呢?外发光的文本框,有点沙沙的感觉,核心代码有兴趣可参考:
private void Window_Loaded(object sender, RoutedEventArgs e)
{//为文本框控件添加颜色光环
var MyOuterGlowBitmapEffect = new System.Windows.Media.Effects.OuterGlowBitmapEffect();
MyOuterGlowBitmapEffect.GlowSize = 30;
Color MyColor = new Color();
MyColor.ScA = 1;
MyColor.ScB = 1;
MyColor.ScG = 0;
MyColor.ScR = 0;
MyOuterGlowBitmapEffect.GlowColor = MyColor;
MyOuterGlowBitmapEffect.Noise = 1;
MyOuterGlowBitmapEffect.Opacity =0.8;
this.textBox1.BitmapEffect = MyOuterGlowBitmapEffect;
}
完整的C#可编译源代码,请下载本源码。
- 2022-07-09 20:47:57下载
- 积分:1
-
STM32F4的三相SPWM逆变器源码
STM32F4的三相SPWM逆变器源码
//该源码是基于STM32F4的三相SPWM逆变器的C程序
#include "stm32f4_discovery.h"
#include "timer.h"
#include "FONT.h"
#include "LCD12864.h"
#include "outputdata.h"
#include
#include "arm_math.h"
- 2022-03-30 05:56:10下载
- 积分:1
-
C# 在LINQ to XML中将XML文件转换为CSV文件的例子源码
C# 在LINQ to XML中将XML文件转换为CSV文件的例子源码,转换的结果请参考如图所示:
private void button1_Click(object sender, EventArgs e)
{//在LINQ to XML中将XML文件转换为CSV文件
TextReader MyReader = new StringReader(this.textBox1.Text);
XElement MyCustomers= XElement.Load(MyReader);
MyReader.Close();
string MyInfo =
(from MyElement in MyCustomers.Elements("客户")
select
String.Format("{0},{1},{2},{3},{4}",
(string)MyElement.Element("客户ID"),
(string)MyElement.Element("公司名称"),
(string)MyElement.Element("城市") + (string)MyElement.Element("地址"),
(string)MyElement.Element("联系人姓名"),
Environment.NewLine
)
).Take(10).Aggregate(new StringBuilder(),(MySubString, MyString)=>MySubString.Append(MyString),MySubString=>MySubString.ToString());
MessageBox.Show(MyInfo, "信息提示");
}
- 2023-04-08 15:00:04下载
- 积分:1
-
Visual C# 查询指定时间间隔的数据
Visual C# 查询指定时间间隔的数据,根据学生出生年月查询学生年龄,代码如下:
private DataTable GetMessage()
{
string P_Str_ConnectionStr = string.Format(//创建数据库连接字符串
@"server=WIN-GI7E47AND9RLS;database=db_TomeTwo;uid=sa;pwd=");
string P_Str_SqlStr = string.Format(//创建SQL查询字符串
"select 学生姓名,出生年月 from tb_Student");
SqlDataAdapter P_SqlDataAdapter = new SqlDataAdapter(//创建数据适配器
P_Str_SqlStr, P_Str_ConnectionStr);
DataTable P_dt = new DataTable();//创建数据表
P_SqlDataAdapter.Fill(P_dt);//填充数据表
return P_dt;//返回数据表
}
- 2022-03-02 08:45:17下载
- 积分:1
-
halcon+c# 机器视觉检测水位测量
halcon+c#配合使用,很好的例子,代码可以直接运行,很适合初学者学习使用,学习
- 2023-03-29 09:50:03下载
- 积分:1
-
C# 使用Graphics方法生成字符串的验证码图片
C# Graphics方法生成字符串的验证码图片,在C#的程序中生成一个随机生成器 ,然后随机生成字符,然后使用Graphics方法画图片的背景噪音线 定义颜色和字体,画图片的前景噪音点,画图片的边框线等。这是个比较简单的生成验证码的方法,验证码的使用率偏高,因此作为一个C#生成验证码的初级例子,本源码有必要学习研究。
- 2022-02-26 05:51:46下载
- 积分:1
-
7Zip
This file is part of SevenZipSharp. SevenZipSharp is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SevenZipSharp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SevenZipSharp. If not, see .
- 2022-07-20 00:09:31下载
- 积分:1