Hi,
Is it possible to call an MFC C++ DLL, either regular or DLL with MFC extension, from Visual Basic.Net ?
Brgds
Printable View
Hi,
Is it possible to call an MFC C++ DLL, either regular or DLL with MFC extension, from Visual Basic.Net ?
Brgds
the people at the .net forum should be able to help you better.
http://www.vbforums.com/forumdisplay.php?f=25
If you export a function from your DLL then you can call it by creating a blank function and using the <DllImport> attribute to import the C++ function.
For example, Sleep()...
VB Code:
Imports System.Runtime.InteropServices <DllImport("kernel32")> Private Shared Sub Sleep (ByVal dwMilliseconds As Integer) End Sub
You could also use the Declare statement, but that has been deprecated in favour of DllImport which gives you more control. Declare is included in VB.NET for backwards compatibility.
Moved to VB.NET
If I test the DLL (FileXfer.dll) with a C++ program it works fine, but when I use a Visual Basic.Net application I received following error mgs :Quote:
Originally Posted by penagate
"An unhandled exception of type 'System.EntryPointNotFoundException' occurred in TestXferDLL.exe
Additional information: Unable to find an entry point named XferFile in DLL FileXfer."
I've made this declaration in the Visual Basic.net application:
<DllImport("FileXfer")> Private Shared Sub XferFile()
End Sub
FileXfer.dll is in the windows\system32 folder so it should be available.
Anybody knows why I receive this error ?
Brgds
How did you export it? Is that the exact name you used?
------------Quote:
Originally Posted by penagate
I use _stdcall to export instead of _declspec(dllexport). Looks like its working now.