• 大小: 2KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-09
  • 语言: C#
  • 标签: usbkey  c#  

资源简介

关于c# 的 usbkey开发代码,包含验证pin码,写入 读出文件等方法

资源截图

代码片段和文件信息

using System;
using System.Text;

using System.Runtime.InteropServices;
public class read{


        public struct WFileInfo
        {
            public uint lID;
            public uint lFlags;
            public uint lFileSize;
            public byte ucFileType;
            public byte ucReadAccess;
            public byte ucWriteAccess;
            public byte ucDeleteAccess;
            public byte ucCryptAccess;
            public byte ucReserved1;
            public byte ucReserved12;
            public byte ucReserved13;
            public int ucReserved14;
            public int ucReserved15;
            public byte ucGrantedAccess;
            public byte ucReserved2;
            public byte ucReserved22;
            public byte ucReserved23;
            public int ucReserved24;
            public int ucReserved25;
            public int ucReserved26;
            public int ucReserved27;
        }

        [DllImport(“FT_ND_API.dll“)]
        public static extern uint epas_CreateContext(out IntPtr hContextHandle uint ulFlags uint ulApiVersion);
        [DllImport(“FT_ND_API.dll“)]
        public static extern uint epas_OpenDevice(IntPtr hContextHandle uint ulQueryType IntPtr pQueryData);
        [DllImport(“FT_ND_API.dll“)]
        public static extern uint epas_Verify(IntPtr hContextHandle uint ulFlagsbyte[] pucData uint ulSize);
        [DllImport(“FT_ND_API.dll“)]
        public static extern uint epas_CloseDevice(IntPtr hContextHandle);
        [DllImport(“FT_ND_API.dll“)]
        public static extern uint epas_DeleteContext(IntPtr hContextHandle);      

        [DllImport(“FT_ND_API.dll“)]
        public static extern uint epas_OpenFile(IntPtr hContextHandle uint ulFlags uint ulFileID ref WFileInfo pFileInfo uint ulSizeOfFileInfo);
        [DllImport(“FT_ND_API.dll“)]
        public static extern uint epas_Write(IntPtr hContextHandle uint ulFlags uint ulOffset byte[] pucBuffer uint ulBytesToWrite out uint pulBytesWritten);
        [DllImport(“FT_ND_API.dll“)]
        public static extern uint epas_Read(IntPtr hContextHandle uint ulFlags uint ulOffset byte[] pucBuffer uint ulBytesToRead out uint pulBytesRead);
        [DllImport(“FT_ND_API.dll“)]
        public static extern uint epas_CloseFile(IntPtr hContextHandle);
[STAThread] 
public static void Main(string[] args){

            IntPtr g_hToken = IntPtr.Zero;
            uint retval = 0;
            byte [] uPin=Encoding.Default.GetBytes(“1234“);
            System.Console.WriteLine(“test verify “);

            retval = epas_CreateContext(out g_hToken 0 0x100);
            if (retval == 0)
            {
                System.Console.WriteLine(“CreateContext OK“);
            }
            else
            {
              System.Console.WriteLine(“CreateContext error {0:X8}“retval);

                goto Exit;
            }

            retval = epas_OpenDevice(g_hToken 0x001 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2314  2010-08-31 11:24  verify1.cs

     文件       4804  2010-08-31 13:19  read.cs

----------- ---------  ---------- -----  ----

                 7118                    2


评论

共有 条评论