本帖最后由 76213585 于 2013-8-31 18:45 编辑
第二項應該可以通过判定資料夾內文件是否存在而來達成?
===========================
dir = Win32API.new('kernel32','GetSystemDirectory','p,l','l') dir_str = " " * 256 dir.call(dir_str,255) dir_str = dir_str.split('system')[0] font_name = "方正像素12.ttf" font_chn_name = "方正像素12" if FileTest.exist?(font_name) copy = Win32API.new('kernel32',"CopyFileA",'p,p,l','') copy.call(font_name, "#{dir_str}Fonts/#{font_name}",0) font = Win32API.new('gdi32','AddFontResourceA','p','l') sendmsg = Win32API.new('user32','SendMessageA','l,l,l,l','l') unless Font.exist?("方正像素12") or Font.exist?(font_chn_name) font.call(font_name) sendmsg.call(65535,29,0,0) #retry end end
dir = Win32API.new('kernel32','GetSystemDirectory','p,l','l')
dir_str = " " * 256
dir.call(dir_str,255)
dir_str = dir_str.split('system')[0]
font_name = "方正像素12.ttf"
font_chn_name = "方正像素12"
if FileTest.exist?(font_name)
copy = Win32API.new('kernel32',"CopyFileA",'p,p,l','')
copy.call(font_name, "#{dir_str}Fonts/#{font_name}",0)
font = Win32API.new('gdi32','AddFontResourceA','p','l')
sendmsg = Win32API.new('user32','SendMessageA','l,l,l,l','l')
unless Font.exist?("方正像素12") or Font.exist?(font_chn_name)
font.call(font_name)
sendmsg.call(65535,29,0,0)
#retry
end
end
這个字体自動安裝腳本就是判定文件並且操作的 可能有用
@命真苦 |