Call a native C++ dll from My C# windows app
I have a C++ dll that has a function exported like so:
__declspec(dllexport) int WINAPI StartServer() ;
I wish to call this function from my C# Windows application. How do I do this??
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Nov 10, 2009, 11:05 AM
In the following, you need to change dllname to the dll name. Add the using to the otehr that is in the program. The DllImport must be in a class.
using System.Runtime.InteropServices;.
.
.
[DllImport("dllname.dll")]
private static extern void StartServer();
.
.
.
StartServer();