資源簡介
是你學(xué)習(xí)使用加密狗很好的例子,有很全面的代碼,可以直接運行

代碼片段和文件信息
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?Ex13_04
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????Dog?dog?=?new?Dog(100);
????????????dog.DogAddr?=?0;
????????????dog.DogBytes?=?6;
????????????dog.ReadDog();
????????????if?(dog.Retcode?==?0)
????????????{
????????????????char[]?chTemp?=?new?char[6];
????????????????for?(int?i?=?0;?i?6;?i++)
????????????????{
????????????????????chTemp[i]?=?(char)dog.DogData[i];
????????????????}
????????????????String?str?=?new?String(chTemp);
????????????????if?(textBox2.Text==str)
????????????????{
????????????????????MessageBox.Show(“OK“);
????????????????}
????????????????else
????????????????{
????????????????????MessageBox.Show(“error“);
????????????????}
????????????}
????????}
????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
????????????Application.Exit();
????????}
????}
}
[StructLayout(LayoutKind.Sequential)]
//這個類用于讀寫加密狗。
public?unsafe?class?Dog
{
????public?uint?DogBytes?DogAddr;??//設(shè)置加密狗起始地址
????public?byte[]?DogData;??//設(shè)置數(shù)據(jù)的長度
????public?uint?Retcode;
????[DllImport(“Win32dll.dll“?CharSet?=?CharSet.Ansi)]
????public?static?unsafe?extern?uint?DogRead(uint?idogBytes?uint?idogAddr?byte*?pdogData);
????public?unsafe?Dog(ushort?num)
????{
????????DogBytes?=?num;
????????DogData?=?new?byte[DogBytes];?//設(shè)置數(shù)據(jù)的長度
????}
????public?unsafe?void?ReadDog()
????{
????????fixed?(byte*?pDogData?=?&DogData[0])
????????{
????????????Retcode?=?DogRead(DogBytes?DogAddr?pDogData); //將數(shù)據(jù)讀出加密狗
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????20480??2007-07-11?11:32??Ex13_04\Ex13_04\bin\Debug\Ex13_04.exe
?????文件??????26112??2007-07-11?11:32??Ex13_04\Ex13_04\bin\Debug\Ex13_04.pdb
?????文件???????5632??2007-07-11?11:32??Ex13_04\Ex13_04\bin\Debug\Ex13_04.vshost.exe
?????文件??????61440??2007-07-11?11:32??Ex13_04\Ex13_04\bin\Debug\win32dll.dll
?????目錄??????????0??2009-04-03?13:28??Ex13_04\Ex13_04\bin\Debug
?????目錄??????????0??2009-04-03?13:28??Ex13_04\Ex13_04\bin
?????文件???????3270??2007-07-11?11:32??Ex13_04\Ex13_04\Ex13_04.csproj
?????文件???????2007??2007-07-11?11:32??Ex13_04\Ex13_04\Form1.cs
?????文件???????5478??2007-07-11?11:32??Ex13_04\Ex13_04\Form1.Designer.cs
?????文件???????5814??2007-07-11?11:32??Ex13_04\Ex13_04\Form1.resx
?????文件????????842??2007-07-11?11:32??Ex13_04\Ex13_04\obj\Debug\Ex13_04.csproj.GenerateResource.Cache
?????文件??????20480??2007-07-11?11:32??Ex13_04\Ex13_04\obj\Debug\Ex13_04.exe
?????文件????????180??2007-07-11?11:32??Ex13_04\Ex13_04\obj\Debug\Ex13_04.Form1.resources
?????文件??????26112??2007-07-11?11:32??Ex13_04\Ex13_04\obj\Debug\Ex13_04.pdb
?????文件????????180??2007-07-11?11:32??Ex13_04\Ex13_04\obj\Debug\Ex13_04.Properties.Resources.resources
?????目錄??????????0??2009-04-03?13:28??Ex13_04\Ex13_04\obj\Debug\TempPE
?????目錄??????????0??2009-04-03?13:28??Ex13_04\Ex13_04\obj\Debug
?????文件????????268??2007-07-11?11:32??Ex13_04\Ex13_04\obj\Ex13_04.csproj.FileList.txt
?????目錄??????????0??2009-04-03?13:28??Ex13_04\Ex13_04\obj
?????文件????????466??2007-07-11?11:32??Ex13_04\Ex13_04\Program.cs
?????文件???????1162??2007-07-11?11:32??Ex13_04\Ex13_04\Properties\AssemblyInfo.cs
?????文件???????2868??2007-07-11?11:32??Ex13_04\Ex13_04\Properties\Resources.Designer.cs
?????文件???????5612??2007-07-11?11:32??Ex13_04\Ex13_04\Properties\Resources.resx
?????文件???????1090??2007-07-11?11:32??Ex13_04\Ex13_04\Properties\Settings.Designer.cs
?????文件????????249??2007-07-11?11:32??Ex13_04\Ex13_04\Properties\Settings.settings
?????目錄??????????0??2009-04-03?13:28??Ex13_04\Ex13_04\Properties
?????目錄??????????0??2009-04-03?13:28??Ex13_04\Ex13_04
?????文件????????910??2007-07-11?11:32??Ex13_04\Ex13_04.sln
?????文件??????12800??2007-07-11?11:32??Ex13_04\Ex13_04.suo
?????目錄??????????0??2009-04-03?13:28??Ex13_04
............此處省略3個文件信息
- 上一篇:2019年大數(shù)據(jù)國賽試題
- 下一篇:瑞薩血壓計原理圖
評論
共有 條評論