Does anyone do this? I used to do it in AutoCad. My boss has asked me to add this to a few proprietary macros we use(paid a lot of money for). Is it as simple as get serial then an if/then statement to continue or close?
The macro (SWP) can be unlocked easily. So better go for standalone (exe) or Add-ins.
In the long run we will eventually get it converted over.
Just want to limit the the macro to run on machines with certain serial numbers for now.
You can password protect a macro so that it cannot be edited.
Right click on the Project (in the VBA Editor) and choose Properties
On the Protection tab, tick the Lock Project for Viewing box and add a password.
I do password protect some of the macro we use....what i am trying to do is limit the macro being used on a machine that does not have 2 of the 3 Network licenses we have. Basically prevent someone from RUNNING the macro based on serial number of the solidworks install.
You can use IF condition to fetch the serial number from registry and then proceed as needed.
In your macro, add a reference to Windows Script Host Object Model. Then use this code:
Dim myWsh As New WshShell
Dim mySerialNumber As String
mySerialNumber = myWsh.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\SolidWorks\Licenses\Serial Numbers\SolidWorks")
Thanks Simon, Deepak...
I had the route but not the process...like always...LOL
I believe i have it i forgot about Windows Script Host Object Model. Once obtaining the reg information i added an if/then to either continue or stop the macro.
I believe it's better to take a route and make your process
You will want to convert this to an addin first. Then you could have the addin get the user's serial number and use that as a decryption key. For example, take your SN and multiply it by a huge prime number, then hard-code the product into the program. On startup, the product is divided by your SN. If the quotient is a prime number, let the user continue.
Whatever you do, just do not hard-code your serial number into your program. DLLs can be decompiled and hence your serial number obtained.
SolidWorks API Training and Services
Hows about provide the passcode to use the macro?
Retrieving data ...