Tuesday, November 1, 2011

How to create Dll and How to call dll function

/**********************************************************************************
* Exe.c
*
* Created on: Oct 12, 2011
*
**********************************************************************************/

# include <stdio.h>
# include <stdlib.h>
# include <windows.h>

int main()
{
//To Load the Dll files
HINSTANCE CallDll=NULL;
FARPROC FunctionLoad;
CallDll = LoadLibrary("D:\\WorkSpace\\DLL_File_Creation\\Debug\\libDLL_File_Creation.dll");
FunctionLoad =GetProcAddress(CallDll,"FirstCallFunction");

FunctionLoad();

FreeLibrary(CallDll);
return 0;
}

/**********************************************************************************
* DLL_File_Creation.c
*
* Created on: Oct 12, 2011
*
**********************************************************************************/

# include <stdio.h>
# include <stdlib.h>
# include <windows.h>

int FirstCallFunction();
/*
* This Function is used to understand the Dll calling process.
*/
int FirstCallFunction()
{

printf("I am in Dll First Call Function \n");
MessageBox(0,"Information","I am in Dll First Call Function ",2);

return 0;
}