Hi all,

Can any one please help me how to call an function from dll in vc++.

// test1.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include "windows.h"
#include "conio.h"
#include "windef.h"

int _tmain(int argc, _TCHAR* argv[])
	HINSTANCE instcall=LoadLibrary(TEXT("c:\\test2.dll"));
	printf("Failed to load dll");
	FARPROC getproc=GetProcAddress(instcall,"funcall");
	printf("failed entry point");
	typedef int(__stdcall * picFunc)();
	picFunc funcall;
//LPTSTR path=(LPTSTR)"c:\test2.dll";
	DWORD threadId=dwThredId*/
/*typedef void *(_stdcall *creatfn)();
	creatfn myfunc=(creatfn) GetProcAddress(instcall,"call");
	void *objptr=myfunc();*/

	/*picFunc funcall;*/

I have this code in the main file
the dll file code is below

// test2.cpp : Defines the exported functions for the DLL application.

#include "stdafx.h"
#include "stdio.h"
#include "conio.h"

 void funcall()

When i execute i get this exception Unhandled exception at 0x00000000 in test1.exe: 0xC0000005: Access violation reading location 0x00000000.

Can any one please help me out in solving this problem. I am using Visual studio 2008 as compiler

Thank you

Yes i found the solution. The exception is because there was no .def file associated with dll. Creating def file with Library and exports overcomes this problem......

When i started using __declspec ( dllexport ), I quit making .def files.