using System;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
namespace PACNET
{
/// Registry API
public class PAC_Reg
{
/// NONE
public const int PKT_NONE = 0;
/// KEY
public const int PKT_KEY = 1;
/// STRING
public const int PKT_STRING = 2;
/// DWORD
public const int PKT_DWORD = 3;
//7.1. PAC_API DWORD pac_RegCountKey(LPCTSTR KeyName)
///
/// This function retrieves the specified registry key which has how many sub keys.
///
/// [in] Specific the path of registry key which you want to count.
/// Return the number of subkeys contained by the specified key.
[DllImport("PACSDK.dll", EntryPoint = "pac_RegCountKey")]
public static extern uint RegCountKey(string KeyName);
//7.2. PAC_API DWORD pac_RegCountValue(LPCTSTR KeyName)
///
/// This function retrieves the specified registry key which has how many values.
///
/// [in] Specific the path of registry key which you want to count.
/// Return the number of values associated with the key.
[DllImport("PACSDK.dll", EntryPoint = "pac_RegCountValue")]
public static extern uint RegCountValue(string KeyName);
//7.3. PAC_API bool pac_RegCreateKey(LPCTSTR KeyName)
///
/// This function creates the specified registry key.
///
/// [in] Specific the path of registry key which you want to create.
/// Return true if success, otherwise false.
[DllImport("PACSDK.dll", EntryPoint = "pac_RegCreateKey")]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool RegCreateKey(string KeyName);
//7.4. PAC_API bool pac_RegDeleteKey(LPCTSTR KeyName)
///
/// This function deletes a named subkey from the specified registry key.
///
/// [in] Specifics the path of registry key which you want to delete.
/// Return true if success, otherwise false.
[DllImport("PACSDK.dll", EntryPoint = "pac_RegDeleteKey")]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool RegDeleteKey(string KeyName);
//7.5. PAC_API bool pac_RegDeleteValue(LPCTSTR KeyName)
///
/// This function removes a named value from the specified registry key.
///
/// [in] Specifics the path of registry key which you want to delete.
/// Return true if success, otherwise false.
[DllImport("PACSDK.dll", EntryPoint = "pac_RegDeleteValue")]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool RegDeleteValue(string KeyName);
//7.6. PAC_API DWORD pac_RegGetDWORD(LPCTSTR KeyName)
///
/// This function retrieves value of the specified registry key.
///
/// [in] Specific the path of registry key.
/// Return the value of the specific key.
[DllImport("PACSDK.dll", EntryPoint = "pac_RegGetDWORD")]
public static extern uint RegGetDWORD(string KeyName);
//7.7. PAC_API bool pac_RegGetKeyByIndex(LPCTSTR KeyName, DWORD dwIndex, LPTSTR lpName)
///
/// This function retrieves the name of specified index of registry key.
///
/// [in] Specific the path of registry key.
/// [in] Specific the index of registry key.
/// [out] Assign a buffer to retrieves the specific the key name.
/// Return true if success, otherwise false.
[DllImport("PACSDK.dll", EntryPoint = "pac_RegGetKeyByIndex")]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool RegGetKeyByIndex(string KeyName, uint dwIndex, string lpName);
//7.8. PAC_API DWORD pac_RegGetKeyInfo(LPCTSTR KeyName)
///
/// This function retrieves the type of specified index of registry key.
///
/// [in] Specific the path of registry key.
/// We define four types about the return value:
/// 0: PKT_NONE, 1: PKT_KEY, 2: PKT_STRING, 3: PKT_DWORD
[DllImport("PACSDK.dll", EntryPoint = "pac_RegGetKeyInfo")]
public static extern uint RegGetKeyInfo(string KeyName);
//7.9. PAC_API bool pac_RegGetString(LPCTSTR KeyName, LPTSTR lpData, DWORD dwLength)
///
/// This function retrieves value of the specified registry key.
///
/// [in] Specific the path of registry key.
/// [out] Pointer to a buffer that receives the value's data.
/// [in] Specific the size of data.
/// Return true if success, otherwise false.
[DllImport("PACSDK.dll", EntryPoint = "pac_RegGetString")]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool RegGetString(string KeyName, string lpData, uint dwLength);
//7.10. PAC_API bool pac_RegGetValueByIndex(LPCTSTR KeyName, DWORD dwIndex, LPTSTR lpName)
///
/// This function retrieves the value of specified index of registry key.
///
/// [in] Specific the path of registry key.
/// [in] Specific the index of value.
/// [out] Pointer to a buffer that receives the value's data.
/// Return true if success, otherwise false.
[DllImport("PACSDK.dll", EntryPoint = "pac_RegGetValueByIndex")]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool RegGetValueByIndex(string KeyName, uint dwIndex, string lpName);
//7.11. PAC_API bool pac_RegKeyExist(LPCTSTR KeyName)
///
/// This function determinants the specified registry key exist or not.
///
/// [in] Specific the path of registry key which you want to check whether it exists or not.
/// Return true if success, otherwise false.
[DllImport("PACSDK.dll", EntryPoint = "pac_RegKeyExist")]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool RegKeyExist(string KeyName);
//7.12. PAC_API bool pac_RegSave(LPCTSTR KeyName)
///
/// This function writes all the attributes of the specified open registry key into the registry.
///
/// [in] Handle to a currently open key or one of the following predefined reserved handle
/// values:
/// Return true if success, otherwise false.
[DllImport("PACSDK.dll", EntryPoint = "pac_RegSave")]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool RegSave(string KeyName);
//7.13. PAC_API bool pac_RegSetString(LPCTSTR KeyName, LPCTSTR assignStr, DWORD dwLength)
///
/// This function assigns the specified registry key data whose type is string.
///
/// [in] Specific the path of registry key which you want to assign data.
/// [in] Specific the data.
/// [in] Specific the size of data.
/// Return true if success, otherwise false.
[DllImport("PACSDK.dll", EntryPoint = "pac_RegSetString")]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool RegSetString(string KeyName, string assignStr, uint dwLength);
//7.14. PAC_API bool pac_RegSetDWORD(LPCTSTR KeyName, DWORD assignVal)
///
/// This function assigns the specified registry key data whose type is DWORD.
///
/// [in] Specific the path of registry key which you want to assign data.
/// [in] Specific the data.
/// Return true if success, otherwise false.
[DllImport("PACSDK.dll", EntryPoint = "pac_RegSetDWORD")]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool RegSetDWORD(string KeyName, uint assignStr);
}
}