How to: Determining programmatically if DLL is registered

Here is a C# code snippet to determine if a particular DLL is registered or not.


 


[DllImport("kernel32")]


public extern static int LoadLibrary(string lpLibFileName);


 


[DllImport("kernel32")]


public extern static bool FreeLibrary(int hLibModule);


 


public bool IsDllRegistered(string DllName)


{


      int libId = LoadLibrary(DllName);


      if (libId>0) FreeLibrary(libId);


      return (libId>0);


}


 


Source: http://blogs.msdn.com/asanto

One thought on “How to: Determining programmatically if DLL is registered”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>