我正在开发一个excel插件。我有序列号(例如 100 个),我想检查何时在 pc 上安装 excel 插件。但是我不能用VS2010安装项目来做,因为它不支持序列号列表存储和检查。
所以我想用设置工厂来做这个,我做了这个链接: link
但我有一个问题 excel ;
如果我选择“是”,excel 将用于打开 .dll,如果选择“否”,它会执行任何操作。
和我的设置工厂列表是这样的。
我的设置工厂“在安装后脚本上”,我的 Addinfilename 值为“Posta Guvercini Excel AddIn For 2010.dll”
-- Determine registry key (2 = HK CURRENT USER)
sVersions = Registry.GetKeyNames(2, "Software\\Microsoft\\Office");
-- Iterate through the registry keys per MS Office-version
--Next line has SetupFactory 8 code
--for iCount1, sVersion in sVersions do
for iCount1, sVersion in pairs(sVersions) do
-- Try opening the registry key
sSubKey = "Software\\Microsoft\\Office\\"..sVersion..
"\\Excel\\Options\\"
sValues = Registry.GetValueNames(2, sSubKey);
--initialize index counter
iIndex = -2
if sValues then
--Determine the index of the maximimum OPEN registry entry
--Next line has SetupFactory 8 code
--for iCount2, sValue in sValues do
for iCount2, sValue in pairs(sValues) do
if (String.Left(sValue, 4) == "OPEN") then
--Check whether the user did not already install
--the same add-in to prevent errors when opening Excel
sKeysValue = Registry.GetValue(2, sSubKey, sValue, true)
if String.Find(sKeysValue, SessionVar.Expand(
"%AddinFileName%"), 1, false) > 0 then
iIndex = -1
-- leave loop
break;
else
if (sValue == "OPEN") then
iIndex = 0
else
iIndex = String.ToNumber(String.Mid(
sValue, 5, String.Length(sValue)-4))
end;
end;
end;
end;
-- -1 means: This add-in is already installed; we're done
if iIndex ~= -1 then
--Determine path based on variable "%AddinFileName%
sAppPath = String.Char(34)..
SessionVar.Expand("%AppFolder%")..
"\\"..
SessionVar.Expand("%AddinFileName%")..
String.Char(34)
-- -2 is the initialized value of the index counter
if (iIndex == -2) then
-- OPEN-key does not exist
Registry.SetValue(2, sSubKey, "OPEN",
sAppPath, REG_SZ)
else
Registry.SetValue(2, sSubKey, "OPEN"..(iIndex + 1),
sAppPath, REG_SZ)
end;
end;
end;
end;