Posts

Showing posts from March, 2010

Calling unmanaged DLL in C#.NET

I have a project that created a DLL but somehow I wanted to know if the current DLL I have is the same with the project. So, I created a form project in C# and calling the function. Sample below: using System.Windows.Forms; using System.Runtime.InteropServices; // DllImport namespace DLLTester {   public partial class Form1 : Form {  public Form1( ) {    InitializeComponent(); }   private void button1_Click( object sender, EventArgs e )  {      MessageBox.Show(WrapperClassOfDLL .EnableDevice().ToString());  } } public class WrapperClassOfDLL { [DllImport("MyUnmanagedDLL.dll")] public static extern UInt32 GetVersion( ); } } Put the DLL in the project directory and make sure the function signature is the same in the DLL. That's it!

Digital Logic

I created a project named Digital Logic. Digital Logic can create any logic gates you want. You can use the Base namespace to create your own customized gates or inherit the ones I already implemented in Base.Gates namespace. For now, only a few gates were implemented but I will add more in the coming days. First, you'll need to have the DigitalLogic.cab. Extract the DLLs and save it in your working folder. Add the DLLs into your project references. Sample code: int main() {    AND andGate = new AND();   andGate.Input(1, true);   andGate.Input(2, false);   if(andGate.Output == false) MessageBox("Correct");   else MessageBox("Wrong");   return ; } You can download the files here Digital Logic Enjoy!