Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: SEREGIUS on December 28, 2017, 03:15:28 AM
-
Hi,
Can I get a PCID for LUA?
I want my module to be used only on a specific copy of Mach4.
How is this best done?
-
To get the PCID as in the same as you use for your Mach4 License then you can get it using
local inst = mc.mcGetInstance()
local PCID = mc.mcCntlGetComputerID(inst)
wx.wxMessageBox(PCID)
from here then just use an if statement to compare IE
if (PCID == "key to match") then
Succces
end
DazTheGas
-
Thank you, DazTheGas.
mcCntlGetComputerID is in Mach4CoreAPI, I did not read well ::)
Made reading the file Mach4Lic.dat, but I will use mcCntlGetComputerID
local inst = mc.mcGetInstance()
local Mach4Lic = io.open("C:\\Mach4Hobby\\Licenses\\Mach4Lic.dat","r")
if not Mach4Lic then
wx.wxMessageBox("Fail open Mach4Lic.dat!")
else
local a = Mach4Lic:seek("set", 329)
local b = Mach4Lic:read (10)
Mach4Lic:close()
local c = 'AAEAAAzPf9'
if b ~= c then
wx.wxMessageBox("Fail licensed module!")
end
end
The problem is using a license check. If you put the script in "Screen Load Script" then it can be removed from there.
If you use the password (Operator - Lock), then it can be reset to "Machine.ini".
If you put the script in the module, then what is it to bind to? "Enable" button? Then you can go into "Edit Screen" and remove the function call in the module ...
-
Just compile your module and include the PCID check within it, then its not readable.
Have a look at one of the mcc files in your macro folder to see what a compiled file looks like.
DazTheGas
-
I compiled the module into mcc.
I can not figure out what to do if the key is not checked ...
-
This isnt tested but should give you an idea.
local MyModule = {}
function PCID_CHECK() -- this becomes a private function that users cant access
local inst = mc.mcGetInstance()
local PCID = mc.mcCntlGetComputerID(inst)
if (PCID == "key to match") then
return
else
package.loaded.MyModule = nil -- unload the module so it cant be used
end
end
function MyModule.whatever()
PCID_CHECK() -- include where-ever you like
-- rest off function
end
return MyModule
DazTheGas
-
package.loaded.MyModule = nil -- unload the module so it cant be used
Thank you will test.
-
It works now: ;D
local testmod = require "mymodule"
testmod = nil
package.loaded["mymodule"] = nil