refactor: move dll loading into c# client
This commit is contained in:
@@ -1,12 +1,27 @@
|
||||
using System.IO;
|
||||
using System.IO.Pipes;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
|
||||
internal class Program
|
||||
{
|
||||
[DllImport("kernel32.dll", EntryPoint = "LoadLibrary", SetLastError = true)]
|
||||
static extern int LoadLibrary([MarshalAs(UnmanagedType.LPStr)] string lpLibFileName);
|
||||
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
int hDll = LoadLibrary("L2BotDll.dll");
|
||||
|
||||
if (hDll == 0)
|
||||
{
|
||||
Console.WriteLine("Unable to load library L2BotDll.dll: " + Marshal.GetLastWin32Error().ToString());
|
||||
Console.ReadLine();
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine("L2BotDll.dll loaded\n");
|
||||
|
||||
while (true)
|
||||
{
|
||||
var clientPipe = new NamedPipeClientStream("PipeL2Bot");
|
||||
@@ -27,7 +42,7 @@ internal class Program
|
||||
mainPipe.Connect();
|
||||
mainPipe.ReadMode = PipeTransmissionMode.Message;
|
||||
|
||||
Console.WriteLine("Connected to main pipe");
|
||||
Console.WriteLine("Connected to main pipe\n");
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -41,8 +56,8 @@ internal class Program
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Disconnected from main pipe");
|
||||
Console.WriteLine("Disconnected from connection pipe");
|
||||
Console.WriteLine("\nDisconnected from main pipe");
|
||||
Console.WriteLine("Disconnected from connection pipe\n\n");
|
||||
|
||||
mainPipe.Close();
|
||||
mainPipe.Dispose();
|
||||
|
@@ -5,6 +5,7 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
Reference in New Issue
Block a user