tags:

views:

123

answers:

1

Hello, i have c++ DLL and 1 program (not code) , that program calls 1 function from DLL, i know only name of that function, now all want to call that function from my application(C#). Is it possible?

Thanks

+1  A: 

I'm assuming that you only have the DLL by itself, if you've got a header file as well it would be much easier since you can skip straight to figuring out how to PInvoke it.

First you have to get hold of the function signature so you know the arguments and their types. If it's a C++ DLL you might be able to get this out with Dependency Walker, if it's a C DLL, you might have to look at the actual assembly code to figure out the arguments and their types.

If you do figure out the signature, then you can use PInvoke to call it from C#, look at the PInvoke website for more details and many samples.

ho1
Thank you for relpy... Dependency Walker shows that this is a c dll, and it can not show more info , only function name.I install PInvoke , it have only search button, how can i choose my dll or function in it, to show info? Thanks
Armen Khachatryan
@Armen: Sorry, you misunderstood, PInvoke can not be used to find out the info about the function. You first have to find that out in some way, after that you use PInvoke to call it. The PInvoke website can give you information about how to map C# to C datatypes etc. I think all you need to know is the unmangled name of function and it's arguments and their types, but finding that out could be difficult.
ho1
oh ok , tahnks.
Armen Khachatryan