Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: vrieg on July 09, 2024, 06:43:10 pm
-
Hello,
I am working on a C# add-in for EA. Right now, I was using EA without admin rights, but another Add-In requires opening EA with admin rights.
Therefore, I would like to register my own C# addin for EA usage with admin privileges.
Does anyone know what would be required to do?
Right now I have,:
private bool register(Type type)
{
bool isAlreadyRegistered = isAlreadyRegisteredInHKCR(type);
if (!isAlreadyRegistered && isComVisible(type))
{
// software classes
RegistryKey controlKey = Registry.CurrentUser.CreateSubKey(@"Software\Classes\" + type.FullName);
controlKey.SetValue(string.Empty,type.FullName);
RegistryKey clsidKey = controlKey.CreateSubKey("CLSID");
clsidKey.SetValue(string.Empty,type.GUID.ToString("B"));
//CLSID
RegistryKey classKey = Registry.CurrentUser.CreateSubKey(@"Software\Classes\CLSID\" + type.GUID.ToString("B"));
classKey.SetValue(string.Empty,type.FullName);
//implemented category
Registry.CurrentUser.CreateSubKey(@"Software\Classes\CLSID\" + type.GUID.ToString("B") + @"\Implemented Categories");
Registry.CurrentUser.CreateSubKey(@"Software\Classes\CLSID\" + type.GUID.ToString("B") + @"\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}");
//inprocerver
RegistryKey inprocKey = Registry.CurrentUser.CreateSubKey(@"Software\Classes\CLSID\" + type.GUID.ToString("B") + @"\InprocServer32");
inprocKey.SetValue(string.Empty,"mscoree.dll"); //hardcoded
inprocKey.SetValue("ThreadingModel","Both"); //hardcoded?
inprocKey.SetValue("Class",type.FullName);
inprocKey.SetValue("Assembly",type.Assembly.FullName);
inprocKey.SetValue("RuntimeVersion",type.Assembly.ImageRuntimeVersion);
inprocKey.SetValue("CodeBase",type.Assembly.EscapedCodeBase);
//version
RegistryKey versionKey = Registry.CurrentUser.CreateSubKey(@"Software\Classes\CLSID\" + type.GUID.ToString("B") + @"\InprocServer32\" + type.Assembly.GetName().Version);
versionKey.SetValue("Class",type.FullName);
versionKey.SetValue("Assembly",type.Assembly.FullName);
versionKey.SetValue("RuntimeVersion",type.Assembly.ImageRuntimeVersion);
versionKey.SetValue("CodeBase",type.Assembly.EscapedCodeBase);
//ProgID
RegistryKey progIdkey = Registry.CurrentUser.CreateSubKey(@"Software\Classes\CLSID\" + type.GUID.ToString("B") + @"\ProgId");
progIdkey.SetValue(string.Empty,type.FullName);
}
return isAlreadyRegistered;
}
Starting EA with admin rights seams not to perform registration during Visual Studio Build
-
I don't really understand why you would want to do it manually like that. Visual Studio will do all that for you if you set the correct checkbox.
Also if you register your add-in on the HKLM it will work for both the regular as admin user.
For an installer I use Wix
Geert
-
ah my fault i did a mistake in setting the checkbox. thanks for the hint