Solved

Create DLL using Turbo C ?

Posted on 1998-10-18
4
1,307 Views
Last Modified: 2008-02-26
How can I create DLL for my Visual Basic Application using turbo C?
0
Comment
Question by:anik
4 Comments
 
LVL 1

Expert Comment

by:mlaiosa
ID: 1253679
what version of turbo C, of VB
0
 

Author Comment

by:anik
ID: 1253680
turbo C++ 3.0, Visual Basic 6.0
0
 
LVL 1

Accepted Solution

by:
prozak earned 10 total points
ID: 1253681
I haven't actually done this with TC but I can tell you how to do it with MS VC++. All of you functions must be declared with the extern "C" qualifier if you're using C++ to prevent name mangling. Additionally all the functions that will be called by you VB program must be declared as stdcall (This affects how arguments are passed to function). And finally when compiling the DLL (this is under VC++ only as far as I know) I had to define a .def (module definition) file and specifically export each function in that, otherwise when I called the function from VB I would get an error "Could not find entry point" or something like that. Also when you declare the function in VB if it's ByVal then you just get the value (i.e. ByVal myVar As Long would be long myvar in C and ByRef myVar as Long would be long *myvar in C. After reading this last sentence, I guess you could've figured that one out by yourself :) Strings must be passed as ByVal so VB can do the translation from a multi-byte string (16-bit characters) to a byte string (8-bit ASCII characters). The only way I've found to get access to the multi-byte versions of VB strings is if the value is passed as type Variant. If you try to pass the string as ByRef, you get a pointer to a pointer to the string but VB still packs all the characters to 8-bits. All of this info is for VB5. I haven't used VB6 yet but I've heard that in this respect it is the same.
Hope this helps!
0
 

Expert Comment

by:peterpan1975
ID: 1253682
there (at VStudio vb cd) is a file vb5dll.doc:
\vb5.0\tools\docs
very good explanation how to connect VC 4.0 dll's to vb... Im not sure if it applies to TC, but I hope it might be helpful as well :)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now