Check if a DLL is present in the system

前端 未结 5 556
深忆病人
深忆病人 2020-12-06 16:41

quick question. I want to find out if a DLL is present in the system where my application is executing.

Is this possible in C#? (in a way that would work on ALL Wind

5条回答
  •  萌比男神i
    2020-12-06 17:47

    Call the LoadLibrary API function:

    [DllImport("kernel32", SetLastError=true)]
    static extern IntPtr LoadLibrary(string lpFileName);
    
    static bool CheckLibrary(string fileName) {
        return LoadLibrary(fileName) == IntPtr.Zero;
    }
    

提交回复
热议问题