Pelles C forum

Pelles C => General discussions => Topic started by: A_Good_Friend on May 15, 2014, 06:24:11 AM

Title: Building custom library
Post by: A_Good_Friend 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
Title: Re: Building custom library
Post by: TimoVJL 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);
    }
}