Add Original SDK

This commit is contained in:
2026-05-06 07:47:36 +02:00
parent 2915e04380
commit 0ed627517a
674 changed files with 89334 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,58 @@
using System.Reflection;
using System.Runtime.CompilerServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]

View File

@@ -0,0 +1,128 @@
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{1B4F9D4B-2045-4A7D-9007-1FBDB9E30F2C}"
>
<Build>
<Settings
ApplicationIcon = "App.ico"
AssemblyKeyContainerName = ""
AssemblyName = "ChangeTest"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "WinExe"
PreBuildEvent = ""
PostBuildEvent = ""
RootNamespace = "ChangeTest"
RunPostBuildEvent = "OnBuildSuccess"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "true"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE"
DocumentationFile = ""
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.dll"
/>
<Reference
Name = "System.Data"
AssemblyName = "System.Data"
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.Data.dll"
/>
<Reference
Name = "System.Drawing"
AssemblyName = "System.Drawing"
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.Drawing.dll"
/>
<Reference
Name = "System.Windows.Forms"
AssemblyName = "System.Windows.Forms"
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.Windows.Forms.dll"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.Xml"
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.XML.dll"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "App.ico"
BuildAction = "Content"
/>
<File
RelPath = "AssemblyInfo.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "DinkeyChange.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "Form1.cs"
SubType = "Form"
BuildAction = "Compile"
/>
<File
RelPath = "Form1.resx"
DependentUpon = "Form1.cs"
BuildAction = "EmbeddedResource"
/>
<File
RelPath = "readme.txt"
BuildAction = "Content"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>

View File

@@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChangeTest", "ChangeTest.csproj", "{1B4F9D4B-2045-4A7D-9007-1FBDB9E30F2C}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{1B4F9D4B-2045-4A7D-9007-1FBDB9E30F2C}.Debug.ActiveCfg = Debug|.NET
{1B4F9D4B-2045-4A7D-9007-1FBDB9E30F2C}.Debug.Build.0 = Debug|.NET
{1B4F9D4B-2045-4A7D-9007-1FBDB9E30F2C}.Release.ActiveCfg = Release|.NET
{1B4F9D4B-2045-4A7D-9007-1FBDB9E30F2C}.Release.Build.0 = Release|.NET
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,203 @@
// !! this file should not be modified
using System;
using System.Runtime.InteropServices; // so we can import DLL functions
using System.Text; // so we can extract prodcode from array
// classes to load the correct 32-bit/64-bit DinkeyChange.dll functions - used by DinkeyChange class
// loads DCGetInfo from the 32-bit DinkeyChange.dll
class DCGetInfo32
{
[DllImport("DinkeyChange.dll", CharSet = CharSet.Ansi)]
public static extern int DCGetInfo(int type_mask, int model_mask, string prodcode_mask, int array_length, out int num_found, int[] type, int[] model, byte[] prodcode, uint[] dongle_number, int[] update_number);
}
// loads DCGetInfo from the 64-bit DinkeyChange64.dll
class DCGetInfo64
{
[DllImport("DinkeyChange64.dll", CharSet = CharSet.Ansi)]
public static extern int DCGetInfo(int type_mask, int model_mask, string prodcode_mask, int array_length, out int num_found, int[] type, int[] model, byte[] prodcode, uint[] dongle_number, int[] update_number);
}
// loads DCGetDiagnosticInfo from the 32-bit DinkeyChange.dll
class DCGetDiagnosticInfo32
{
[DllImport("DinkeyChange.dll", CharSet = CharSet.Ansi)]
public static extern int DCGetDiagnosticInfo(string filename);
}
// loads DCGetDiagnosticInfo from the 64-bit DinkeyChange64.dll
class DCGetDiagnosticInfo64
{
[DllImport("DinkeyChange64.dll", CharSet = CharSet.Ansi)]
public static extern int DCGetDiagnosticInfo(string filename);
}
// loads DCDoUpdateCodeString from the 32-bit DinkeyChange.dll
class DCDoUpdateCodeString32
{
[DllImport("DinkeyChange.dll", CharSet = CharSet.Ansi)]
public static extern int DCDoUpdateCodeString(string update_code_string, out int confirmation_code, out int extended_error);
}
// loads DCDoUpdateCodeString from the 64-bit DinkeyChange64.dll
class DCDoUpdateCodeString64
{
[DllImport("DinkeyChange64.dll", CharSet = CharSet.Ansi)]
public static extern int DCDoUpdateCodeString(string update_code_string, out int confirmation_code, out int extended_error);
}
// loads DCDoUpdateCodeFromFile from the 32-bit DinkeyChange.dll
class DCDoUpdateCodeFromFile32
{
[DllImport("DinkeyChange.dll", CharSet = CharSet.Ansi)]
public static extern int DCDoUpdateCodeFromFile(string update_code_file, out int confirmation_code, out int extended_error);
}
// loads DCDoUpdateCodeFromFile from the 64-bit DinkeyChange64.dll
class DCDoUpdateCodeFromFile64
{
[DllImport("DinkeyChange64.dll", CharSet = CharSet.Ansi)]
public static extern int DCDoUpdateCodeFromFile(string update_code_file, out int confirmation_code, out int extended_error);
}
// loads DCRestoreDinkeyFDLite from the 32-bit DinkeyChange.dll
class DCRestoreDinkeyFDLite32
{
[DllImport("DinkeyChange.dll", CharSet = CharSet.Ansi)]
public static extern int DCRestoreDinkeyFDLite();
}
// loads DCRestoreDinkeyFDLite from the 64-bit DinkeyChange64.dll
class DCRestoreDinkeyFDLite64
{
[DllImport("DinkeyChange64.dll", CharSet = CharSet.Ansi)]
public static extern int DCRestoreDinkeyFDLite();
}
// loads DCGetMachineID from the 32-bit DinkeyChange.dll
class DCGetMachineID32
{
[DllImport("DinkeyChange.dll", CharSet = CharSet.Ansi)]
public static extern int DCGetMachineID(out uint machineID, out int extended_error);
}
// loads DCGetMachineID from the 64-bit DinkeyChange64.dll
class DCGetMachineID64
{
[DllImport("DinkeyChange64.dll", CharSet = CharSet.Ansi)]
public static extern int DCGetMachineID(out uint machineID, out int extended_error);
}
// loads DCDownloadTempSoftwareKey from the 32-bit DinkeyChange.dll
class DCDownloadTempSoftwareKey32
{
[DllImport("DinkeyChange.dll", CharSet = CharSet.Ansi)]
public static extern int DCDownloadTempSoftwareKey(uint machineID, out int extended_error);
}
// loads DCDownloadTempSoftwareKey from the 64-bit DinkeyChange64.dll
class DCDownloadTempSoftwareKey64
{
[DllImport("DinkeyChange64.dll", CharSet = CharSet.Ansi)]
public static extern int DCDownloadTempSoftwareKey(uint machineID, out int extended_error);
}
// loads DCDownloadDemoSoftwareKey from the 32-bit DinkeyChange.dll
class DCDownloadDemoSoftwareKey32
{
[DllImport("DinkeyChange.dll", CharSet = CharSet.Ansi)]
public static extern int DCDownloadDemoSoftwareKey(uint machineID, string prodcode, int model, out int extended_error);
}
// loads DCDownloadDemoSoftwareKey from the 64-bit DinkeyChange64.dll
class DCDownloadDemoSoftwareKey64
{
[DllImport("DinkeyChange64.dll", CharSet = CharSet.Ansi)]
public static extern int DCDownloadDemoSoftwareKey(uint machineID, string prodcode, int model, out int extended_error);
}
class DinkeyChange
{
// **** main API
// We only want to load the correct DLL for the bit-ness of the computer. The other DLL may not exist.
// if the appropriate DLL does not exist in the same directory as this test program you will receive a DllNotFoundException
// detects whether running 32-bit code or 64-bit code and loads appropriate Dll.
public static int DCGetInfo(int type_mask, int model_mask, string prodcode_mask, int array_length, out int num_found, int[] type, int[] model, byte[] prodcode, uint[] dongle_number, int[] update_number)
{
if (IntPtr.Size == 4)
return DCGetInfo32.DCGetInfo(type_mask, model_mask, prodcode_mask, array_length, out num_found, type, model, prodcode, dongle_number, update_number);
return DCGetInfo64.DCGetInfo(type_mask, model_mask, prodcode_mask, array_length, out num_found, type, model, prodcode, dongle_number, update_number);
}
public static int DCGetDiagnosticInfo(string filename)
{
if (IntPtr.Size == 4)
return DCGetDiagnosticInfo32.DCGetDiagnosticInfo(filename);
return DCGetDiagnosticInfo64.DCGetDiagnosticInfo(filename);
}
public static int DCDoUpdateCodeString(string update_code_string, out int confirmation_code, out int extended_error)
{
if (IntPtr.Size == 4)
return DCDoUpdateCodeString32.DCDoUpdateCodeString(update_code_string, out confirmation_code, out extended_error);
return DCDoUpdateCodeString64.DCDoUpdateCodeString(update_code_string, out confirmation_code, out extended_error);
}
public static int DCDoUpdateCodeFromFile(string update_code_string, out int confirmation_code, out int extended_error)
{
if (IntPtr.Size == 4)
return DCDoUpdateCodeFromFile32.DCDoUpdateCodeFromFile(update_code_string, out confirmation_code, out extended_error);
return DCDoUpdateCodeFromFile64.DCDoUpdateCodeFromFile(update_code_string, out confirmation_code, out extended_error);
}
public static int DCRestoreDinkeyFDLite()
{
if (IntPtr.Size == 4)
return DCRestoreDinkeyFDLite32.DCRestoreDinkeyFDLite();
return DCRestoreDinkeyFDLite64.DCRestoreDinkeyFDLite();
}
public static int DCGetMachineID(out uint machineID, out int extended_error)
{
if (IntPtr.Size == 4)
return DCGetMachineID32.DCGetMachineID(out machineID, out extended_error);
return DCGetMachineID64.DCGetMachineID(out machineID, out extended_error);
}
public static int DCDownloadTempSoftwareKey(uint machineID, out int extended_error)
{
if (IntPtr.Size == 4)
return DCDownloadTempSoftwareKey32.DCDownloadTempSoftwareKey(machineID, out extended_error);
return DCDownloadTempSoftwareKey64.DCDownloadTempSoftwareKey(machineID, out extended_error);
}
public static int DCDownloadDemoSoftwareKey(uint machineID, string prodcode, int model, out int extended_error)
{
if (IntPtr.Size == 4)
return DCDownloadDemoSoftwareKey32.DCDownloadDemoSoftwareKey(machineID, prodcode, model, out extended_error);
return DCDownloadDemoSoftwareKey64.DCDownloadDemoSoftwareKey(machineID, prodcode, model, out extended_error);
}
// **** general purpose routines
// routine to extract product code string from array of product codes
public static string GetProductCode(byte[] prodcode, int index)
{
int i;
StringBuilder sb = new StringBuilder(8);
for (i=index*9; i<(index+1)*9; i++)
{
if (prodcode[i] == 0)
return sb.ToString();
else
sb.Append((char)prodcode[i]);
}
return sb.ToString();
}
}

View File

@@ -0,0 +1,581 @@
// !! We strongly recommend that you read the "readme.txt" file in the sample code folder.
// !! It contains important instructions on how to use the sample code
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace ChangeTest
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button get_dongle_info;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox diag_filename;
private System.Windows.Forms.Button write_diag_file;
private System.Windows.Forms.Button do_update_code_string;
private System.Windows.Forms.TextBox update_code_string;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button do_update_code_file;
private System.Windows.Forms.TextBox update_code_file;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button restore_fd_lite;
private System.Windows.Forms.Button get_machine_id;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox swkey_prod_code;
private System.Windows.Forms.Button download_temp_swkey;
private System.Windows.Forms.Button download_demo_swkey;
private System.Windows.Forms.TextBox machine_id;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
// maximum number of USB devices that can be attached to a machine at any time
public const int MAX_USB_DEVICES = 128;
public const int MAX_PRODCODE_LEN = 9; // including terminating null
public string AppName = "ChangeTest";
// mask values
public const int TYPE_MASK_PRO = 1;
public const int TYPE_MASK_FD = 2;
public const int TYPE_MASK_ALL = (TYPE_MASK_PRO | TYPE_MASK_FD);
public const int MODEL_MASK_LITE = 1;
public const int MODEL_MASK_PLUS = 2;
public const int MODEL_MASK_NET = 4;
public const int MODEL_MASK_ALL = (MODEL_MASK_LITE | MODEL_MASK_PLUS | MODEL_MASK_NET);
public const int MODEL_MASK_DEFAULT = (MODEL_MASK_PLUS | MODEL_MASK_NET);
// type values for DCGetInfo (returned in the array)
public const int TYPE_PRO = 1;
public const int TYPE_FD = 2;
// model values for DCGetInfo (returned in the array)
public const int MODEL_LITE = 1;
public const int MODEL_PLUS = 2;
public const int MODEL_NET5 = 4;
public const int MODEL_NETU = 7;
// model values for DCDownloadDemoSoftwareKey
public const int SWKEY_MODEL_DEFAULT = -1; // NB this assumes that the Demo Software Key Template was created with only one valid dongle model
public const int SWKEY_MODEL_PRO_LITE = 0;
public const int SWKEY_MODEL_PRO_PLUS = 1;
public const int SWKEY_MODEL_PRO_NET = 2;
public const int SWKEY_MODEL_FD_LITE = 3;
public const int SWKEY_MODEL_FD_PLUS = 4;
public const int SWKEY_MODEL_FD_NET = 5;
private void InitializeComponent()
{
this.get_dongle_info = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.diag_filename = new System.Windows.Forms.TextBox();
this.write_diag_file = new System.Windows.Forms.Button();
this.do_update_code_string = new System.Windows.Forms.Button();
this.update_code_string = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.do_update_code_file = new System.Windows.Forms.Button();
this.update_code_file = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.restore_fd_lite = new System.Windows.Forms.Button();
this.get_machine_id = new System.Windows.Forms.Button();
this.machine_id = new System.Windows.Forms.TextBox();
this.download_temp_swkey = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.swkey_prod_code = new System.Windows.Forms.TextBox();
this.download_demo_swkey = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// get_dongle_info
//
this.get_dongle_info.Location = new System.Drawing.Point(48, 24);
this.get_dongle_info.Name = "get_dongle_info";
this.get_dongle_info.Size = new System.Drawing.Size(224, 24);
this.get_dongle_info.TabIndex = 0;
this.get_dongle_info.Text = "Get Dongle Information";
this.get_dongle_info.Click += new System.EventHandler(this.get_dongle_info_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 72);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(280, 16);
this.label1.TabIndex = 1;
this.label1.Text = "Enter diagnostic filename:";
//
// diag_filename
//
this.diag_filename.Location = new System.Drawing.Point(16, 88);
this.diag_filename.Name = "diag_filename";
this.diag_filename.Size = new System.Drawing.Size(288, 20);
this.diag_filename.TabIndex = 2;
this.diag_filename.Text = "";
//
// write_diag_file
//
this.write_diag_file.Location = new System.Drawing.Point(48, 120);
this.write_diag_file.Name = "write_diag_file";
this.write_diag_file.Size = new System.Drawing.Size(224, 24);
this.write_diag_file.TabIndex = 3;
this.write_diag_file.Text = "Write Diagnostics to File";
this.write_diag_file.Click += new System.EventHandler(this.write_diag_file_Click);
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 168);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(280, 16);
this.label2.TabIndex = 4;
this.label2.Text = "Enter short Update Code here:";
//
// update_code_string
//
this.update_code_string.Location = new System.Drawing.Point(16, 184);
this.update_code_string.Name = "update_code_string";
this.update_code_string.Size = new System.Drawing.Size(288, 20);
this.update_code_string.TabIndex = 5;
this.update_code_string.Text = "";
//
// do_update_code_string
//
this.do_update_code_string.Location = new System.Drawing.Point(48, 216);
this.do_update_code_string.Name = "do_update_code_string";
this.do_update_code_string.Size = new System.Drawing.Size(224, 24);
this.do_update_code_string.TabIndex = 6;
this.do_update_code_string.Text = "Make Changes";
this.do_update_code_string.Click += new System.EventHandler(this.do_update_code_string_Click);
//
// do_update_code_file
//
this.do_update_code_file.Location = new System.Drawing.Point(48, 312);
this.do_update_code_file.Name = "do_update_code_file";
this.do_update_code_file.Size = new System.Drawing.Size(224, 24);
this.do_update_code_file.TabIndex = 9;
this.do_update_code_file.Text = "Make Changes";
this.do_update_code_file.Click += new System.EventHandler(this.do_update_code_file_Click);
//
// update_code_file
//
this.update_code_file.Location = new System.Drawing.Point(16, 280);
this.update_code_file.Name = "update_code_file";
this.update_code_file.Size = new System.Drawing.Size(288, 20);
this.update_code_file.TabIndex = 8;
this.update_code_file.Text = "";
//
// label3
//
this.label3.Location = new System.Drawing.Point(16, 264);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(280, 16);
this.label3.TabIndex = 7;
this.label3.Text = "Enter path to Update Code file:";
//
// restore_fd_lite
//
this.restore_fd_lite.Location = new System.Drawing.Point(48, 368);
this.restore_fd_lite.Name = "restore_fd_lite";
this.restore_fd_lite.Size = new System.Drawing.Size(224, 24);
this.restore_fd_lite.TabIndex = 10;
this.restore_fd_lite.Text = "Restore Dinkey FD Lite";
this.restore_fd_lite.Click += new System.EventHandler(this.restore_fd_lite_Click);
//
// get_machine_id
//
this.get_machine_id.Location = new System.Drawing.Point(16, 424);
this.get_machine_id.Name = "get_machine_id";
this.get_machine_id.Size = new System.Drawing.Size(144, 24);
this.get_machine_id.TabIndex = 11;
this.get_machine_id.Text = "Get Machine ID";
this.get_machine_id.Click += new System.EventHandler(this.get_machine_id_Click);
//
// machine_id
//
this.machine_id.Location = new System.Drawing.Point(168, 424);
this.machine_id.Name = "machine_id";
this.machine_id.Size = new System.Drawing.Size(136, 20);
this.machine_id.TabIndex = 12;
this.machine_id.Text = "";
//
// download_temp_swkey
//
this.download_temp_swkey.Location = new System.Drawing.Point(48, 480);
this.download_temp_swkey.Name = "download_temp_swkey";
this.download_temp_swkey.Size = new System.Drawing.Size(224, 24);
this.download_temp_swkey.TabIndex = 13;
this.download_temp_swkey.Text = "Download Temporary Software Key";
this.download_temp_swkey.Click += new System.EventHandler(this.download_temp_swkey_Click);
//
// label4
//
this.label4.Location = new System.Drawing.Point(16, 528);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(280, 16);
this.label4.TabIndex = 14;
this.label4.Text = "Demo Software Key Product Code:";
//
// swkey_prod_code
//
this.swkey_prod_code.Location = new System.Drawing.Point(16, 544);
this.swkey_prod_code.Name = "swkey_prod_code";
this.swkey_prod_code.Size = new System.Drawing.Size(288, 20);
this.swkey_prod_code.TabIndex = 15;
this.swkey_prod_code.Text = "";
//
// download_demo_swkey
//
this.download_demo_swkey.Location = new System.Drawing.Point(48, 576);
this.download_demo_swkey.Name = "download_demo_swkey";
this.download_demo_swkey.Size = new System.Drawing.Size(224, 24);
this.download_demo_swkey.TabIndex = 16;
this.download_demo_swkey.Text = "Download Demo Software Key";
this.download_demo_swkey.Click += new System.EventHandler(this.download_demo_swkey_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(320, 624);
this.Controls.Add(this.download_demo_swkey);
this.Controls.Add(this.swkey_prod_code);
this.Controls.Add(this.label4);
this.Controls.Add(this.machine_id);
this.Controls.Add(this.download_temp_swkey);
this.Controls.Add(this.get_machine_id);
this.Controls.Add(this.restore_fd_lite);
this.Controls.Add(this.do_update_code_file);
this.Controls.Add(this.update_code_file);
this.Controls.Add(this.label3);
this.Controls.Add(this.do_update_code_string);
this.Controls.Add(this.update_code_string);
this.Controls.Add(this.label2);
this.Controls.Add(this.write_diag_file);
this.Controls.Add(this.diag_filename);
this.Controls.Add(this.label1);
this.Controls.Add(this.get_dongle_info);
this.Name = "Form1";
this.Text = "ChangeTest";
this.ResumeLayout(false);
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
// routine to get & display information for all dongles attached
private void get_dongle_info_Click(object sender, System.EventArgs e)
{
int ret_code, i, num_found;
string DisplayString = null;
string Type, Model, ProdCodeString;
// return arrays of dongle details filedin by DCGetInfo
int[] type = new int[MAX_USB_DEVICES];
int[] model = new int[MAX_USB_DEVICES];
byte[] prodcode = new Byte[MAX_USB_DEVICES*MAX_PRODCODE_LEN];
uint[] dongle_number = new uint[MAX_USB_DEVICES];
int[] update_number = new int[MAX_USB_DEVICES];
// find dongle information for all dongle types, Plus & Net models, for all product codes
// NB In practice you will probably want to set the prodcode_mask to the value of your product code
ret_code = DinkeyChange.DCGetInfo(TYPE_MASK_ALL, MODEL_MASK_DEFAULT, null, MAX_USB_DEVICES, out num_found, type, model, prodcode, dongle_number, update_number);
// check error code and display error if an error occurs
if (ret_code == 401)
{
MessageBox.Show("No dongles detected matching the search criteria specified", AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
else if (ret_code != 0)
{
DisplayString = "An error occurred getting dongle information. Error: " + String.Format("{0:D}", ret_code);
MessageBox.Show(DisplayString, AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
// display info for dongle(s) detected
for (i=0; i<num_found; i++)
{
// get type of dongle
if (type[i] == TYPE_PRO)
Type = "Pro";
else
Type = "FD";
// get model of dongle
if (model[i] == MODEL_LITE)
Model = "Lite";
else if (model[i] == MODEL_PLUS)
Model = "Plus";
else
Model = "Net";
ProdCodeString = DinkeyChange.GetProductCode(prodcode, i);
DisplayString += String.Format("{0}. Dinkey {1} {2} with dongle number: {3}, product code: {4}, update number: {5}", i+1, Type, Model, dongle_number[i], ProdCodeString, update_number[i]);
DisplayString += Environment.NewLine;
}
MessageBox.Show(DisplayString, "Dongle Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Write Dongle Diagnostics to file
private void write_diag_file_Click(object sender, System.EventArgs e)
{
int ret_code;
// NB this could take a while if the data area is very large
ret_code = DinkeyChange.DCGetDiagnosticInfo(diag_filename.Text);
// check error code and display error if an error occurs
if (ret_code == 754)
{
MessageBox.Show("Could not create the diagnostic file. Please check that the path exists: " + diag_filename.Text, AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
else if (ret_code != 0)
{
MessageBox.Show(String.Format("Error {0} writing diagnostic information", ret_code), AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
// display success
MessageBox.Show("Diagnostic file written successfully.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Update dongle using short code typed-in
private void do_update_code_string_Click(object sender, System.EventArgs e)
{
int ret_code, confirmation_code, extended_error;
// make changes
ret_code = DinkeyChange.DCDoUpdateCodeString(update_code_string.Text, out confirmation_code, out extended_error);
// check error code and display error if an error occurs
if (ret_code != 0)
{
DisplayError(ret_code, extended_error);
return;
}
MessageBox.Show(String.Format("Dongle updated successfully!\nConfirmation code is : {0:X4}", confirmation_code), AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void do_update_code_file_Click(object sender, System.EventArgs e)
{
int ret_code, confirmation_code, extended_error;
// make changes
ret_code = DinkeyChange.DCDoUpdateCodeFromFile(update_code_file.Text, out confirmation_code, out extended_error);
// check error code and display error if an error occurs
if (ret_code != 0)
{
DisplayError(ret_code, extended_error);
return;
}
MessageBox.Show(String.Format("Dongle updated successfully!\nConfirmation code is : {0:X4}", confirmation_code), AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
// attempt to restore a Dinkey FD Lite dongle
private void restore_fd_lite_Click(object sender, System.EventArgs e)
{
int ret_code;
ret_code = DinkeyChange.DCRestoreDinkeyFDLite();
// check error code and display error if an error occurs
if (ret_code != 0)
{
DisplayError(ret_code, 0);
return;
}
MessageBox.Show("Dinkey FD Lite restored successfully.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void get_machine_id_Click(object sender, System.EventArgs e)
{
int ret_code, extended_error;
uint machineID;
ret_code = DinkeyChange.DCGetMachineID(out machineID, out extended_error);
// check error code and display error if an error occurs
if (ret_code != 0)
{
DisplayError(ret_code, extended_error);
return;
}
// display the machine ID in the text box
machine_id.Text = String.Format("{0:X8}", machineID);
}
private void download_temp_swkey_Click(object sender, System.EventArgs e)
{
int ret_code, extended_error;
uint machineID;
// first get the machine ID...
ret_code = DinkeyChange.DCGetMachineID(out machineID, out extended_error);
// check error code and display error if an error occurs
if (ret_code != 0)
{
DisplayError(ret_code, extended_error);
return;
}
// ... and then try to download the temporary software key
ret_code = DinkeyChange.DCDownloadTempSoftwareKey(machineID, out extended_error);
// check error code and display error if an error occurs
if (ret_code != 0)
{
DisplayError(ret_code, extended_error);
return;
}
MessageBox.Show("Temporary Software Key downloaded successfully.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void download_demo_swkey_Click(object sender, System.EventArgs e)
{
int ret_code, extended_error;
uint machineID;
// first get the machine ID...
ret_code = DinkeyChange.DCGetMachineID(out machineID, out extended_error);
// check error code and display error if an error occurs
if (ret_code != 0)
{
DisplayError(ret_code, extended_error);
return;
}
// try to download the demo software key
// (NB we are assuming only one dongle model is set in the Demo Software Template.
// If multiple models are set you will also need to specify the exact model)
ret_code = DinkeyChange.DCDownloadDemoSoftwareKey(machineID, swkey_prod_code.Text, SWKEY_MODEL_DEFAULT, out extended_error);
// check error code and display error if an error occurs
if (ret_code != 0)
{
DisplayError(ret_code, extended_error);
return;
}
MessageBox.Show("Demo Software Key downloaded successfully.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
// displays messages for the most common errors. You will want to change this for your code
void DisplayError(int ret_code, int extended_error)
{
switch (ret_code)
{
case 401:
MessageBox.Show("Error! No dongles detected that meet the search criteria!", AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 409:
MessageBox.Show("Error! The dongle detected has not been programmed by DinkeyAdd.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 758:
MessageBox.Show("Error! Cannot open the Update Code file specified.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 759:
MessageBox.Show("Error! The file specified is not a valid Update Code file.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 762:
case 763:
case 764:
MessageBox.Show("Error! Update Code is not in a correct format / update code file is corrupt.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 765:
MessageBox.Show("Error! The Update Code does not match any dongle attached to your machine.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 766:
MessageBox.Show("Error! The update number for this Update Code is too high. You need to first enter an update code that was previously sent to you.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 767:
MessageBox.Show("Error! You have already entered this Update Code.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 1905:
MessageBox.Show("Error! There is no Software Key available for download.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 1907:
MessageBox.Show("Error! The Temporary Software Key has expired. Cannot download it.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 1910:
MessageBox.Show("Error! The Software Key has already been downloaded.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 1921:
MessageBox.Show("Error! You specified the 'default model' but there is more than one model available. You need to specify a specific dongle model.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 1922:
MessageBox.Show("Error! The model you requested is not available.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 1923:
MessageBox.Show("Error! The Demo Software Key Template has been disabled.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 1924:
MessageBox(NULL, "Error! You have run out of Demo Software Key activations. You need to order some more.", g_szAppName, MB_OK);
break;
default:
MessageBox.Show(String.Format("An error occurred updating the dongle.\nError: {0}, Extended Error: {1}", ret_code, extended_error), AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
}
return;
}
}
}

View File

@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="$this.Name">
<value>Form1</value>
</data>
</root>

View File

@@ -0,0 +1,64 @@
ChangeTest - sample code to call DinkeyChange Module in C#
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This project is written in Visual Studio 2003 but will work in more recent versions of
Visual Studio (they will upgrade the Project to the latest version. If prompted you
should also upgrade the .NET framework the project requires).
For users of Visual Studio 2005 or higher, the default setting to projects is to compile
for the Target Platform "Any". This means that on 32-bit Windows, your code will run as
32-bit code (and needs to call DinkeyChange.dll) and under 64-bit Windows your code will
run as 64-bit code (and needs to call DinkeyChange64.dll). The sample code works this out
automatically. If you select the target platform as "x86" then it will always be 32-bit
and so you only need to use DinkeyChange.dll. If you select "x64" then your code will be
64-bit and you only need to use DinkeyChange64.dll.
The main source files in the project are:
DinkeyChange.cs - the source file contains declarations of our API. We automatically
work out whether your code is running in 32-bit or 64-bit and load the
appropriate DinkeyChange module.
Form1.cs - this is the sample code giving an example on how you can call our API.
It contains 7 functions. Just use which ever functions are most appropriate
and customise in your own way.
The best approach is to compile the sample code and see how it works and then to take the
appropriate code and apply it to your own project. You should include the DinkeyChange.cs
file in your project and use/modify which ever functions from Form1.cs you feel are
appropriate. The DinkeyChange.cs file should not be modified.
The sample code is just a guide. As none of the parameters are security sensitive then
there is no need to implement strong security in calling DinkeyChange.
Make sure you remember to do the following when creating your own project:
1) Insert the DinkeyChange.cs file in your project.
2) You need to put DinkeyChange.dll and/or DinkeyChange64.dll into the folder that
contains your EXE file. Otherwise the System.DllNotFoundException error will appear
when you run ChangeTest.
You can rename DinkeyChange.dll (DinkeyChange64.dll) to a name of your choice. In this
case you will need to modify the dll names specified in the DinkeyChange.cs file.
Notes on Debugging 64-bit Code
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When you use the 64-bit module (DinkeyChange64.dll) the anti-debug code is so strong that
if you are debugging your code, after calling our API then it will crash with an SEH
exception. If you want to be able to debug your code then you can setup your project so
that your code calls the debug module (DinkeyChange64Debug.dll) in your "debug" build and
the standard module (DinkeyChange64.dll) in your release build. In this case you will
need to modify the declarations of our API in DinkeyChange.cs. This is an example for
DCDoUpdateCodeFromFile64:
class DCDoUpdateCodeFromFile64
{
#if DEBUG ' debug module
[DllImport("DinkeyChange64Debug.dll", CharSet = CharSet.Ansi)]
public static extern int DCDoUpdateCodeFromFile(string update_code_file, out int confirmation_code, out int extended_error);
#else ' standard module
[DllImport("DinkeyChange64.dll", CharSet = CharSet.Ansi)]
public static extern int DCDoUpdateCodeFromFile(string update_code_file, out int confirmation_code, out int extended_error);
#endif
}