#region SolidWorks Registration
[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type t)
{
#region Get Custom Attribute: SwAddinAttribute
SwAddinAttribute SWattr = null;
Type type = typeof(SwAddin); foreach (System.Attribute attr in type.GetCustomAttributes(false))
{
if (attr is SwAddinAttribute)
{
SWattr = attr as SwAddinAttribute;
break;
}
} #endregion try
{
Microsoft.Win32.RegistryKey hklm = Microsoft.Win32.Registry.LocalMachine;
Microsoft.Win32.RegistryKey hkcu = Microsoft.Win32.Registry.CurrentUser; string keyname = "SOFTWARE\\SolidWorks\\Addins\\{" + t.GUID.ToString() + "}";
Microsoft.Win32.RegistryKey addinkey = hklm.CreateSubKey(keyname);
addinkey.SetValue(null, ); addinkey.SetValue("Description", SWattr.Description);
addinkey.SetValue("Title", SWattr.Title); keyname = "Software\\SolidWorks\\AddInsStartup\\{" + t.GUID.ToString() + "}";
addinkey = hkcu.CreateSubKey(keyname);
addinkey.SetValue(null, Convert.ToInt32(SWattr.LoadAtStartup), Microsoft.Win32.RegistryValueKind.DWord);
}
catch (System.NullReferenceException nl)
{
Console.WriteLine("There was a problem registering this dll: SWattr is null. \n\"" + nl.Message + "\"");
System.Windows.Forms.MessageBox.Show("There was a problem registering this dll: SWattr is null.\n\"" + nl.Message + "\"");
} catch (System.Exception e)
{
Console.WriteLine(e.Message); System.Windows.Forms.MessageBox.Show("There was a problem registering the function: \n\"" + e.Message + "\"");
}
} [ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type t)
{
try
{
Microsoft.Win32.RegistryKey hklm = Microsoft.Win32.Registry.LocalMachine;
Microsoft.Win32.RegistryKey hkcu = Microsoft.Win32.Registry.CurrentUser; string keyname = "SOFTWARE\\SolidWorks\\Addins\\{" + t.GUID.ToString() + "}";
hklm.DeleteSubKey(keyname); keyname = "Software\\SolidWorks\\AddInsStartup\\{" + t.GUID.ToString() + "}";
hkcu.DeleteSubKey(keyname);
}
catch (System.NullReferenceException nl)
{
Console.WriteLine("There was a problem unregistering this dll: " + nl.Message);
System.Windows.Forms.MessageBox.Show("There was a problem unregistering this dll: \n\"" + nl.Message + "\"");
}
catch (System.Exception e)
{
Console.WriteLine("There was a problem unregistering this dll: " + e.Message);
System.Windows.Forms.MessageBox.Show("There was a problem unregistering this dll: \n\"" + e.Message + "\"");
}
} #endregion

RegisterFunction z More articles about

  1. 【Python】 Use torrentParser1.03 For multiple files torrent Analysis results of

    Your environment has been set up for using Node.js 8.5.0 (x64) and npm. C:\Users\horn1>cd C:\User ...

  2. Android Three dimensional rotation animation implementation and packaging ( Support with X、Y、Z Three axes rotate around )

    This paper mainly introduces Android 3D rotation animation , perhaps 3D rotate , Here's an interface I implemented myself There are three types of solid rotation : 1.  With X The axis rotates around the axis 2.  With Y The axis rotates around the axis 3.  With Z The axis rotates around the axis -- This is equivalent to andro ...

  3. Z Glyph scanning (201412-2)

    Problem description In the algorithm of image coding , We need to do a given square matrix Z Glyph scanning (Zigzag Scan). Given a n×n Matrix ,Z The process of glyph scanning is shown in the figure below : For the following 4×4 Matrix , 1 5 3 9 3 7 5 ...

  4. 【IOS】 A set of data containing Chinese is divided into two parts #ABC...Z* grouping

    Last article [IOS] imitation windowsphone List index control YFMetroListBox Inside Step by step, we have achieved WindowsPhone Index of style . But did you find out , If you're going to implement alphabetical order , What else do you have to do ...

  5. Java Compress / decompression .Z file

    1. Problem description Company projects need JAVA decompression .z file . .z yes unix System common compressed file . 2. Source code import com.chilkatsoft.CkUnixCompress; impor ...

  6. Chinese programming language Z Language open source is officially open source !!!

    (Z Language based .NET Environmental Science , There's a lot of high-tech code in the source code , Let more people know that it will help you a lot , Please let the administrator approve it and put it on the front page ) I realize the Chinese programming language Z The language is now officially open source , use LGPL agreement . The address of the compiler core is ...

  7. CCF——Z Glyph scanning problem

    Question number : 201412-2 The title of the test question : Z Glyph scanning The time limit : 2.0s Memory limit : 256.0MB Problem description : Problem description In the algorithm of image coding , We need to do a given square matrix Z Glyph scanning (Zigzag ...

  8. Z.ExtensionMethods A powerful open source extension library

    Today, I intentionally searched in the blog Garden Z.ExtensionMethods This extended class library , I found that only two blog articles were found to be really related to this , I went in to have a look , It's just mentioned , No special introduction , That led me to write this document ...

  9. Linux Ctrl+c And ctrl+z The difference between

    put questions to :CTRL-Z and CTRL-C difference ? answer :CTRL-Z and CTRL-C All interrupt commands , But their role is different .CTRL-C Is to forcibly interrupt the execution of a program , and CTRL-Z It's important to interrupt the mission , But the task is not over , He still ...

Random recommendation

  1. Practical Malware Analysis It's about inetsim\APATEDNS

    Never touched before linux, There are many problems , Step by step : 1\ install VMWARE, install ubuntu16.04 problem 1: It used to be VM10, Not installed after installation VMTOOLS, I'll click Install VMTOOLS, It pops up “ Jane Eyan ...

  2. https collection 12306( Copy )

    package train; import java.io.IOException;import java.security.NoSuchAlgorithmException;import java. ...

  3. During the loading process, the image is distorted ? -- To teach you how to customize the aspect ratio of auto adapted pictures RatioLayout

    Many peers may encounter such problems in development , The problem of image deformation occurs when loading images . In fact, this is probably caused by the mismatch between the aspect ratio of your image and that of the container where the image is located . For example, the width of the picture is 200, High for 100. The aspect ratio is 2, that ...

  4. Smart principle

    follow smart principle , Must be specific . Measurable . Accessible . Related to job responsibilities . There is a definite time limit .

  5. Windows2008 R2 Next ,DCOM The solution to the unavailability of attribute gray in configuration

    Error for : Pool for applications “XXXXXX” The process of providing services is related to “Windows Process Activation Service” There was a serious error communicating . The process ID by "XXX". Data word ...

  6. To configure JDK environment variable

    • To configure JDK environment variable <Windows Under the system > Right click on my computer -----> attribute ------> senior ------> environment variable ------->  newly build ( It is recommended to create a new ...

  7. android+apimonitor+genymotion

    1. install genymotion: http://www.genymotion.net/ 2. Set to use adb Setting--adb-- choice sdk The catalog of 3. apimonitor https:// ...

  8. C++ Initialization and assignment

    1. The difference between initialization and assignment : The difference between the two is not to see , Is there a = This assignment operator , It's about the operation , Whether the object already has a value . initialization : Create objects , And set it an initial value . assignment : Object already has a value , Erase the current value of the object , And use the new value instead of . ...

  9. To put an assembly “xxx.dll” Marked as a prerequisite , It must be strongly signed

    Recently, the title error often appears occasionally in compilers , Sometimes restart the computer , It's normal , Sometimes rebooting doesn't work , It hurts , It turns out that dll Pre copy to build directory , This compilation error can also be avoided , But it's really troublesome , Go again Google For a long time , Finally found a solution ...

  10. http headers

    What is? HTTP Headers HTTP yes “Hypertext Transfer Protocol” Written by , This protocol is used throughout the World Wide Web , Almost most of what you see in your browser is through http Protocol to transmit , Than ...