| 赞 | 17 |
| VIP | |
| 好人卡 | |
| 积分 | 27 |
| 经验 | |
| 最后登录 | 2019-2-2 |
| 在线时间 | 166 小时 |
- 梦石
- 0
- 星屑
- 2709
- 在线时间
- 166 小时
- 注册时间
- 2018-1-19
- 回帖
- 88
|
发表于 2018-1-26 18:56:29
|
显示全部楼层
本帖最后由 mori13 于 2018-1-26 19:00 编辑
用win32API的kernel32的CopyFileA函数
类似代码如下
- #查找系统根目录
- dir = Win32API.new('kernel32','GetSystemDirectory','pl','l')
- dir_str = " " * 256
- dir.call(dir_str,255)
- dir_str = dir_str.split('system')[0]
- #字体查找
- font_name = "STXINWEI.ttf"
- font_chn_name = "华文新魏"
- begin
- if FileTest.exist?(font_name)
- copy = Win32API.new('kernel32',"CopyFileA",'ppl','')
- copy.call(font_name, "#{dir_str}Fonts/#{font_name}",0)
- font = Win32API.new('gdi32','AddFontResourceA','p','l')
- sendmsg = Win32API.new('user32','SendMessageA','llll','l')
- unless Font.exist?(font_chn_name)
- font.call(font_name)
- sendmsg.call(65535,29,0,0)
- end
- end
- end
复制代码 |
|