NO

Author Topic: Building custom library  (Read 2300 times)

A_Good_Friend

  • Guest
Building custom library
« on: May 15, 2014, 06:24:11 AM »
Hello,

Can some one suggest me how can I build my own library in Pelles C which can be used in dotnet projects later.

Regards

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Building custom library
« Reply #1 on: May 15, 2014, 11:39:21 AM »
Code: [Select]
// TestDll.c
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
// compile with compiler option -Gn
BOOL WINAPI DllMain(HANDLE hInstDLL, DWORD dwReason, LPVOID lpvReserved)
{
return TRUE;
}

__declspec(dllexport)
int __stdcall SampleFunction(int a, int b)
{
MessageBox(0, "SampleFunction", "TestDLL", MB_OK);
return a * b;
}
Code: [Select]
using System;
using System.Runtime.InteropServices;

class MessageBoxTest
{
    [DllImport("TestDll.dll")]
    static extern int SampleFunction(int a, int b);

    public static void Main()
    {
        int nReturnValue = SampleFunction(1, 2);
    }
}
May the source be with you