I know that there are many solutions for my problem. I have tried them all; however, I still get error.
These are original functions from DLL 'KeygenLibrary.dll' :
bool dfcDecodeMachineID(char* sEncodeMachineID, int iInLen, char* sMachineID, int& iOutLen);
bool dfcCreateLicense(char* sMachineID, int iLen, char* sLicenseFilePath);
To import this DLL, I have tried:
Way 1:
unsafe public class ImportDLL
{
[DllImport("KeygenLibrary.dll", EntryPoint = "dfcDecodeMachineID")]
unsafe public static extern bool dfcDecodeMachineID(char* sEncodeMachineID, int iInLen, char* sMachineID, ref int iOutLen);
[DllImport("KeygenLibrary.dll", EntryPoint = "dfcCreateLicense")]
unsafe public static extern bool dfcCreateLicense(char* sMachineID, int iLen, char* sLicenseFilePath);
}
Way 2:
public class ImportDLL
{
[DllImport("KeygenLibrary.dll", EntryPoint = "dfcDecodeMachineID")]
public static extern bool dfcDecodeMachineID([MarshalAs(UnmanagedType.LPStr)] string sEncodeMachineID, int iInLen, [MarshalAs(UnmanagedType.LPStr)] string sMachineID, ref int iOutLen);
[DllImport("KeygenLibrary.dll", EntryPoint = "dfcCreateLicense")]
public static extern bool dfcCreateLicense([MarshalAs(UnmanagedType.LPStr)] string sMachineID, int iLen, [MarshalAs(UnmanagedType.LPStr)] string sLicenseFilePath);
}
However, both above ways give me error:
Unable to find an entry point named 'function name' in DLL 'KeygenLibrary.dll'.
How can I fix my problem? Thanks a lot.