Skip to content

Commit a1acee8

Browse files
committed
添加Wine环境的检测,在Wine环境下不显示菜单图标
1 parent 1285265 commit a1acee8

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

TrafficMonitor/TrafficMonitor.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,10 +751,15 @@ CString CTrafficMonitorApp::GetSystemInfoString()
751751
info += _T("System Info:\r\n");
752752

753753
CString strTmp;
754-
strTmp.Format(_T("Windows Version: %d.%d build %d\r\n"), m_win_version.GetMajorVersion(),
754+
strTmp.Format(_T("Windows Version: %d.%d build %d"), m_win_version.GetMajorVersion(),
755755
m_win_version.GetMinorVersion(), m_win_version.GetBuildNumber());
756756
info += strTmp;
757757

758+
if (m_win_version.IsWine())
759+
info += _T(" (Wine)");
760+
761+
info += _T("\r\n");
762+
758763
strTmp.Format(_T("DPI: %d"), m_dpi);
759764
info += strTmp;
760765
info += _T("\r\n");

TrafficMonitor/TrafficMonitorDlg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ void CTrafficMonitorDlg::OnTimer(UINT_PTR nIDEvent)
16601660
if (!theApp.m_cfg_data.m_hide_main_window || theApp.m_cfg_data.m_show_task_bar_wnd)
16611661
{
16621662
//每隔10秒钟检测一次是否可以嵌入任务栏
1663-
if (IsTaskbarWndValid() && m_timer_cnt % 10 == 1)
1663+
if (!theApp.m_win_version.IsWine() && IsTaskbarWndValid() && m_timer_cnt % 10 == 1)
16641664
{
16651665
if (m_tBarDlg->GetCannotInsertToTaskBar() && m_insert_to_taskbar_cnt < MAX_INSERT_TO_TASKBAR_CNT)
16661666
{

TrafficMonitor/WIC.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "stdafx.h"
22
#include "WIC.h"
3+
#include "TrafficMonitor.h"
34

45
CWICFactory CWICFactory::m_instance;
56

@@ -44,6 +45,10 @@ CMenuIcon::~CMenuIcon()
4445

4546
HRESULT CMenuIcon::AddIconToMenuItem(HMENU hmenu, int iMenuItem, BOOL fByPosition, HICON hicon)
4647
{
48+
//由于Wine环境下菜单图标会出现异常,因此不为菜单添加图标
49+
if (theApp.m_win_version.IsWine())
50+
return 0;
51+
4752
#ifndef COMPILE_IN_WIN_XP
4853
HBITMAP hbmp{};
4954
HRESULT hr = GetBitmapByIcon(hicon, hbmp);

TrafficMonitor/WinVersionHelper.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ CWinVersionHelper::CWinVersionHelper()
1717
pfRtlGetNtVersionNumbers(&dwMajorVer, &dwMinorVer, &dwBuildNumber);
1818
dwBuildNumber &= 0x0ffff;
1919
}
20+
21+
//判断是否在Wine环境中
22+
FARPROC pProc = GetProcAddress(hModNtdll, "wine_get_version");
23+
if (pProc != NULL)
24+
{
25+
m_is_wine = true;
26+
}
27+
2028
::FreeLibrary(hModNtdll);
2129
hModNtdll = NULL;
2230
}
@@ -90,3 +98,8 @@ bool CWinVersionHelper::IsWindows10OrLater() const
9098
{
9199
return m_major_version >= 10;
92100
}
101+
102+
bool CWinVersionHelper::IsWine() const
103+
{
104+
return m_is_wine;
105+
}

TrafficMonitor/WinVersionHelper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class CWinVersionHelper
1212
bool IsWindows8Point1OrLater() const; //判断Windows版本是否大于等于Windows8.1
1313
bool IsWindows8OrLater() const;
1414
bool IsWindows10OrLater() const;
15+
bool IsWine() const;
1516

1617
int GetMajorVersion() const { return m_major_version; }
1718
int GetMinorVersion() const { return m_minor_version; }
@@ -20,4 +21,5 @@ class CWinVersionHelper
2021
int m_major_version{};
2122
int m_minor_version{};
2223
int m_build_number{};
24+
bool m_is_wine{};
2325
};

0 commit comments

Comments
 (0)