Jump to content
Xtreme .Net Talk

Recommended Posts

Guest rowansmith
Posted

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

  • *Experts*
Posted

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

Printer Monitor for .NET? - see Merrion Computing Ltd for details
  • *Gurus*
Posted
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).

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
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...