It's good to back in the Windows Programming forum. I read a couple of tutorials about creating a DLL in C and it all looks to me as template at this point. Following my question about calling an application from another, found here http://www.cplusplus.com/forum/general/77570/, I would be grateful if someone would tell me whether this would successfully work or not, I'm using gcc
#include "main.h"
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// attach to process
// return FALSE to fail DLL load
break;
case DLL_PROCESS_DETACH:
// detach from process
break;
case DLL_THREAD_ATTACH:
// attach to thread
break;
case DLL_THREAD_DETACH:
// detach from thread
break;
}
return TRUE; // succesful
}
main.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#ifndef __MAIN_H__
#define __MAIN_H__
#include <windows.h>
#include "h1.h"
#ifdef BUILD_DLL
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif
void DLL_EXPORT perff(double * pd)
{
// function code goes here | uses functions defined in h1.h
}
#endif // __MAIN_H__
i'm sorry for this, it's not an reply.i'm just a newbie to cpp programming can u please tell how and where do you program the .DLL files and how to use them in a live program.
please ignore the reply if it seems violating the forum rules but please don't ban me.
Thanking you in advance.
@ ankit2313: Please make your own thread, it makes it easier for people with similar questions to find it. Have you tried looking it up on Google? Are you stuck at some particular point? What do you want the DLL to do?
I wrap extern "C" around void DLL_EXPORT perff(double * pd) in main.h and around BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) in main.c?
I can jam whatever I want in the .c file right, i.e. whatever functions or variables perff() uses can go in main.c too, there's no harm in doing that?