一种实用的方法
regsvr32.exe xx.dll
每个需要注册的文件都包括一个DllRegisterServer()方法,regsvr32.exe通过调用该方法来完成Dll的注册
//xx.dll注册
[DllImport("xx.dll")]
public static extern int DllRegisterServer();
//xx.dll反注册
[DllImport("xx.dll")]
public static extern int DllUnregisterServer();
判断注册是否成功
int i=DllRegisterServer();
i>=0注册成功,否则注册失败
每个dll的在注册表中的ID都不一样,你可以先用regsvr32注册成功一个就可以查到
string id="CLSID\\{7713f78A-SXX-CED33-23-3--DDABADD}\\";
添加Microsoft.Win32引用
RegistryKey rk=Registry.ClassesRoot.OpenSubkey(id);
if(rk==null)
说明dll文件还没有注册
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23109131/viewspace-692905/
,如需转载,请注明出处,否则将追究法律责任。