Welcome! Log In Create A New Profile

Advanced

Including a C DLL in a windev project

Posted by gdelucce.pcs.crosspost 
gdelucce.pcs.crosspost
Including a C DLL in a windev project
May 18, 2009 12:21PM
Hi everyone,
I am trying to include some C code written in Visual C++ 6 in my WinDev 12 project. I suppose I have to create a DLL from this code in order to embed it in WD. But it is not clear to me how I can include it in my project, I read the help but am still a little confused. Could I use CallDLL32 to use the functions in the DLL? or must I use the Automation functions? Can someone please post a step-by-step guide on how to include my custom C code in WinDev? thanks!!

Message forwarded from pcsoft.us.windev
noprop at all u can do :

F.I.

//Testdll.h the Header file
#ifdef TESTDLL_EXPORTS
#define WDEXPORT extern "C" __declspec(dllexport)
#else
#define WDEXPORT  extern "C" __declspec(dllimport)
#endif


// define your exported functions
WDEXPORT int fntestdll(void);
WDEXPORT void fninc(int* intptr);

// Testdll.cpp
#include "stdafx.h"
#include "testdll.h"


BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
		break;
	}
    return TRUE;
}


// This is an example of exported functions.
WDEXPORT int fntestdll(void)
{
	return 42; // what else smiling smiley
}
WDEXPORT void fninc(int* intptr)
{
	++*intptr;
}


//WINDEV 
res is int = API("TestDLL", "fntestdll")

//or
res is int = 100
API("TestDLL", "fninc", &res)
Trace(res) // 101

3 hints :
add WDEXPORT to the function you wanna access from WD.
pass structures as references use : &,
be very carefule in case that you find char* !!!
HTH
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: