How do I write this VB6 dll call in C#? [RESOLVED]
How do I call a legacy 32-bit dll from C#?
The VB6 code would look like this:
VB Code:
Option Explicit
Private Declare Function MyFunc Lib "my.dll" _
(ByVal cmd As String) As Boolean
Private Sub Command1_Click()
If MyFunc("abc") Then
MsgBox "Cool!"
End If
End Sub
How should that look in C#?
Thanks!
Re: How do I write this VB6 dll call in C#? [RESOLVED]
Please help: I did this example verbatim except for my path statement and I got the following erro:
Unable to find an entry point named 'MyFunc' in DLL 'c:\MyFunction32\my.Dll'.
Any ideas ?
Re: How do I write this VB6 dll call in C#? [RESOLVED]
Quote:
Originally Posted by
talktodale
Please help: I did this example verbatim except for my path statement and I got the following erro:
Unable to find an entry point named 'MyFunc' in DLL 'c:\MyFunction32\my.Dll'.
Any ideas ?
Do you have the code for my.dll?
The DLLImport directive works with DLL's that have exported functions.
Quote:
Originally Posted by msdn
These attributes explicitly define the DLL's interface to its client, which can be the executable file or another DLL. Declaring functions as dllexport eliminates the need for a module-definition (.DEF) file, at least with respect to the specification of exported functions. Note that dllexport replaces the __export keyword.
If a class is marked declspec(dllexport), any specializations of class templates in the class hierarchy are implicitly marked as declspec(dllexport). This means templates are explicitly instantiated and its members must be defined.
dllexport of a C++ function will expose the function with C++ name mangling. If C++ name mangling is not desired, either use a .def file (EXPORTS keyword) or declare the function as extern "C".