EP_RegLoadKeyEx
EP_RegLoadKeyEx function serves for reading of the registration information (name and key). This function should be used instead of deprecated EP_RegLoadKey. The place and path where the registration information will be stored should be defined in REGISTRATION FEATURES - Registration data storing panel.
Parameters
- Name - pointer to the buffer that receives registration name. If the UNICODE Registration Scheme is used in REGISTRATION FEATURES - Common panel then Name buffer contains unicode string otherwise ansi string (without null terminator)
- NameLen - receives a size in bytes of the Name buffer. Returns the required or passed to Name buffer number of bytes
- Key - pointer to the buffer that receives registration key. If the UNICODE Registration Scheme is used in REGISTRATION FEATURES - Common panel then Key buffer contains unicode string otherwise ansi string (without null terminator)
- KeyLen - receives a size in bytes of the Key buffer. Returns the required or passed to Key buffer number of bytes
Return Value
The function returns one of the following values:
Value |
Description |
LOADKEY_SUCCEEDED = 0; |
Registration information loaded successfully |
LOADKEY_REGINFONOTFOUND = 1; |
Registration information is not found |
LOADKEY_NAMEBUFFERTOOSMALL = 2; |
Buffer for registration name is too small |
LOADKEY_KEYBUFFERTOOSMALL = 3; |
Buffer for registration key is too small |
Remark
The function just reads the registration information, it does not verify key validation. To make sure you have the correct pair of registration name/key, you must manually check the key validatation by means of EP_RegCheckKey, or use the combine function EP_RegLoadAndCheckKey.
Definition
Show/Hide Delphi function definition
function EP_RegLoadKeyEx(Name : pointer; var NameLen : Cardinal; Key : pointer; var KeyLen : Cardinal) : Cardinal; stdcall;
Show/Hide C# (.NET) function definition
public class Enigma_IDE
{
[DllImport("enigma_ide.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int EP_RegLoadKeyEx(IntPtr Name, ref int NameLen, IntPtr Key, ref int KeyLen);
}
Show/Hide C++ function definition
extern "C" __declspec( dllimport ) __stdcall int EP_RegLoadKeyEx( char* Name, int* NameLen, char* Key, int* KeyLen);
Examples
Show/Hide Delphi function example
uses
enigma_ide;
function EP_RegistrationLoadKeyA(var Name, Key : AnsiString) : boolean;
var
namelen, keylen : Cardinal;
namebuf, keybuf : pointer;
begin
Result := false;
namelen := 0;
keylen := 0;
if EP_RegLoadKeyEx(nil, namelen, nil, keylen) <> LOADKEY_REGINFONOTFOUND then
begin
GetMem(namebuf, namelen);
try
GetMem(keybuf, keylen);
try
if EP_RegLoadKeyEx(namebuf, namelen, keybuf, keylen) = LOADKEY_SUCCEEDED then
begin
SetString(Name, PAnsiChar(namebuf), namelen);
SetString(Key, PAnsiChar(keybuf), keylen);
Result := true;
end;
finally
FreeMem(keybuf);
end;
finally
FreeMem(namebuf);
end;
end;
end;
function EP_RegistrationLoadKeyW(var Name, Key : WideString) : boolean;
var
namelen, keylen : Cardinal;
namebuf, keybuf : pointer;
begin
Result := false;
namelen := 0;
keylen := 0;
if EP_RegLoadKeyEx(nil, namelen, nil, keylen) <> LOADKEY_REGINFONOTFOUND then
begin
GetMem(namebuf, namelen);
try
GetMem(keybuf, keylen);
try
if EP_RegLoadKeyEx(namebuf, namelen, keybuf, keylen) = LOADKEY_SUCCEEDED then
begin
SetString(Name, PWideChar(namebuf), namelen shr 1);
SetString(Key, PWideChar(keybuf), keylen shr 1);
Result := true;
end;
finally
FreeMem(keybuf);
end;
finally
FreeMem(namebuf);
end;
end;
end;
Show/Hide C# function example
public class Enigma_IDE
{
public static bool EP_RegistrationLoadKeyA(out string Name, out string Key)
{
Name = Key = string.Empty;
int namelen = 0, keylen = 0;
if (EP_RegLoadKeyEx(IntPtr.Zero, ref namelen, IntPtr.Zero, ref keylen) != LOADKEY_REGINFONOTFOUND)
{
byte[] namebuf = new byte[namelen];
byte[] keybuf = new byte[keylen];
if (EP_RegLoadKeyEx(Marshal.UnsafeAddrOfPinnedArrayElement(namebuf, 0), ref namelen, Marshal.UnsafeAddrOfPinnedArrayElement(keybuf, 0), ref keylen) == LOADKEY_SUCCEEDED)
{
Name = Encoding.ASCII.GetString(namebuf);
Key = Encoding.ASCII.GetString(keybuf);
return true;
}
}
return false;
}
public static bool EP_RegistrationLoadKeyW(out string Name, out string Key)
{
Name = Key = string.Empty;
int namelen = 0, keylen = 0;
if (EP_RegLoadKeyEx(IntPtr.Zero, ref namelen, IntPtr.Zero, ref keylen) != LOADKEY_REGINFONOTFOUND)
{
byte[] namebuf = new byte[namelen];
byte[] keybuf = new byte[keylen];
if (EP_RegLoadKeyEx(Marshal.UnsafeAddrOfPinnedArrayElement(namebuf, 0), ref namelen, Marshal.UnsafeAddrOfPinnedArrayElement(keybuf, 0), ref keylen) == LOADKEY_SUCCEEDED)
{
Name = Encoding.Unicode.GetString(namebuf);
Key = Encoding.Unicode.GetString(keybuf);
return true;
}
}
return false;
}
}
See function examples in the installation folder, Examples subfolder.