Hi,
I have a dll created using C++, which i want to use in my C# prgm. How should i convert it. Also I have header files, how can i use them in my C# prgm. Can anyone guide me or provide some good materials.
Thanks...
Hi,
I have a dll created using C++, which i want to use in my C# prgm. How should i convert it. Also I have header files, how can i use them in my C# prgm. Can anyone guide me or provide some good materials.
Thanks...
You need a tool to convert C++ to C#, but be aware that no tool can convert C++ to C# completely.
go through this site:
http://www.tangiblesoftwaresolutions.com/
Hope it helps you...........:)
There's no need to translate anything in terms of the DLL. See this link: http://msdn.microsoft.com/en-us/library/aa288468(VS.71).aspx What do the header files contain? With the dll import you will be specifying your function prototypes right in the C# code. Any #defines can be translated into consts (or into methods if they define macros).
Ya u r right, I dont want to convert the source code just the dll. K I use PInvoke to convert the dll. What abt Header files.....
My header files contain #define and typedef stmts..... So to replace typedef should i use the delegate???
I'm not 100% sure. I honestly don't have the experience with this kind of thing. That article seems to cover what to do with typedefs but in the context of a struct. People that know more about this kind of thing will probably pick up on the thread. I just didn't want you to think you had to scrap and translate everything. I wish I could be more help.
What type of DLL is it and do you want to maintain C++ or are you wanting to move your code over to C#? You can use DllImport
to define the signatures and call the method:
[System.Runtime.InteropServices.DllImport("shell32.dll")]
private static extern long ShellExecute(Int32 hWnd, string lpOperation,
string lpFile, string lpParameters, string lpDirectory, long nShowCmd);
private enum SW
{
SW_HIDE = 0,
SW_SHOWNORMAL = 1
}
private void OpenNotepad()
{
ShellExecute(0, "open", "notepad.exe", null, null, (long)SW.SW_SHOWNORMAL);
}
The question is do you want this code to run natively or are you happy with exporting the method calls? You can do it either way. I personally prefer having all managed code.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.