Call dll function written in C

I want write a function in win32 dll VC 6.0.
That function is called by a program written in VB 6.0
Who can give me the sample source codes for both side?
I have try many way follow online help, but it always show
"Can't find entry point fun1 in clib"

Who is Participating?
spojConnect With a Mentor Commented:
check out this site:

good luck!!!
my vc dlls[win32] al the functios i add Extern C infront of each function.

for example;

extern "C" __declspec( dllexport ) long MyFunction (HKEY hKeyRoot,
LPCTSTR lpValue,
unsigned long lType )

here, i have added extern "C" __declspec
in front of the exported function.

I guess u have missed this part.
then, compile and use it like any normal API call from ur VB environment.

Find the link:
Create a VC++ DLL file for use with Visual Basic (60K)

* this is a downloadable code

*note*: you may also see some interesting codes that you may also use and study....
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

additional: the link is found in the lower part of the VB4/VB5/VB6 section of the page.....  

good luck!!!! =)
ginaaAuthor Commented:
I have tried the sample, it works, thanks
But in method1 vb program, it must declare alias.
In method2 vc it has a .def file.
Is there any rule or where to find documents for that declaration?

i think it comes with the readme file in it.... i guess.... a certain dll's function could only be found in the documentation of the dll itself..... hope this helps.... thanx..... =) good luck...
ginaaAuthor Commented:
I met the problem again.
In my program:

#define DllExport      __declspec(dllexport)

 /* Declare function */
 extern "C" DllExport int fun1(int p1);

 /* Function body */
 extern "C" DllExport int fun1(int p1)

But in that two line about function header, it said
 error C2059: syntax error : 'string'

But in that two line, I don't write the token 'string'
So what happen? Is there any limit for that use?


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.