We help IT Professionals succeed at work.

Writing Main Program to test dll

raymondwee asked
Last Modified: 2010-04-10
I need a short Main program written in BC5 to test out my dll.
Dll complied using MFC, VC++6.
dll function -
extern "C" int Testing(void);
return value is the status of Testing function.
I have tried using _import and loadlibrary. But can't seems to work.

Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)

if your going to use your dll from other languages such as VB you should declare it also as stdcall like this...

extern "C" __declspec(dllexport) __stdcall int Testing(void)

This will ensure that the parameter passing method can be used by VB and other stdcall mechanism languages.


a program to test this would look like...

void main()

  HANDLE hLib=LoadLibrary("MyLib.DLL");
     FARPROC fProc=GetProcAddress(hLib,"Testing");
      // successfully got proc address



Adjusted points from 30 to 50


I have added those codes you mentioned.
but I can't get the address of the Function.(dll)
I have just changed my dll function to

extern int __declspec(dllimport) Test(char *name), where name is a input parameter for user to input name.

So my GetProcAddress should still be fProc = GetProcAddress(hLib,"Test");

But the "if(fProc) ruturns NULL..

Pls help.

"C" grade?????
why not just ask for more info and not grade yet?

My answer was correct - by not putting extern "C" you have changed the name of the function.

You have introduced C++ name mangling - put the extern "C" back and all should be well.

Use the quickview application or depends.exe with VC++ to view the exports of a DLL.

C ???

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.