Kopiuj
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct tPRINTER_STATUS
{
public bool ONL;
public bool PE;
public bool ERR;
}
[DllImport("ThermalServiceLibrary.dll", EntryPoint = "Port_Open", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern int OpenPort(StringBuilder port, long speed);
[DllImport("ThermalServiceLibrary.dll", EntryPoint = "GetStatus_Printer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
unsafe public static extern int SendBel(ref tPRINTER_STATUS del);
[DllImport("ThermalServiceLibrary.dll", EntryPoint = "LBFEED", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
unsafe public static extern int SendFEEd(int feed);
[DllImport("ThermalServiceLibrary.dll", EntryPoint = "LBSERM", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern string SendSer();
static void Main(string[] args)
{
Console.WriteLine("Podaj numer portu:");
ConsoleKeyInfo info = Console.ReadKey();
tPRINTER_STATUS emp = new tPRINTER_STATUS();
int r = OpenPort(new StringBuilder("COM"+ info.KeyChar), 9600);
Console.WriteLine(r);
SendFEEd(20);
SendBel(ref emp);
Console.WriteLine(emp.ONL);
Console.WriteLine(emp.ERR);
Console.WriteLine(emp.PE);
Console.ReadKey();
}
}
}
Mam taki kod jak powyżej i chcę dorobić wystawianie paragonu tylko nie wiem jak zaimportować z dll funkcję
Kopiuj
typedef int ( *tTYPE_TRANSL_FUNC )( LPVOID, char * );
typedef struct
{
tTYPE_TRANSL_FUNC TypeTranslFuncPtr;
LPVOID ParamValuePtr;
} tEXTERNAL_NUMERIC;
typedef struct
{
BYTE Pi;
BYTE Pr;
char * Name;
tEXTERNAL_NUMERIC Quantity;
char Vat;
tEXTERNAL_NUMERIC Price;
tEXTERNAL_NUMERIC Gross;
tEXTERNAL_NUMERIC Discount;
} tLBTRSLN_PARAMS;
int LBTRSLN(
tLBTRSLN_PARAMS * aLBTRSLN_ParamsPtr
);
Jak to przenieść na C# ? Głównie mi chodzi o tEXTERNAL_NUMERIC oraz tLBTRSLN_PARAMS.