Павел - спасибо, может выложить [URL=https://scancode.ru/download/260/]https://scancode.ru/download/260/[/URL] т.к. там есть для неё отдельный пункт и там сейчас лежит старая ... и её качают ...
[QUOTE]Павел Осинцев написал: Если все ок, то пойдет в оф. релиз.[/QUOTE] Павел, а когда будет релиз библиотеки на сайте ? P.S. т.к. пока на офф. сайте лежит (CipherLabTCP8_1_0_5_14.rar от 16.10.2019 14:40:32)
Добрый день, Павел. Да всё довольно стандартно, C# (visual studio 2019, целевая среда - .net 4.5) код без изысков почти как в вашем примере (приложение собирается под x64): [CODE][UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate System.Int32 VCallback(IntPtr lparams, IntPtr handle);
#region Библиотека Cipherlab [DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpCreate")] static extern int CipherlabtcpCreate(ref IntPtr ptrtohandle); [DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpDestroy")] static extern int CipherlabtcpDestroy(IntPtr handle); [DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpSetEventMessage")] static extern int CipherlabtcpSetEventMessage(IntPtr handle, IntPtr hwnd, int messageid, IntPtr lparam); [DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpSetEventCallback")] static extern int CipherlabtcpSetEventCallback(IntPtr handle, VCallback callbackfunc, IntPtr lparam); [DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpGetProperties")] static extern int CipherlabtcpGetProperties(IntPtr handle, out int Port, out int SaveMethod, out int Debug); [DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpSetProperties")] static extern int CipherlabtcpSetProperties(IntPtr handle, int Port, int SaveMethod, int Debug); [DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpGetLastError")] static extern int CipherlabtcpGetLastError(IntPtr handle, out int lasterror); [DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpStart")] static extern int CipherlabtcpStart(IntPtr handle); [DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpStop")] static extern int CipherlabtcpStop(IntPtr handle); [DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", CharSet = CharSet.Unicode, EntryPoint = "cipherlabtcpGetSerialNumber")] static extern int CipherlabtcpGetSerialNumber(IntPtr handle, IntPtr eventhandle, StringBuilder NumberTSD); [DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", CharSet = CharSet.Unicode, EntryPoint = "cipherlabtcpGetSerialNumberA")] static extern int CipherlabtcpGetSerialNumberA(IntPtr handle, IntPtr eventhandle, StringBuilder NumberTSD); [DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", CharSet = CharSet.Unicode, EntryPoint = "cipherlabtcpGetEvent")] static extern int CipherlabtcpGetEvent(IntPtr handle, IntPtr eventhandle, StringBuilder messagebuf); [DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", CharSet = CharSet.Unicode, EntryPoint = "cipherlabtcpGetData")] static extern int CipherlabtcpGetData(IntPtr handle, IntPtr eventhandle, out int NumberDB, out int NumberForm, StringBuilder Field1, StringBuilder Field2, StringBuilder Field3, StringBuilder Field4, StringBuilder Field5, StringBuilder Field6, StringBuilder Field7, StringBuilder Field8); [DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", CharSet = CharSet.Unicode, EntryPoint = "cipherlabtcpAnswer")] static extern int CipherlabtcpAnswer(IntPtr handle, IntPtr eventhandle, string OutField1, string OutField2, string OutField3, string OutField4, string OutField5, string OutField6, string OutField7, string OutField8, string NewRow, string NewForm); [DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", CharSet = CharSet.Unicode, EntryPoint = "cipherlabtcpSendMessage")] static extern int CipherlabtcpSendMessage(IntPtr handle, string NumberTSD, string TextOfMessage); [DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", CharSet = CharSet.Unicode, EntryPoint = "cipherlabtcpSendWarning")] static extern int CipherlabtcpSendWarning(IntPtr handle, string NumberTSD, string TextOfMessage); [DllImport("Kernel32.dll", CharSet = CharSet.Auto)] #endregion
const int WM_APP = 0x8000; const int MAXSNSIZE = 256; const int MAXFIELDSIZE = 256; readonly VCallback TSDCallBack = new VCallback(TSDCallbackFunc);
private static int TSDCallbackFunc(IntPtr lparams, IntPtr handle) { int res; StringBuilder sbsn = new StringBuilder(MAXSNSIZE); StringBuilder sbcmd = new StringBuilder(MAXSNSIZE);
res = CipherlabtcpGetEvent(m_server, handle, sbcmd); string command = sbcmd.ToString();
res = CipherlabtcpCreate(ref m_server); res = CipherlabtcpSetEventCallback(m_server, TSDCallBack, IntPtr.Zero); res = CipherlabtcpSetProperties(m_server, Global.m_port, 1, checkBoxDebug.Checked ? 1 : 0); // Вот тут крашимся на версии либы 1.0.5.14, а на 1.0.5.11 всё норм! res = CipherlabtcpStart(m_server); } [/CODE]
При использовании в проекте C# компоненты версии CipherLabTCP8_x86_64_1_0_5_11.dll - нет проблем, при использовании CipherLabTCP8_x86_64_1_0_5_14.dll - программа падает с исключением в неуправляемом коде компоненты:
[CODE]Вызвано исключение по адресу 0x00007FFE75EA1340 (cipherlabtcp8_x86_64_1_0_5_14.dll) в Logos_TSD_Gate.exe: 0xC0000005: нарушение прав доступа при чтении по адресу 0x0000000000000068.[/CODE]
Добрый день! Работаю с ТСД CipherLab 8400/8470 из своего приложения на C# через либу CipherLabTCP8_x86_64_1_0_5_11.dll и очень не хватает возможности видеть кроме SN еще и IP-адрес ТСД вызвавшего callback, например серийник получаю функцией CipherlabtcpGetSerialNumber(), а вот как быть с IP - загадка. Очень нужно. Спасибо!