登录
首页 » C# » C# 二维码 例子源码

C# 二维码 例子源码

于 2015-05-05 发布
0 130
下载积分: 1 下载次数: 0

代码说明:

二维码

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • C# 制作系统服务 实例源码下载
    附件中有详细的安装使用文档,大概步骤如下:1.新建Windows项目,选择"Windows服务"类型的工程。2.生成的Program.cs文件中,定义了服务启动的Main函数。 代码 namespace WindowsService1{    static class Program    {        ///         /// 应用程序的主入口点。        ///         static void Main()        {            ServiceBase[] ServicesToRun;            ServicesToRun = new ServiceBase[]             {                 new Service1()             };            ServiceBase.Run(ServicesToRun);        }    }}  3.在新建的工程中,点击Service1.cs文件,切换到代码视图,生成的代码继承于ServiceBase基类,并重载了OnStart和OnStop方法。我在这个文件中进行了一些简单的操作,就是在服务开始的时候,定义一个定时器,然后每隔1秒钟,向文件中写入当前时间。 代码 namespace WindowsService1{    public partial class Service1 : ServiceBase    {        Timer timer;        public Service1()        {            InitializeComponent();        }        protected override void OnStart(string[] args)        {            timer = new Timer(1000);            timer.Elapsed  = new ElapsedEventHandler(timer_Elapsed);            timer.Start();        }        protected override void OnStop()        {            timer.Stop();            timer.Dispose();        }        void timer_Elapsed(object sender, ElapsedEventArgs e)        {            string filePath = AppDomain.CurrentDomain.BaseDirectory   "test.txt";            StreamWriter sw = null;            if (!File.Exists(filePath))            {                sw = File.CreateText(filePath);            }            else            {                sw = File.AppendText(filePath);            }            sw.Write("访问时间:" DateTime.Now.ToString() Environment.NewLine);            sw.Close();        }    }}4.向工程中添加一个安装程序类。 4.在新添加的安装程序类中,设定服务的名称,启动方式,账号名和密码等信息。 代码 namespace WindowsService1{    partial class Installer1    {        ///         /// 必需的设计器变量。        ///         private System.ComponentModel.IContainer components = null;        private System.ServiceProcess.ServiceProcessInstaller spInstaller;        private System.ServiceProcess.ServiceInstaller sInstaller;        ///          /// 清理所有正在使用的资源。        ///         /// 如果应释放托管资源,为 true;否则为 false。        protected override void Dispose(bool disposing)        {            if (disposing && (components != null))            {                components.Dispose();            }            base.Dispose(disposing);        }        #region 组件设计器生成的代码        ///         /// 设计器支持所需的方法 - 不要        /// 使用代码编辑器修改此方法的内容。        ///         private void InitializeComponent()        {            components = new System.ComponentModel.Container();            // 创建ServiceProcessInstaller对象和ServiceInstaller对象            this.spInstaller =new System.ServiceProcess.ServiceProcessInstaller();            this.sInstaller = new System.ServiceProcess.ServiceInstaller();            // 设定ServiceProcessInstaller对象的帐号、用户名和密码等信息            this.spInstaller.Account = System.ServiceProcess.ServiceAccount.LocalSystem;            this.spInstaller.Password = null;            this.spInstaller.Username = null;            // 设定服务的名称            this.sInstaller.ServiceName = "WindowsService1";            //设定服务启动的方式            this.sInstaller.StartType = System.ServiceProcess.ServiceStartMode.Automatic;            this.Installers.AddRange(new System.Configuration.Install.Installer[] {            this.spInstaller,this.sInstaller});        }        #endregion    }}5.生成工程,在bin目录下会生成exe文件。如果直接运行exe文件的话,是不能执行的,需要使用安装Windows服务用到一个名为InstallUtil.exe的命令行工具,打开命令行工具,转到InstallUtil.exe的目录下,我安装的是VS 2010,对应的目录为:C:WindowsMicrosoft.NETFrameworkv4.0.30319InstallUtil.exe,然后执行InstallUtil.exe 待执行的exe文件的目录,如:InstallUtil.exe F:MyProjectWindowsService1WindowsService1inDebugWindowsService1.exe。执行成功后,会在Windows的服务中,出现了刚刚添加的服务的名称。 6.启动该服务,这时打开binDebug文件夹,发现已经生成了一个test.txt的文件,里面记录了时间。这说明服务已经正式开始执行。7.停止服务的操作也和简单,打开命令行工具,转到C:WindowsMicrosoft.NETFrameworkv4.0.30319目录,然后执行InstallUtil.exe - u F:MyProjectWindowsService1WindowsService1inDebugWindowsService1.exe命令就可以了。
    2015-04-21下载
    积分:1
  • html5 绘图以及 动画实例源码
    html5 绘图以及 动画实例源码
    2014-06-12下载
    积分:1
  • linux命令.doc
    【实例简介】linux基础命令
    2021-09-25 00:30:58下载
    积分:1
  • TCP客户端demo
    TCP服务端接收客户端连接 TCP服务端发送和接收消息
    2015-05-12下载
    积分:1
  • PSO粒子群算法(亲测可以运行)
    PSO粒子群算法,加上罚函数,解决有边界的优化模型的方程问题,C 语言,仅有一个cpp,有注释,方便理解。亲测可以运行,效果不错,跑出来结果拿到一个小公司的数据挖掘实习生岗位!
    2019-07-16下载
    积分:1
  • 串口工具开发实例
    串口工具开发实例
    2021-01-06 14:48:54下载
    积分:1
  • 于八叉树分解的三维重建
    基于八叉树分解的三维重建,原始数据需要有法向量.
    2019-06-26下载
    积分:1
  • 简单三层+EF
    简单三层+EF
    2014-04-14下载
    积分:1
  • 用友二次开发(VB)单据开发的实例,包含参照,验证数据等 用友二次开发单据实例.rar
    用友二次开发(VB)单据开发的实例,包含参照,验证数据等  用友二次开发单据实例.rar
    2014-02-25下载
    积分:1
  • crm客户关系管理系统源码(winform)
    crm客户关系管理系统源码本系统使用了,第三方组件:DevExpress。 在项目的lib包中。系统中树形菜单就是使用DevExpress.XtraNavBar控件。系统结构:资料管理  区域信息管理  客户信息管理  竞争对手管理我方信息管理  基本信息管理  员工信息管理  货物信息管理  重大历史进程管理统计分析  客户级别分析  客户来源分析用户管理  用户管理  更改密码  设置权限系统维护  数据库备份  数据库还原  数据库清理帮助  启用记事本  启用Word  启用Excel  水平平铺  垂直平铺  关于我们  重新登陆  退出
    2017-03-23下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载