Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i execute a void from a dll when the dllname is in a string?
To make it a little clear:

string thisdll = "testdll.dll";
UseDLLOrSomething(thisdll)//i don't know how to import a dll from a STRING
anyvoid();//I don't know how to call a function from a extern dll

does anyone know how to do this?

PS: sorry for bad english, that is becouse i am dutch.
Posted

1 solution

The answer will depend on the dll. If it's Managed (.Net) then you can simply call:

C#
System.Reflection.Assembly.LoadFile("ddlFile");


And then use reflection to call the method. (you may need to instance a class via reflection as well).

If it's Native (like c/c++) then you'll need to register the function via a DLLImport.

http://msdn.microsoft.com/en-us/library/ms235282.aspx[^]
 
Share this answer
 
Comments
Nish Nishant 15-Jul-10 15:20pm    
Reason for my vote of 5
Worth 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900