Guest rowansmith Posted November 25, 2002 Posted November 25, 2002 I am writing a VB application to use the new dnsapi.lib SDK shipped in Aug 2002. To do this I have created two projects in my solution: 1) A VB Application 2) A MFC DLL I have used the line: declare function CanVBSee lib "dnslib2.dll" alias "CanVBSeeThis" (byval s as string) as long. When I try to call the function I get an Error that VB could not find the entry point for the function CanVBSeeThis in dnslib2.dll. What is the correct way to make the DLL accessible to my VB program? Is there a better way to make C functions available to VB? I have read about creating type libraries, but can not find a way to do this. Thanks. -Rowan Quote
*Experts* Merrion Posted November 26, 2002 *Experts* Posted November 26, 2002 Are you using the StdCall calling convention in your DLL? If not you may have to declare the dll import differently i.e.: <DllImport("dnslib2.dll", EntryPoint:="CanVBSeeThis", _ SetLastError:=False, CharSet:=CharSet.Ansi, _ ExactSpelling:=True, _ CallingConvention:=CallingConvention.Cdecl)> Public Shared function CanVBSee (byval s as string) as long '\\ No code goes here.... End Function Check out the DllImport class for more info.. HTH, Duncan Quote Printer Monitor for .NET? - see Merrion Computing Ltd for details
*Gurus* divil Posted November 26, 2002 *Gurus* Posted November 26, 2002 You don't need to create a type library for this kind of export. Try searching Google for documents on writing C DLLs to be used from VB6 (there are many) and then use the same style declare in VB.NET, doing the necessary conversions (Long becomes Integer, etc). Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Administrators PlausiblyDamp Posted November 27, 2002 Administrators Posted November 27, 2002 how is the function declared in the MFC DL? If you export it as a C function then it should have the correct name. When C++ functions are exported there names are 'mangled' (technical term - not my term) to allow C++ features like overloading to work, this usually involves the addition of extra characters (such as @) in the function name. Check with dumpbin.exe or similar what the exported function names are. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts