views:

126

answers:

2

Hi,
In my new project I want to use a existing C C++ functions . For that I would need to add the C/C++ dlls to C# project.

My C/C++ projects is of type UnManaged and it is not a COM Project. I have seen few articles after from MSDN and tried:

[DllImport("user32.dll", EntryPoint="MessageBoxA")]

But I am not sure Where should I place the user32.dll or my.dll. Do I need to place my dll in GAC or in some other physical folder.

If that is going to be a physical folder then , Don't I need to use either relative or absolute path?

Also read few articles talking about porting the C++ dlls using InterOp but not quite sure how to start with.

+2  A: 

You can place it in your application bin folder.

ŁukaszW.pl
@ŁukaszW.pl, What about the Entry Point?
Subhen
+3  A: 

Please don't put your own dll's in C:\Windows\system32. If you're going to use part of Windows, like user32.dll, you don't put it anywhere, it's already there and will be found at runtime because C:\Windows\system32 is on the path. If you're going to use your own DLL, put it in the bin or bin\Debug or whatever folder, right next to your exe. This is most easily accomplished by adding it to the project so it will copy into the output directory when you build, but you could have an MSI or whatever. If it's used by multiple applications you have to decide if you want them all to start using the new one when it's updated, or to sit happy with their existing copies. That can be a complicated question and you have enough going on getting it working for one app, right?

As for Entry Point, it's the name of the function inside the DLL. If you're using the same name in your managed code, you can leave it out. It lets you map a DLL function name that you may find complicated into a simpler name you're using in your managed code.

Kate Gregory