function  CheckIESetting(tab)	
	if tab == nil then
		return nil
	end
	local Obj = XLGetObject("Xunlei.OSShell.Obj")
	local result = 0
--	XLMessageBox("CheckIESetting")
	local regPath=""
	if tab['rule@']['enable']=="1" then
		regPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Ext\\Settings\\"..tab['rule@']['clsid']
		--XLMessageBox(regPath)
		local flag = 1
		local flag = Obj:QueryRegValue("HKEY_CURRENT_USER", regPath, "Flags")	
		if flag ~= nil and flag~= 0 then
			return 1
		end
	else	
		regPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Ext\\Stats\\"..tab['rule@']['clsid'].."\\iexplore\\AllowedDomains"
		local tabSubkey = Obj:GetRegSubItem("HKEY_CURRENT_USER", regPath)
		if tabSubkey==nil then
			return 1
		end
		result = 1
		for i=1, #tabSubkey do
			if tabSubkey[i]~=nil then
				local addr=tab['rule@']['addr']
				if addr==nil then addr="*" end
				if tabSubkey[i]=="*" or string.lower(tabSubkey[i])==addr then
					result = 0
				end
			end		
		end	
	end
	
--	XLMessageBox("result: "..result)	
	return result
end
function FixIESetting(tab)		
	if tab == nil then
		return nil
	end
--	XLMessageBox("修复IE插件设置")
	local Obj = XLGetObject("Xunlei.OSShell.Obj")
	local regPath=""
	if tab['rule@']['enable']=="1" then
		regPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Ext\\Settings\\"..tab['rule@']['clsid']
		local result = 0
		if Obj:DeleteRegKey("HKEY_CURRENT_USER", regPath) == false then
		 	result = 1
		end					
	else	
		regPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Ext\\Stats\\"..tab['rule@']['clsid'].."\\iexplore\\AllowedDomains"
		local tabSubkey = Obj:GetRegSubItem("HKEY_CURRENT_USER", regPath)
		if tabSubkey==nil then
			result = Obj:SetRegValue("HKEY_CURRENT_USER", regPath.."\\*", "", 1, "")
		else
			local needfix = true
			for i=1, #tabSubkey do
				if tabSubkey[i]~=nil and (tabSubkey[i]=="*" or string.lower(tabSubkey[i])=="xunlei.com") then
					needfix = false
				end
			end	
			if needfix then 
				result = Obj:SetRegValue("HKEY_CURRENT_USER", regPath.."\\*", "", 1, "")
			end
		end
	end
	--result = Obj:SetRegValue("HKEY_CURRENT_USER", regPath, "", 1, "")
	
--	XLMessageBox("result: "..tostring(result))
	result = CheckIESetting(tab)
	return result
end

function DisIESetting(tab)		
	if tab == nil then
		return nil
	end
--	XLMessageBox("修复IE插件设置")
	
	local result = 0
	local Obj = XLGetObject("Xunlei.OSShell.Obj")
	
	if tab['rule@']['enable']=="1" then
		local regPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Ext\\Settings\\"..tab['rule@']['clsid']
	--	XLMessageBox(regPath)
		local ret = Obj:SetRegValue("HKEY_CURRENT_USER", regPath, "Flags", 4,  1)	
		if ret==false then
			result = 1
		else
			local ret = Obj:SetRegValue("HKEY_CURRENT_USER", regPath, "Version", 1, "*")
			if ret==false then
				result = 1
			end
		end
	end
--	XLMessageBox("result: "..tostring(result))
	return result
end
