Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DllImport vs LoadLibrary, What is the best way?

i'm usually using Win32 API in c#.NET. But not declare all in one application. Sometimes usually using user32, sometimes gdi32 ... I think when i declare all api function, those use lot of memory. What is the best way using API in .NET ?

like image 853
ebattulga Avatar asked Dec 10 '22 21:12

ebattulga


1 Answers

LoadLibrary is useful when you are writing code that might be used in an environment that may or may not have the desired dll -- for example, you might have a program that can use a special crypto dll if it is available, but can still operate without it. Using DllImport would require that dll to exist.

like image 51
Toybuilder Avatar answered Dec 29 '22 17:12

Toybuilder