function CheckFileAsscioate(suffix)
	
	--XLMessageBox("检查文件关联")
	local result = 0
	if suffix == nil then
		--XLMessageBox("suffix nil")
--	else
--		XLMessageBox("start")
		--XLMessageBox(#suffix['rule']['roots'])
	end
	local Obj = XLGetObject("Xunlei.OSShell.Obj")
	local ExePath =  suffix['rule@']['filepath']
	if ExePath == "{nil}" then return 2 end 
	local key, value ,  regpath 
	local filetypename = suffix['rule@']['name']
	
	
	for  i = 0, #suffix['rule']['roots'] do
		if suffix['rule']['roots'][i]~=nil then
			value = Obj:QueryRegValue("HKEY_CLASSES_ROOT", suffix['rule']['roots'][i]['root@']['section'], suffix['rule']['roots'][i]['root@']['key'])
			if value ~= suffix['rule']['roots'][i]['root@']['value'] then
				result = 1
				break
			end			
		end
	end
	
	if result ==  1 then		
--		XLMessageBox("root fail")
--		XLMessageBox("Ext: "..suffix['rule@']['ext'])
--		XLMessageBox("ExePath: "..ExePath)
		return result
	else
		--XLMessageBox ("root success")
	end
	
	
	for  i = 0, #suffix['rule']['items'] do	
		if suffix['rule']['items'][i]~=nil then
			value = suffix['rule']['items'][i]['item@']['value']
			if suffix['rule']['items'][i]['item@']['valuetype'] == "1" then
			if string.sub(suffix['rule']['items'][i]['item@']['value'], 1, 3)  == "..\\" then
				value = Obj:PathAppendLua(ExePath, suffix['rule']['items'][i]['item@']['value'])				
			else
				value = ExePath.." "..value
			end
		end
	   end
	   key = suffix['rule']['items'][i]['item@']['key']
	   
	 
	 
	   regpath = filetypename..suffix['rule']['items'][i]['item@']['section']	   
--	   if suffix['rule@']['ext'] ~= ".torrent" then
--			XLMessageBox("regpath: "..regpath)	     
--			XLMessageBox("QueryRegValue: "..Obj:QueryRegValue("HKEY_CLASSES_ROOT", regpath, key))
--	   end
	   if Obj:QueryRegValue("HKEY_CLASSES_ROOT", regpath, key) ~= value then
	   		result = 1
	   		
--	   		XLMessageBox("item fail")
--			XLMessageBox("Ext: "..suffix['rule@']['ext'])
--	   		XLMessageBox("valuereal: "..value)	
--			XLMessageBox(suffix['rule']['items'][i]['item@']['valuetype'])
--			XLMessageBox("key "..key)
--			
--			XLMessageBox("regpath: "..regpath)
--			XLMessageBox("queryvalue: "..Obj:QueryRegValue("HKEY_CLASSES_ROOT", regpath, key) )
	   		break
	   	end
	end	
	if result == 1  then
		--XLMessageBox("item success")
	end
	
	--XLMessageBox("result"..result)
	return result;
end

function FixFileAsscioate(suffix)
	--XLMessageBox('FixFileAsscioate')
	local result = 0
	local Obj = XLGetObject("Xunlei.OSShell.Obj")
	local ExePath = suffix['rule@']['filepath']
	if ExePath == "{nil}" then return 2 end 
	local key , value ,regpath 	
	local filetypename = suffix['rule@']['name']
	for  i = 0, #suffix['rule']['roots'] do
		if suffix['rule']['roots'][i]~=nil then
			Obj:SetRegValue("HKEY_CLASSES_ROOT",suffix['rule']['roots'][i]['root@']['section'], suffix['rule']['roots'][i]['root@']['key'], suffix['rule']['roots'][i]['root@']['regtype'], suffix['rule']['roots'][i]['root@']['value'])
		end
	end
	for i = 0, #suffix['rule']['items'] do 
		if suffix['rule']['items'][i]~=nil then
			value = suffix['rule']['items'][i]['item@']['value']
			if suffix['rule']['items'][i]['item@']['valuetype'] == "1" then
				if string.sub(suffix['rule']['items'][i]['item@']['value'], 1, 3) == "../" then                                        --相对路径
					value = Obj:PathAppendLua(ExePath, suffix['rule']['items'][i]['item@']['value'])
				else                                                                                                         --命令行参数 直接加
				   value = ExePath.." "..value
				end
		end
	   end
		regpath = filetypename..suffix['rule']['items'][i]['item@']['section']
		--XLMessageBox("regpath: "..regpath)
		key = suffix['rule']['items'][i]['item@']['key']
		if Obj:SetRegValue("HKEY_CLASSES_ROOT", regpath, key, suffix['rule']['items'][i]['item@']['regtype'], value) == false then
			result = 1
		end
	end
	--XLMessageBox("result"..result)
	return result
end
