Function KG_GenerateRegistrationKeyFromProjectW
KG_GenerateRegistrationKeyFromProjectW, as well as the KG_GenerateRegistrationKeyW function, is used for generating unicode-based registration keys. Note: to enable the application to accept unicode registration keys, the UNICODE Registration Scheme parameter from the Registration Features - Common panel should be enabled. The function reads secure information (PublicKey, PrivateKey, KeyMode, KeyBase and EncryptedConstant) from the project file and you do not have to set up these parameters in the input structure TGenKeyParamW. KG_GenerateRegistrationKeyFromProjectW has two parameters, one of them is ProjectFile, which is a pointer to unicode - null terminated string - the path to the Enigma Protector project file, and another parameter is a pointer to the TGenKeyParamW structure.
Return Values
EP_NO_ERROR=0 |
the function succeeds. In this case, Key parameter of TKeyGenParams structure should contain a pointer to the null terminated string - registration key. |
EP_ERROR_UNKNOWN=1 |
unknown error |
EP_ERROR_KEYBUFFEREMPTY=2 |
memory buffer for registration key is not allocated |
EP_ERROR_KEYBUFFERISLESS=3 |
size of allocated memory for registration key is less than required |
EP_ERROR_REGINFOEMPTY=4 |
registration information is not specified |
EP_ERROR_REGINFOTOOLARGE=5 |
registration information is empty (has a null size) |
EP_ERROR_PRIVATEKEYISNOTSET=6 |
private key is not set |
EP_ERROR_PUBLICKEYISNOTSET=7 |
public key is not set |
EP_ERROR_PRIVATEKEYISINVALID=8 |
private key is invalid |
EP_ERROR_PUBLICKEYISINVALID=9 |
public key is invalid |
EP_ERROR_KEYMODEISINVALID=10 |
key mode is invalid |
EP_ERROR_KEYBASEISINVALID=11 |
key base is invalid |
EP_ERROR_CURRENTDATEISINVALID=12 |
current date is invalid |
EP_ERROR_EXPIRATIONDATEISINVALID=13 |
expiration date is invalid |
EP_ERROR_KEYISINVALID=14 |
key is invalid |
EP_ERROR_HARDWAREID=15 |
hardware id is invalid |
EP_ERROR_HARDWAREBUFFEREMPTY=16 |
hardware id buffer is empty |
EP_ERROR_HARDWAREIDINVALIDFORKEY=17 |
hardware id is invalid for the key |
EP_ERROR_PROJECTFILENOTFOUND=18 |
project file is not found |
EP_ERROR_INVALIDPROJECTFILE=19 |
project file is invalid |
EP_ERROR_EXECUTIONSNUMBERINVALID=20 |
executions number is invalid |
EP_ERROR_DAYSNUMBERINVALID=21 |
days number is invalid |
EP_ERROR_COUNTRYCODEINVALID=22 |
country code is invalid |
EP_ERROR_RUNTIMEINVALID=23 |
run-time value is invalid |
EP_ERROR_GLOBALTIMEINVALID=24 |
global time is invalid |
EP_ERROR_INSTALLBEFOREINVALID=25 |
register before date is invalid |
EP_ERROR_INSTALLAFTERINVALID=26 |
register after date is invalid |
Definition
Show/Hide Delphi function definition
function KG_GenerateRegistrationKeyW(kg : PKeyGenParamsW) : dword; external keygen_api_dll_name name 'KG_GenerateRegistrationKeyW';
Show/Hide C++ function definition
extern "C" __declspec( dllimport ) __stdcall int KG_GenerateRegistrationKeyW(PKeyGenParamsW kg);
Show/Hide C# (.NET) function definition
public class Enigma_KeyGen_IDE
{
[DllImport("keygen.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern uint KG_GenerateRegistrationKeyW(ref TKeyGenParamsW kg);
}
Examples
Show/Hide Delphi function example
procedure TfrmMain.bGenFPClick(Sender: TObject);
var
kg : TKeyGenParamsW;
KeyBuffer : array [0..2047] of widechar;
dwResult : dword;
begin
mKey.Clear;
if eUserInfo.Text = '' then
begin
ShowMessage('User info field is empty!');
Exit;
end;
ZeroMemory(@kg, SizeOf(kg));
kg.KeyWithHyphens := cbHyphens.Checked;
ZeroMemory(@KeyBuffer, SizeOf(KeyBuffer));
kg.Key := @KeyBuffer;
kg.KeyLen := SizeOf(KeyBuffer);
kg.RegInfo := PWideChar(eUserInfo.Text);
kg.UseKeyExpiration := cbExpirationDate.Checked;
kg.ExpirationYear := YearOf(DateTimePicker1.DateTime);
kg.ExpirationMonth := MonthOf(DateTimePicker1.DateTime);
kg.ExpirationDay := DayOf(DateTimePicker1.DateTime);
kg.UseRegisterAfter := cbRegisterAfter.Checked;
if kg.UseRegisterAfter then
begin
kg.RegisterAfterYear := YearOf(dtpRegisterAfter.DateTime);
kg.RegisterAfterMonth := MonthOf(dtpRegisterAfter.DateTime);
kg.RegisterAfterDay := DayOf(dtpRegisterAfter.DateTime);
end;
kg.UseRegisterBefore := cbRegisterBefore.Checked;
if kg.UseRegisterBefore then
begin
kg.RegisterBeforeYear := YearOf(dtpRegisterBefore.DateTime);
kg.RegisterBeforeMonth := MonthOf(dtpRegisterBefore.DateTime);
kg.RegisterBeforeDay := DayOf(dtpRegisterBefore.DateTime);
end;
kg.UseCountyLimit := cbCountry.Checked;
if kg.UseCountyLimit then
begin
kg.CountryCode := KEY_COUNTRIES[comCountries.ItemIndex].Code;
end;
kg.UseExecutionsLimit := cbExecutions.Checked;
if kg.UseExecutionsLimit then
begin
kg.ExecutionsCount := StrToInt(eExecutions.Text);
end;
kg.UseDaysLimit := cbDays.Checked;
if kg.UseDaysLimit then
begin
kg.DaysCount := StrToInt(eDays.Text);
end;
kg.UseRunTimeLimit := cbRuntime.Checked;
if kg.UseRunTimeLimit then
begin
kg.RunTimeMinutes := StrToInt(eRuntime.Text);
end;
kg.UseGlobalTimeLimit := cbGlobalTime.Checked;
if kg.UseGlobalTimeLimit then
begin
kg.GlobalTimeMinutes := StrToInt(eGlobalTime.Text);
end;
kg.UseHardwareLocking := cbHardwareID.Checked;
kg.HardwareID := PWideChar(eHardware.Text);
kg.EncryptedSections[1] := cbSection1.Checked;
kg.EncryptedSections[2] := cbSection2.Checked;
kg.EncryptedSections[3] := cbSection3.Checked;
kg.EncryptedSections[4] := cbSection4.Checked;
kg.EncryptedSections[5] := cbSection5.Checked;
kg.EncryptedSections[6] := cbSection6.Checked;
kg.EncryptedSections[7] := cbSection7.Checked;
kg.EncryptedSections[8] := cbSection8.Checked;
kg.EncryptedSections[9] := cbSection9.Checked;
kg.EncryptedSections[10] := cbSection10.Checked;
kg.EncryptedSections[11] := cbSection11.Checked;
kg.EncryptedSections[12] := cbSection12.Checked;
kg.EncryptedSections[13] := cbSection13.Checked;
kg.EncryptedSections[14] := cbSection14.Checked;
kg.EncryptedSections[15] := cbSection15.Checked;
kg.EncryptedSections[16] := cbSection16.Checked;
dwResult := KG_GenerateRegistrationKeyFromProjectW('default.enigma', @kg);
if dwResult = EP_NO_ERROR then
begin
mKey.Text := String(PWideChar(kg.Key));
end else
begin
case dwResult of
EP_ERROR_UNKNOWN : mKey.Text := 'EP_ERROR_UNKNOWN ';
EP_ERROR_KEYBUFFEREMPTY : mKey.Text := 'EP_ERROR_KEYBUFFEREMPTY ';
EP_ERROR_KEYBUFFERISLESS : mKey.Text := 'EP_ERROR_KEYBUFFERISLESS ';
EP_ERROR_REGINFOEMPTY : mKey.Text := 'EP_ERROR_REGINFOEMPTY ';
EP_ERROR_REGINFOTOOLARGE : mKey.Text := 'EP_ERROR_REGINFOTOOLARGE ';
EP_ERROR_PRIVATEKEYISNOTSET : mKey.Text := 'EP_ERROR_PRIVATEKEYISNOTSET ';
EP_ERROR_PUBLICKEYISNOTSET : mKey.Text := 'EP_ERROR_PUBLICKEYISNOTSET ';
EP_ERROR_PRIVATEKEYISINVALID : mKey.Text := 'EP_ERROR_PRIVATEKEYISINVALID ';
EP_ERROR_PUBLICKEYISINVALID : mKey.Text := 'EP_ERROR_PUBLICKEYISINVALID ';
EP_ERROR_KEYMODEISINVALID : mKey.Text := 'EP_ERROR_KEYMODEISINVALID ';
EP_ERROR_KEYBASEISINVALID : mKey.Text := 'EP_ERROR_KEYBASEISINVALID ';
EP_ERROR_CURRENTDATEISINVALID : mKey.Text := 'EP_ERROR_CURRENTDATEISINVALID ';
EP_ERROR_EXPIRATIONDATEISINVALID : mKey.Text := 'EP_ERROR_EXPIRATIONDATEISINVALID';
EP_ERROR_KEYISINVALID : mKey.Text := 'EP_ERROR_KEYISINVALID ';
EP_ERROR_HARDWAREID : mKey.Text := 'EP_ERROR_HARDWAREID ';
EP_ERROR_HARDWAREBUFFEREMPTY : mKey.Text := 'EP_ERROR_HARDWAREBUFFEREMPTY ';
EP_ERROR_HARDWAREIDINVALIDFORKEY : mKey.Text := 'EP_ERROR_HARDWAREIDINVALIDFORKEY';
EP_ERROR_PROJECTFILENOTFOUND : mKey.Text := 'EP_ERROR_PROJECTFILENOTFOUND ';
EP_ERROR_INVALIDPROJECTFILE : mKey.Text := 'EP_ERROR_INVALIDPROJECTFILE ';
EP_ERROR_EXECUTIONSNUMBERINVALID : mKey.Text := 'EP_ERROR_EXECUTIONSNUMBERINVALID';
EP_ERROR_DAYSNUMBERINVALID : mKey.Text := 'EP_ERROR_DAYSNUMBERINVALID ';
EP_ERROR_COUNTRYCODEINVALID : mKey.Text := 'EP_ERROR_COUNTRYCODEINVALID ';
EP_ERROR_RUNTIMEINVALID : mKey.Text := 'EP_ERROR_RUNTIMEINVALID ';
EP_ERROR_GLOBALTIMEINVALID : mKey.Text := 'EP_ERROR_GLOBALTIMEINVALID ';
EP_ERROR_INSTALLBEFOREINVALID : mKey.Text := 'EP_ERROR_INSTALLBEFOREINVALID ';
EP_ERROR_INSTALLAFTERINVALID : mKey.Text := 'EP_ERROR_INSTALLAFTERINVALID ';
else mKey.Text := 'Unknown error';
end;
end;
end;
Show/Hide Visual C++ function example
void CKeygenDlg::OnBnClickedButtongenfp()
{
TODO: Add your control notification handler code here
TODO: Add your control notification handler code here
TKeyGenParamsW kp;
wchar_t keybuffer[2048];
wchar_t tmp[255];
wchar_t username[255];
wchar_t hardwareid[255];
SYSTEMTIME lpDate;
DWORD dwResult;
memset(&kp, 0, sizeof(kp));
memset(&keybuffer, 0, sizeof(keybuffer));
kp.Key = (wchar_t*) keybuffer;
kp.KeyLen = sizeof(keybuffer);
memset(&username, 0, sizeof(username));
GetDlgItemTextW(IDC_EDITNAME, (wchar_t*)&username, sizeof(username));
kp.RegInfo = (wchar_t*)&username;
if (IsDlgButtonChecked(IDC_CHECKEXPIRATION) != 0)
{
kp.UseKeyExpiration = true;
SendDlgItemMessage(IDC_DTPEXPIRATION, DTM_GETSYSTEMTIME, GDT_VALID, (LPARAM)&lpDate);
kp.ExpirationYear = lpDate.wYear;
kp.ExpirationMonth = lpDate.wMonth;
kp.ExpirationDay = lpDate.wDay;
}
if (IsDlgButtonChecked(IDC_CHECKREGAFTER) != 0)
{
kp.UseRegisterAfter = true;
SendDlgItemMessage(IDC_DTPREGAFTER, DTM_GETSYSTEMTIME, GDT_VALID, (LPARAM)&lpDate);
kp.RegisterAfterYear = lpDate.wYear;
kp.RegisterAfterMonth = lpDate.wMonth;
kp.RegisterAfterDay = lpDate.wDay;
}
if (IsDlgButtonChecked(IDC_CHECKREGBEFORE) != 0)
{
kp.UseRegisterBefore = true;
SendDlgItemMessage(IDC_DTPREGBEFORE, DTM_GETSYSTEMTIME, GDT_VALID, (LPARAM)&lpDate);
kp.RegisterBeforeYear = lpDate.wYear;
kp.RegisterBeforeMonth = lpDate.wMonth;
kp.RegisterBeforeDay = lpDate.wDay;
}
if (IsDlgButtonChecked(IDC_CHECKEXECS) != 0)
{
kp.UseExecutionsLimit = true;
memset(&tmp, 0, sizeof(tmp));
GetDlgItemTextW(IDC_EDITEXECS, (wchar_t*)&tmp, sizeof(tmp));
kp.ExecutionsCount = _wtoi((wchar_t*)&tmp);
}
if (IsDlgButtonChecked(IDC_CHECKDAYS) != 0)
{
kp.UseDaysLimit = true;
memset(&tmp, 0, sizeof(tmp));
GetDlgItemTextW(IDC_EDITDAYS, (wchar_t*)&tmp, sizeof(tmp));
kp.DaysCount = _wtoi((wchar_t*)&tmp);
}
if (IsDlgButtonChecked(IDC_CHECKRTIME) != 0)
{
kp.UseRunTimeLimit = true;
memset(&tmp, 0, sizeof(tmp));
GetDlgItemTextW(IDC_EDITRTIME, (wchar_t*)&tmp, sizeof(tmp));
kp.RunTimeMinutes = _wtoi((wchar_t*)&tmp);
}
if (IsDlgButtonChecked(IDC_CHECKGTIME) != 0)
{
kp.UseGlobalTimeLimit = true;
memset(&tmp, 0, sizeof(tmp));
GetDlgItemTextW(IDC_EDITGTIME, (wchar_t*)&tmp, sizeof(tmp));
kp.GlobalTimeMinutes = _wtoi((wchar_t*)&tmp);
}
if (IsDlgButtonChecked(IDC_CHECKCOUNTRY) != 0)
{
kp.UseCountyLimit = true;
kp.CountryCode = KEY_COUNTRIES[com_counties.GetCurSel()].Code;
}
if (IsDlgButtonChecked(IDC_CHECKHD) != 0)
{
kp.UseHardwareLocking = true;
memset(&hardwareid, 0, sizeof(hardwareid));
GetDlgItemTextW(IDC_EDITHD, (wchar_t*)&hardwareid, sizeof(hardwareid));
kp.HardwareID = (wchar_t*)&hardwareid;
}
if (IsDlgButtonChecked(IDC_CHECKS1) != 0) { kp.EncryptedSections[0] = true; }
if (IsDlgButtonChecked(IDC_CHECKS2) != 0) { kp.EncryptedSections[1] = true; }
if (IsDlgButtonChecked(IDC_CHECKS3) != 0) { kp.EncryptedSections[2] = true; }
if (IsDlgButtonChecked(IDC_CHECKS4) != 0) { kp.EncryptedSections[3] = true; }
if (IsDlgButtonChecked(IDC_CHECKS5) != 0) { kp.EncryptedSections[4] = true; }
if (IsDlgButtonChecked(IDC_CHECKS6) != 0) { kp.EncryptedSections[5] = true; }
if (IsDlgButtonChecked(IDC_CHECKS7) != 0) { kp.EncryptedSections[6] = true; }
if (IsDlgButtonChecked(IDC_CHECKS8) != 0) { kp.EncryptedSections[7] = true; }
if (IsDlgButtonChecked(IDC_CHECKS9) != 0) { kp.EncryptedSections[8] = true; }
if (IsDlgButtonChecked(IDC_CHECKS10) != 0) { kp.EncryptedSections[9] = true; }
if (IsDlgButtonChecked(IDC_CHECKS11) != 0) { kp.EncryptedSections[10] = true; }
if (IsDlgButtonChecked(IDC_CHECKS12) != 0) { kp.EncryptedSections[11] = true; }
if (IsDlgButtonChecked(IDC_CHECKS13) != 0) { kp.EncryptedSections[12] = true; }
if (IsDlgButtonChecked(IDC_CHECKS14) != 0) { kp.EncryptedSections[13] = true; }
if (IsDlgButtonChecked(IDC_CHECKS15) != 0) { kp.EncryptedSections[14] = true; }
if (IsDlgButtonChecked(IDC_CHECKS16) != 0) { kp.EncryptedSections[15] = true; }
kp.KeyWithHyphens = IsDlgButtonChecked(IDC_CHECKHYPHENS) != 0;
dwResult = KG_GenerateRegistrationKeyFromProjectW(L"default.enigma", &kp);
if (dwResult == EP_NO_ERROR)
{
SetDlgItemTextW(IDC_EDITKEY, kp.Key);
} else
{
wchar_t* sError;
switch (dwResult)
{
case EP_ERROR_UNKNOWN:
sError = L"EP_ERROR_UNKNOWN";
break;
case EP_ERROR_KEYBUFFEREMPTY:
sError = L"EP_ERROR_KEYBUFFEREMPTY";
break;
case EP_ERROR_KEYBUFFERISLESS:
sError = L"EP_ERROR_KEYBUFFERISLESS";
break;
case EP_ERROR_REGINFOEMPTY:
sError = L"EP_ERROR_REGINFOEMPTY";
break;
case EP_ERROR_REGINFOTOOLARGE:
sError = L"EP_ERROR_REGINFOTOOLARGE";
break;
case EP_ERROR_PRIVATEKEYISNOTSET:
sError = L"EP_ERROR_PRIVATEKEYISNOTSET";
break;
case EP_ERROR_PUBLICKEYISNOTSET:
sError = L"EP_ERROR_PUBLICKEYISNOTSET";
break;
case EP_ERROR_PRIVATEKEYISINVALID:
sError = L"EP_ERROR_PRIVATEKEYISINVALID";
break;
case EP_ERROR_PUBLICKEYISINVALID:
sError = L"EP_ERROR_PUBLICKEYISINVALID";
break;
case EP_ERROR_KEYMODEISINVALID:
sError = L"EP_ERROR_KEYMODEISINVALID";
break;
case EP_ERROR_KEYBASEISINVALID:
sError = L"EP_ERROR_KEYBASEISINVALID";
break;
case EP_ERROR_CURRENTDATEISINVALID:
sError = L"EP_ERROR_CURRENTDATEISINVALID";
break;
case EP_ERROR_EXPIRATIONDATEISINVALID:
sError = L"EP_ERROR_EXPIRATIONDATEISINVALID";
break;
case EP_ERROR_KEYISINVALID:
sError = L"EP_ERROR_KEYISINVALID";
break;
case EP_ERROR_HARDWAREID:
sError = L"EP_ERROR_HARDWAREID";
break;
case EP_ERROR_HARDWAREBUFFEREMPTY:
sError = L"EP_ERROR_HARDWAREBUFFEREMPTY";
break;
case EP_ERROR_HARDWAREIDINVALIDFORKEY:
sError = L"EP_ERROR_HARDWAREIDINVALIDFORKEY";
break;
case EP_ERROR_PROJECTFILENOTFOUND:
sError = L"EP_ERROR_PROJECTFILENOTFOUND";
break;
case EP_ERROR_INVALIDPROJECTFILE:
sError = L"EP_ERROR_INVALIDPROJECTFILE";
break;
case EP_ERROR_EXECUTIONSNUMBERINVALID:
sError = L"EP_ERROR_EXECUTIONSNUMBERINVALID";
break;
case EP_ERROR_DAYSNUMBERINVALID:
sError = L"EP_ERROR_DAYSNUMBERINVALID";
break;
case EP_ERROR_COUNTRYCODEINVALID:
sError = L"EP_ERROR_COUNTRYCODEINVALID";
break;
case EP_ERROR_RUNTIMEINVALID:
sError = L"EP_ERROR_RUNTIMEINVALID";
break;
case EP_ERROR_GLOBALTIMEINVALID:
sError = L"EP_ERROR_GLOBALTIMEINVALID";
break;
case EP_ERROR_INSTALLBEFOREINVALID:
sError = L"EP_ERROR_INSTALLBEFOREINVALID";
break;
case EP_ERROR_INSTALLAFTERINVALID:
sError = L"EP_ERROR_INSTALLAFTERINVALID";
break;
default:
sError = L"Unknown error";
break;
}
SetDlgItemTextW(IDC_EDITKEY, sError);
}
}
Show/Hide C# (.NET) function example
private void btnGenerateFP_Click(object sender, EventArgs e)
{
tbKey.Clear();
if (tbUserInfo.Text == string.Empty)
{
MessageBox.Show("User info field is empty!");
return;
}
Enigma_KeyGen_IDE.TKeyGenParamsW kg = new Enigma_KeyGen_IDE.TKeyGenParamsW();
kg.KeyWithHyphens = cbHyphens.Checked;
kg.Key = new string('\0', 2048);
kg.KeyLen = kg.Key.Length;
kg.RegInfo = tbUserInfo.Text;
kg.UseKeyExpiration = cbExpiration.Checked;
if (kg.UseKeyExpiration)
{
kg.ExpirationYear = dtpExpiration.Value.Year;
kg.ExpirationMonth = dtpExpiration.Value.Month;
kg.ExpirationDay = dtpExpiration.Value.Day;
}
kg.UseHardwareLocking = cbHardware.Checked;
if (kg.UseHardwareLocking)
{
kg.HardwareID = tbHardware.Text;
}
kg.UseRegisterAfter = cbRegisterAfter.Checked;
if (kg.UseRegisterAfter)
{
kg.RegisterAfterYear = dtpRegisterAfter.Value.Year;
kg.RegisterAfterMonth = dtpRegisterAfter.Value.Month;
kg.RegisterAfterDay = dtpRegisterAfter.Value.Day;
}
kg.UseRegisterBefore = cbRegisterBefore.Checked;
if (kg.UseRegisterBefore)
{
kg.RegisterBeforeYear = dtpRegisterBefore.Value.Year;
kg.RegisterBeforeMonth = dtpRegisterBefore.Value.Month;
kg.RegisterBeforeDay = dtpRegisterBefore.Value.Day;
}
kg.UseExecutionsLimit = cbExecutions.Checked;
if (kg.UseExecutionsLimit)
{
kg.ExecutionsCount = (int)udExecutions.Value;
}
kg.UseDaysLimit = cbDays.Checked;
if (kg.UseDaysLimit)
{
kg.DaysCount = (int)udDays.Value;
}
kg.UseRunTimeLimit = cbRuntime.Checked;
if (kg.UseRunTimeLimit)
{
kg.RunTimeMinutes = (int)udRuntime.Value;
}
kg.UseGlobalTimeLimit = cbGlobalTime.Checked;
if (kg.UseGlobalTimeLimit)
{
kg.GlobalTimeMinutes = (int)udGlobalTime.Value;
}
kg.UseCountyLimit = cbCountry.Checked;
if (kg.UseCountyLimit)
{
Enigma_KeyGen_IDE ide = new Enigma_KeyGen_IDE();
kg.CountryCode = ide.KEY_COUNTRIES[comCountries.SelectedIndex].Code;
}
kg.EncryptedSections = new bool[Enigma_KeyGen_IDE.NUMBER_OF_CRYPTED_SECTIONS];
kg.EncryptedSections[0] = cbSection1.Checked;
kg.EncryptedSections[1] = cbSection2.Checked;
kg.EncryptedSections[2] = cbSection3.Checked;
kg.EncryptedSections[3] = cbSection4.Checked;
kg.EncryptedSections[4] = cbSection5.Checked;
kg.EncryptedSections[5] = cbSection6.Checked;
kg.EncryptedSections[6] = cbSection7.Checked;
kg.EncryptedSections[7] = cbSection8.Checked;
kg.EncryptedSections[8] = cbSection9.Checked;
kg.EncryptedSections[9] = cbSection10.Checked;
kg.EncryptedSections[10] = cbSection11.Checked;
kg.EncryptedSections[11] = cbSection12.Checked;
kg.EncryptedSections[12] = cbSection13.Checked;
kg.EncryptedSections[13] = cbSection14.Checked;
kg.EncryptedSections[14] = cbSection15.Checked;
kg.EncryptedSections[15] = cbSection16.Checked;
uint dwResult = Enigma_KeyGen_IDE.KG_GenerateRegistrationKeyFromProjectW("default.enigma", ref kg);
if (dwResult == Enigma_KeyGen_IDE.EP_NO_ERROR)
{
tbKey.Text = kg.Key;
}
else
{
switch (dwResult)
{
case Enigma_KeyGen_IDE.EP_ERROR_UNKNOWN:
tbKey.Text = "EP_ERROR_UNKNOWN";
break;
case Enigma_KeyGen_IDE.EP_ERROR_KEYBUFFEREMPTY:
tbKey.Text = "EP_ERROR_KEYBUFFEREMPTY";
break;
case Enigma_KeyGen_IDE.EP_ERROR_KEYBUFFERISLESS:
tbKey.Text = "EP_ERROR_KEYBUFFERISLESS";
break;
case Enigma_KeyGen_IDE.EP_ERROR_REGINFOEMPTY:
tbKey.Text = "EP_ERROR_REGINFOEMPTY";
break;
case Enigma_KeyGen_IDE.EP_ERROR_REGINFOTOOLARGE:
tbKey.Text = "EP_ERROR_REGINFOTOOLARGE";
break;
case Enigma_KeyGen_IDE.EP_ERROR_PRIVATEKEYISNOTSET:
tbKey.Text = "EP_ERROR_PRIVATEKEYISNOTSET";
break;
case Enigma_KeyGen_IDE.EP_ERROR_PUBLICKEYISNOTSET:
tbKey.Text = "EP_ERROR_PUBLICKEYISNOTSET";
break;
case Enigma_KeyGen_IDE.EP_ERROR_PRIVATEKEYISINVALID:
tbKey.Text = "EP_ERROR_PRIVATEKEYISINVALID";
break;
case Enigma_KeyGen_IDE.EP_ERROR_PUBLICKEYISINVALID:
tbKey.Text = "EP_ERROR_PUBLICKEYISINVALID";
break;
case Enigma_KeyGen_IDE.EP_ERROR_KEYMODEISINVALID:
tbKey.Text = "EP_ERROR_KEYMODEISINVALID";
break;
case Enigma_KeyGen_IDE.EP_ERROR_KEYBASEISINVALID:
tbKey.Text = "EP_ERROR_KEYBASEISINVALID";
break;
case Enigma_KeyGen_IDE.EP_ERROR_CURRENTDATEISINVALID:
tbKey.Text = "EP_ERROR_CURRENTDATEISINVALID";
break;
case Enigma_KeyGen_IDE.EP_ERROR_EXPIRATIONDATEISINVALID:
tbKey.Text = "EP_ERROR_EXPIRATIONDATEISINVALID";
break;
case Enigma_KeyGen_IDE.EP_ERROR_KEYISINVALID:
tbKey.Text = "EP_ERROR_KEYISINVALID";
break;
case Enigma_KeyGen_IDE.EP_ERROR_HARDWAREID:
tbKey.Text = "EP_ERROR_HARDWAREID";
break;
case Enigma_KeyGen_IDE.EP_ERROR_HARDWAREBUFFEREMPTY:
tbKey.Text = "EP_ERROR_HARDWAREBUFFEREMPTY";
break;
case Enigma_KeyGen_IDE.EP_ERROR_HARDWAREIDINVALIDFORKEY:
tbKey.Text = "EP_ERROR_HARDWAREIDINVALIDFORKEY";
break;
case Enigma_KeyGen_IDE.EP_ERROR_PROJECTFILENOTFOUND:
tbKey.Text = "EP_ERROR_PROJECTFILENOTFOUND";
break;
case Enigma_KeyGen_IDE.EP_ERROR_INVALIDPROJECTFILE:
tbKey.Text = "EP_ERROR_INVALIDPROJECTFILE";
break;
case Enigma_KeyGen_IDE.EP_ERROR_EXECUTIONSNUMBERINVALID:
tbKey.Text = "EP_ERROR_EXECUTIONSNUMBERINVALID";
break;
case Enigma_KeyGen_IDE.EP_ERROR_DAYSNUMBERINVALID:
tbKey.Text = "EP_ERROR_DAYSNUMBERINVALID";
break;
case Enigma_KeyGen_IDE.EP_ERROR_COUNTRYCODEINVALID:
tbKey.Text = "EP_ERROR_COUNTRYCODEINVALID";
break;
case Enigma_KeyGen_IDE.EP_ERROR_RUNTIMEINVALID:
tbKey.Text = "EP_ERROR_RUNTIMEINVALID";
break;
case Enigma_KeyGen_IDE.EP_ERROR_GLOBALTIMEINVALID:
tbKey.Text = "EP_ERROR_GLOBALTIMEINVALID";
break;
case Enigma_KeyGen_IDE.EP_ERROR_INSTALLBEFOREINVALID:
tbKey.Text = "EP_ERROR_INSTALLBEFOREINVALID";
break;
case Enigma_KeyGen_IDE.EP_ERROR_INSTALLAFTERINVALID:
tbKey.Text = "EP_ERROR_INSTALLAFTERINVALID";
break;
default:
tbKey.Text = "Unknown error";
break;
}
}
}
See function examples in the installation folder, Examples\KeygenUnicode subfolder.