【笔记】MacOS上使用Wine运行Windows程序

前言

MacOS上使用Wine运行Windows程序

介绍

官网介绍

Wine (“Wine Is Not an Emulator” 的首字母缩写)是一个能够在多种 POSIX-compliant 操作系统(诸如 Linux,macOS 及 BSD 等)上运行 Windows 应用的兼容层。Wine 不是像虚拟机或者模拟器一样模仿内部的 Windows 逻辑,而是將 Windows API 调用翻译成为动态的 POSIX 调用,免除了性能和其他一些行为的内存占用,让你能够干净地集合 Windows 应用到你的桌面。(官网

维基百科

Wine是在x86、x86-64容许类Unix操作系统在X Window System运行Microsoft Windows程序的软件。另外,Wine也提供程序运行库(Winelib)来帮助计算机程序设计师将Windows程序移植到类Unix系统;也有不少软件经过Wine测试后发布,比如Picasa、uTorrent、MediaCoder。(维基百科

Github

Wine is a program which allows running Microsoft Windows programs(including DOS, Windows 3.x, Win32, and Win64 executables) on Unix.(Github

安装依赖

XQuartz介绍

The XQuartz project is an open-source effort to develop a version of the X.Org X Window System that runs on macOS. Together with supporting libraries and applications, it forms the X11.app that Apple shipped with OS X versions 10.5 through 10.7.(官网

安装 XQuartz

1
brew install xquartz

安装 Wine

1
brew install wine-stable

加入环境变量

~/.zshrc
1
2
export WINE_HOME=/Applications/Wine\ Stable.app/Contents/Resources/wine
export PATH=$PATH:$WINE_HOME/bin

重新加载环境变量

1
source ~/.zshrc

启动 Wine

⚠️ 由于自MacOS 15.0开始不再支持32位程序,所以命令wine废弃,所有wine命令应改为win64才可以正常使用Wine

安装 winecfg

  • 安装用于配置wine的winecfg
1
wine64 winecfg

运行一个 Windows 程序

运行Windows自带程序

  • 运行在C:\windows\system32\路径下的,Windows自带的程序

<name>:程序名

1
wine64 <name>

运行EXE程序

<file>:Windows可执行程序的路径

1
wine64 <file>.exe

运行MSI程序

1
wine64 msiexec /i <file>.msi

Wine安装的程序路径

  • 使用Wine安装的Windows程序的安装路径
1
~/.wine/drive_c/Program Files(x86)/Netease/

解决乱码

修改字符编码集

  • 将修改字符编码集的命令加入到环境变量
~/.zshrc
1
export LC_ALL=zh_CN.UTF-8

重新加载环境变量

1
source ~/.zshrc

修改文字设置(可选)

添加字体

  • 找到MacOS上的宋体字体文件,创建软链接到Windows上

新宋体.ttf:请根据自己的字体文件名指定字体

1
ln -s ~/Library/Fonts/新宋体.ttf ~/.wine/drive_c/windows/fonts/XinSongTi.ttf

更新注册表

  • 在MacOS上创建一个wine_zh.reg文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
REGEDIT4
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows
NT\CurrentVersion\FontSubstitutes]
"Arial"="XinSongTi"
"Arial CE,238"="XinSongTi"
"Arial CYR,204"="XinSongTi"
"Arial Greek,161"="XinSongTi"
"Arial TUR,162"="XinSongTi"
"Courier New"="XinSongTi"
"Courier New CE,238"="XinSongTi"
"Courier New CYR,204"="XinSongTi"
"Courier New Greek,161"="XinSongTi"
"Courier New TUR,162"="XinSongTi"
"FixedSys"="XinSongTi"
"Helv"="XinSongTi"
"Helvetica"="XinSongTi"
"MS Sans Serif"="XinSongTi"
"MS Shell Dlg"="XinSongTi"
"MS Shell Dlg 2"="XinSongTi"
"System"="XinSongTi"
"Tahoma"="XinSongTi"
"Times"="XinSongTi"
"Times New Roman CE,238"="XinSongTi"
"Times New Roman CYR,204"="XinSongTi"
"Times New Roman Greek,161"="XinSongTi"
"Times New Roman TUR,162"="XinSongTi"
"Tms Rmn"="XinSongTi"
  • 执行wine_zh.reg程序,实现修改注册表
1
wine64 regedit wine_zh.reg

提高清晰度

  • 通过修改Windows的注册表来提高Windows文字的清晰度
  • 修改十六进制的00000060(十进制为96)来实现提高清晰度
~/.wine/system.reg
1
"LogPixels"=dword:00000060

修改文字大小

  • 在win.ini文件末尾追加修改文字大小的配置信息
~/.wine/drive_c/windows/win.ini
1
2
3
4
5
[Desktop]
menufontsize=13
messagefontsize=13
statusfontsize=13
IconTitleSize=13

完成

参考文献

Bruce的博客