The simplicity of the dongle

The application significance of the dongle is self-evident, it represents the use restriction of a software, and the software is not allowed to be used without the dongle.

So how do we use the dongle to encrypt software?

1. The first is to buy the dongle, the dongle will come with a CD, the CD has the driver installation program, install the driver



2. After the driver installation is complete, we can find 32-bit and 64-bit drivers under the installation path.


3. Open our C# program and run the provided program code.

Additional information will be encountered: Unable to load DLL 'Win64dll.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E). The problem.


The solution: is to add win64dll.dll to the existing item to the program, change the property to always copy. You can read and write operations on the dongle.

Special: If it's a 64-bit application, use [DllImport("Win64dll.dll", CharSet = CharSet.Ansi)]
        public static unsafe extern uint DogRead(uint idogBytes, uint idogAddr, byte* pdogData);
        [DllImport(" Win64dll.dll", CharSet = CharSet.Ansi)]

32位则使用:[DllImport("Win32dll.dll", CharSet = CharSet.Ansi)]
        public static unsafe extern uint DogRead(uint idogBytes, uint idogAddr, byte* pdogData);
        [DllImport("Win32dll.dll", CharSet = CharSet.Ansi)]



4. Problem unsafe

An error will appear, and we need to set the following settings in Project-"Project Properties-"Generation: Allow unsafe code.







Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325710938&siteId=291194637