资源简介
C#调用考勤机API读取记录,对没过串口编程的朋友有帮助
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace app3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender EventArgs e)
{
const long JS_OK=1;
const long INVALID_HANDLE_VALUE=-1;
const long JS_COMM_ERR=-3;
const long JS_NO_HEX_STR=-6;
const long JS_STRLEN_ERR=-7;
const long JS_TYPE_ERR=-10;
const long JS_OP_ERR=-11;
IntPtr hc;
long si;
si = wsh.ClearAlarm(button1.Handle 139);
第一个参数据是端口句柄,你要装上考勤机,才能获取到
第二个参数同上,也要装上考勤机,才能获取到
switch (si)
{
case JS_OK:
MessageBox.Show(“JS_OK成功“);
break;
case INVALID_HANDLE_VALUE:
MessageBox.Show(“INVALID_HANDLE_VALUE非法句柄“);
break;
case JS_COMM_ERR:
MessageBox.Show(“JS_COMM_ERR通讯错误“);
break;
case JS_NO_HEX_STR:
MessageBox.Show(“JS_NO_HEX_STR输入参数不是十六进制的字符串“);
break;
case JS_STRLEN_ERR:
MessageBox.Show(“JS_STRLEN_ERR输入字符串参数长度不匹配“);
break;
case JS_TYPE_ERR:
MessageBox.Show(“JS_TYPE_ERR设备不支持的类型“);
break;
case JS_OP_ERR:
MessageBox.Show(“JS_OP_ERR设备操作错误“);
break;
default:
MessageBox.Show(“调用失败“);
break;
}
}
}
public class wsh
{
[DllImport(“a08.dll“ CharSet = CharSet.Ansi CallingConvention = CallingConvention.StdCall)]
public extern static long ClearAlarm(IntPtr hCom byte DevNo);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3215 2009-07-10 13:29 app3\app3\app3.csproj
文件 163840 2005-06-21 16:05 app3\app3\bin\Debug\a08.dll
文件 20480 2009-07-10 13:29 app3\app3\bin\Debug\app3.exe
文件 22016 2009-07-10 13:29 app3\app3\bin\Debug\app3.pdb
文件 5632 2005-11-11 22:25 app3\app3\bin\Debug\app3.vshost.exe
文件 2277 2009-07-10 13:36 app3\app3\Form1.cs
文件 2043 2009-07-10 12:17 app3\app3\Form1.Designer.cs
文件 5814 2009-07-10 12:17 app3\app3\Form1.resx
文件 247 2009-07-10 13:29 app3\app3\obj\app3.csproj.FileList.txt
文件 842 2009-07-10 12:19 app3\app3\obj\Debug\app3.csproj.GenerateResource.Cache
文件 20480 2009-07-10 13:29 app3\app3\obj\Debug\app3.exe
文件 180 2009-07-10 12:19 app3\app3\obj\Debug\app3.Form1.resources
文件 22016 2009-07-10 13:29 app3\app3\obj\Debug\app3.pdb
文件 180 2009-07-10 11:53 app3\app3\obj\Debug\app3.Properties.Resources.resources
文件 469 2009-07-10 12:20 app3\app3\Program.cs
文件 1162 2009-07-10 11:53 app3\app3\Properties\AssemblyInfo.cs
文件 2862 2009-07-10 11:53 app3\app3\Properties\Resources.Designer.cs
文件 5612 2009-07-10 11:53 app3\app3\Properties\Resources.resx
文件 1087 2009-07-10 11:53 app3\app3\Properties\Settings.Designer.cs
文件 249 2009-07-10 11:53 app3\app3\Properties\Settings.settings
文件 901 2009-07-10 11:53 app3\app3.sln
..A..H. 17408 2009-07-10 13:36 app3\app3.suo
目录 0 2009-07-10 11:53 app3\app3\obj\Debug\TempPE
目录 0 2009-07-10 13:36 app3\app3\bin\Debug
目录 0 2009-07-10 13:29 app3\app3\obj\Debug
目录 0 2009-07-10 13:29 app3\app3\bin
目录 0 2009-07-10 11:53 app3\app3\obj
目录 0 2009-07-10 11:53 app3\app3\Properties
目录 0 2009-07-10 13:36 app3\app3
目录 0 2009-07-10 11:53 app3
............此处省略3个文件信息
- 上一篇:c# 真正的线控件直线、斜线而且不会遮盖
- 下一篇:C# 动态生成RDLC报表
评论
共有 条评论