Write a Delphi XE5 interface based on c# code to talk to an C DLL from Delphi
Budget: $30 – $250 USD
Dear Delphi programmers,
We are looking for a skilled Delphi programmer with good C++ C# knowledge able to create an interface header for a C++ DLL that will be used by our Delphi application.
Testing can’t be outsourced since the DLL is controlling a Hardware device.
The DLL Exports 88 functions
What we have:
the code c# class to call the functions of the DLL
the compiled DLL
C Source of the DLL is not available
And What th c# code looks like:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
namespace sbxpc
{
class SBXPCDLL
{
[DllImport("SBXPCDLL.dll", CallingConvention = CallingConvention.Winapi)]
static extern void _DotNET();
public static void DotNET()
{
_DotNET();
}
[DllImport("SBXPCDLL.dll", CallingConvention = CallingConvention.Winapi)]
static extern byte _EnableDevice(Int32 dwMachineNumber, byte bFlag);
public static bool EnableDevice(Int32 dwMachineNumber, byte bFlag)
{
return _EnableDevice(dwMachineNumber, bFlag) > 0;
}
#region Not Tested Part 1
[DllImport("SBXPCDLL.dll", CallingConvention = CallingConvention.Winapi)]
static extern byte _SetMachineType(Int32 dwMachineNumber, ref IntPtr lpszMachineType);
public static bool _SetMachineType(Int32 dwMachineNumber, string lpszMachineType)
{
IntPtr string_in = Marshal.StringToBSTR(lpszMachineType);
try
{
return _SetMachineType(dwMachineNumber, ref string_in) > 0;
}
catch (Exception)
{
return false;
}
finally
{
Marshal.FreeBSTR(string_in);
}
}
[DllImport("SBXPCDLL.dll", CallingConvention = CallingConvention.Winapi)]
static extern byte _GetEnrollData(Int32 dwMachineNumber,Int32 dwEnrollNumber,Int32 dwEMachineNumber,Int32 dwBackupNumber, IntPtr dwMachinePrivilege, ref IntPtr dwEnrollData, IntPtr dwPassWord);
public static bool GetEnrollData(Int32 dwMachineNumber, Int32 dwEnrollNumber, Int32 dwEMachineNumber, Int32 dwBackupNumber, out Int32 dwMachinePrivilege, byte[] dwEnrollData, out Int32 dwPassWord)
{
dwMachinePrivilege = 0;
dwPassWord = 0;
byte[] privilege = new byte[4];
byte[] password = new byte[4];
GCHandle gh_privilege = GCHandle.Alloc(privilege, GCHandleType.Pinned);
GCHandle gh_password = GCHandle.Alloc(password, GCHandleType.Pinned);
GCHandle gh_enroll_data = GCHandle.Alloc(dwEnrollData, GCHandleType.Pinned);
try
{
We are looking for a skilled Delphi programmer with good C++ C# knowledge able to create an interface header for a C++ DLL that will be used by our Delphi application.
Testing can’t be outsourced since the DLL is controlling a Hardware device.
The DLL Exports 88 functions
What we have:
the code c# class to call the functions of the DLL
the compiled DLL
C Source of the DLL is not available
And What th c# code looks like:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
namespace sbxpc
{
class SBXPCDLL
{
[DllImport("SBXPCDLL.dll", CallingConvention = CallingConvention.Winapi)]
static extern void _DotNET();
public static void DotNET()
{
_DotNET();
}
[DllImport("SBXPCDLL.dll", CallingConvention = CallingConvention.Winapi)]
static extern byte _EnableDevice(Int32 dwMachineNumber, byte bFlag);
public static bool EnableDevice(Int32 dwMachineNumber, byte bFlag)
{
return _EnableDevice(dwMachineNumber, bFlag) > 0;
}
#region Not Tested Part 1
[DllImport("SBXPCDLL.dll", CallingConvention = CallingConvention.Winapi)]
static extern byte _SetMachineType(Int32 dwMachineNumber, ref IntPtr lpszMachineType);
public static bool _SetMachineType(Int32 dwMachineNumber, string lpszMachineType)
{
IntPtr string_in = Marshal.StringToBSTR(lpszMachineType);
try
{
return _SetMachineType(dwMachineNumber, ref string_in) > 0;
}
catch (Exception)
{
return false;
}
finally
{
Marshal.FreeBSTR(string_in);
}
}
[DllImport("SBXPCDLL.dll", CallingConvention = CallingConvention.Winapi)]
static extern byte _GetEnrollData(Int32 dwMachineNumber,Int32 dwEnrollNumber,Int32 dwEMachineNumber,Int32 dwBackupNumber, IntPtr dwMachinePrivilege, ref IntPtr dwEnrollData, IntPtr dwPassWord);
public static bool GetEnrollData(Int32 dwMachineNumber, Int32 dwEnrollNumber, Int32 dwEMachineNumber, Int32 dwBackupNumber, out Int32 dwMachinePrivilege, byte[] dwEnrollData, out Int32 dwPassWord)
{
dwMachinePrivilege = 0;
dwPassWord = 0;
byte[] privilege = new byte[4];
byte[] password = new byte[4];
GCHandle gh_privilege = GCHandle.Alloc(privilege, GCHandleType.Pinned);
GCHandle gh_password = GCHandle.Alloc(password, GCHandleType.Pinned);
GCHandle gh_enroll_data = GCHandle.Alloc(dwEnrollData, GCHandleType.Pinned);
try
{