Advertisement
kijato

Try Sentinel SuperPro API Functions (call from DLL)

May 12th, 2020
1,156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.79 KB | None | 0 0
  1. /*
  2. set PATH=c:\Windows\Microsoft.NET\Framework64\v4.0.30319;%PATH%
  3. cls && csc.exe -debug- -target:exe -platform:x64 sx32w.cs && sx32w.exe
  4. */
  5.  
  6. using System;
  7. using System.IO;
  8. using System.Runtime.InteropServices; // ez a névtér szükséges a DLL-ek miatt
  9.  
  10. public class API
  11. {
  12.     [DllImport("user32.dll")]
  13.     public static extern int MessageBox(int hWnd, string text, string caption, uint type);
  14. }
  15.  
  16. public class SPro
  17. {
  18.     public static uint SPRO_APIPACKET_SIZE = 1028;
  19.     public byte[] packet;
  20.    
  21.     [DllImport("sx32w.dll", CharSet=CharSet.Ansi, EntryPoint="RNBOsproFormatPacket")]
  22.         public static extern ushort RNBOsproFormatPacket(byte[] packet, uint packetSize );
  23.     [DllImport("sx32w.dll", CharSet=CharSet.Ansi, EntryPoint="RNBOsproInitialize")]
  24.         public static extern ushort RNBOsproInitialize(byte[] packet);
  25.     [DllImport("sx32w.dll", CharSet=CharSet.Ansi, EntryPoint="RNBOsproFindFirstUnit")]
  26.         public static extern ushort RNBOsproFindFirstUnit(byte[] packet, ushort developerID);
  27. }
  28.  
  29. namespace TryRNBO
  30. {
  31.     class TryRNBO
  32.     {
  33.         public static SPro oSPro;
  34.        
  35.         static void Main(string[] args)
  36.         {
  37.  
  38.             API.MessageBox(0, "Try it!", "MessageBox...", 0);
  39.            
  40.             try
  41.             {
  42.                 uint status = 0;  
  43.                 oSPro = new SPro();
  44.                 status = SPro.RNBOsproFormatPacket(oSPro.packet,SPro.SPRO_APIPACKET_SIZE);
  45.                 if (status != 0)
  46.                 {
  47.                     API.MessageBox(0, "FormatPacket: ok", "MessageBox...", 0);
  48.                 }
  49.                 else
  50.                 {
  51.                     API.MessageBox(0, "FormatPacket: isn't ok", "MessageBox...", 0);
  52.                 }
  53.             }
  54.             catch (Exception e)
  55.             {
  56.                 Console.WriteLine(e.Message);
  57.             }
  58.            
  59.             Console.WriteLine("Press any key to exit.");
  60.             Console.ReadKey();
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement