· 5 years ago · May 12, 2020, 07:30 AM
1using System;
2using System.IO;
3using System.Runtime.InteropServices; // ez a névtér szükséges a DLL-ek miatt
4
5public class API
6{
7 [DllImport("user32.dll")]
8 public static extern int MessageBox(int hWnd, string text, string caption, uint type);
9}
10
11public class SPro
12{
13 public static uint SPRO_APIPACKET_SIZE = 1028;
14 public byte[] packet;
15
16 [DllImport("sx32w.dll", CharSet=CharSet.Ansi, EntryPoint="RNBOsproFormatPacket")]
17 public static extern ushort RNBOsproFormatPacket(byte[] packet, uint packetSize );
18 [DllImport("sx32w.dll", CharSet=CharSet.Ansi, EntryPoint="RNBOsproInitialize")]
19 public static extern ushort RNBOsproInitialize(byte[] packet);
20 [DllImport("sx32w.dll", CharSet=CharSet.Ansi, EntryPoint="RNBOsproFindFirstUnit")]
21 public static extern ushort RNBOsproFindFirstUnit(byte[] packet, ushort developerID);
22}
23
24namespace TryRNBO
25{
26 class TryRNBO
27 {
28 public static SPro oSPro;
29
30 static void Main(string[] args)
31 {
32
33 API.MessageBox(0, "Try it!", "MessageBox...", 0);
34
35 try
36 {
37 uint status = 0;
38 oSPro = new SPro();
39 status = SPro.RNBOsproFormatPacket(oSPro.packet,SPro.SPRO_APIPACKET_SIZE);
40 if (status != 0)
41 {
42 API.MessageBox(0, "FormatPacket: ok", "MessageBox...", 0);
43 }
44 else
45 {
46 API.MessageBox(0, "FormatPacket: isn't ok", "MessageBox...", 0);
47 }
48 }
49 catch (Exception e)
50 {
51 Console.WriteLine(e.Message);
52 }
53
54 Console.WriteLine("Press any key to exit.");
55 Console.ReadKey();
56 }
57 }
58}