PB DLLs in C# (C.NET, Visual C# Express 2005, and such)
Posted: Sat Dec 23, 2006 3:30 am
Whoah, it's been so long since I stepped here 
Anyways, I've been programming in C# now, but because I use PureBASIC for some of my functions that I can't translate to C# still, I figured someone could be interested in running their PB DLLs in C#, so here it goes:
MyDLL.pb:
Program.cs (Create a Console Application)
There, nice string return functions. You can do the same for returning ints, simply change ProcedureReturn Ansi2Uni("This is a test") by, for example, ProcedureReturn 123456
Yay

Anyways, I've been programming in C# now, but because I use PureBASIC for some of my functions that I can't translate to C# still, I figured someone could be interested in running their PB DLLs in C#, so here it goes:
MyDLL.pb:
Code: Select all
ProcedureDLL show_message()
ProcedureReturn Ansi2Uni("This is a test")
EndProcedure
Code: Select all
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading;
using System.Text;
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
[STAThread]
[DllImport("MyDLL.dll", CharSet = CharSet.Auto)]
public static extern string show_message();
static void Main(string[] args)
{
Console.WriteLine(show_message());
Console.ReadLine();
}
}
}
Yay
