HGWebService增加系统托盘
This commit is contained in:
parent
88d11d609e
commit
8135dddf9f
|
@ -88,6 +88,7 @@
|
|||
<ClInclude Include="..\..\..\sdk\webservice\ManagerV2.h" />
|
||||
<ClInclude Include="..\..\..\sdk\webservice\Msg.h" />
|
||||
<ClInclude Include="..\..\..\sdk\webservice\MsgPumpCallback.h" />
|
||||
<ClInclude Include="..\..\..\sdk\webservice\resource.h" />
|
||||
<ClInclude Include="..\..\..\sdk\webservice\SockIoServer.h" />
|
||||
<ClInclude Include="..\..\..\sdk\webservice\SockIoUser.h" />
|
||||
<ClInclude Include="..\..\..\sdk\webservice\WebServer.h" />
|
||||
|
@ -101,6 +102,9 @@
|
|||
<ClInclude Include="..\..\..\third_party\sqlite\sqlite3ext.h" />
|
||||
<ClInclude Include="..\..\..\utility\HGString.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="..\..\..\sdk\webservice\HGWebService.rc" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
|
@ -323,6 +327,9 @@
|
|||
<AdditionalOptions>/ignore:4098,4099,4075 /LTCG %(AdditionalOptions)</AdditionalOptions>
|
||||
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
|
||||
</Link>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>OEM_HUAGAO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -348,6 +355,9 @@
|
|||
<PostBuildEvent>
|
||||
<Command>copy $(OutDir)HGWebService.exe $(SolutionDir)..\..\..\release\win\x86\Release\</Command>
|
||||
</PostBuildEvent>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>OEM_HUAGAO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='HWRelease|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -373,6 +383,9 @@
|
|||
<PostBuildEvent>
|
||||
<Command>copy $(OutDir)HWWebService.exe $(SolutionDir)..\..\..\release\win\x86\Release\</Command>
|
||||
</PostBuildEvent>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>OEM_HANWANG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ZGRelease|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -398,6 +411,9 @@
|
|||
<PostBuildEvent>
|
||||
<Command>copy $(OutDir)ZGWebService.exe $(SolutionDir)..\..\..\release\win\x86\Release\</Command>
|
||||
</PostBuildEvent>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>OEM_ZIGUANG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ZJRelease|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -423,6 +439,9 @@
|
|||
<PostBuildEvent>
|
||||
<Command>copy $(OutDir)ZJWebService.exe $(SolutionDir)..\..\..\release\win\x86\Release\</Command>
|
||||
</PostBuildEvent>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>OEM_ZHONGJING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='LSCRelease|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -448,6 +467,9 @@
|
|||
<PostBuildEvent>
|
||||
<Command>copy $(OutDir)LSCWebService.exe $(SolutionDir)..\..\..\release\win\x86\Release\</Command>
|
||||
</PostBuildEvent>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>OEM_LISICHENG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='CTSRelease|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -473,6 +495,9 @@
|
|||
<PostBuildEvent>
|
||||
<Command>copy $(OutDir)CTSWebService.exe $(SolutionDir)..\..\..\release\win\x86\Release\</Command>
|
||||
</PostBuildEvent>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>OEM_CANGTIAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
|
@ -491,6 +516,9 @@
|
|||
<AdditionalOptions>/ignore:4098,4099,4075 /LTCG %(AdditionalOptions)</AdditionalOptions>
|
||||
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
|
||||
</Link>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>OEM_HUAGAO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
|
@ -516,6 +544,9 @@
|
|||
<PostBuildEvent>
|
||||
<Command>copy $(OutDir)HGWebService.exe $(SolutionDir)..\..\..\release\win\x64\Release\</Command>
|
||||
</PostBuildEvent>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>OEM_HUAGAO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='HWRelease|x64'">
|
||||
<ClCompile>
|
||||
|
@ -541,6 +572,9 @@
|
|||
<PostBuildEvent>
|
||||
<Command>copy $(OutDir)HWWebService.exe $(SolutionDir)..\..\..\release\win\x64\Release\</Command>
|
||||
</PostBuildEvent>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>OEM_HANWANG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ZGRelease|x64'">
|
||||
<ClCompile>
|
||||
|
@ -566,6 +600,9 @@
|
|||
<PostBuildEvent>
|
||||
<Command>copy $(OutDir)ZGWebService.exe $(SolutionDir)..\..\..\release\win\x64\Release\</Command>
|
||||
</PostBuildEvent>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>OEM_ZIGUANG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ZJRelease|x64'">
|
||||
<ClCompile>
|
||||
|
@ -591,6 +628,9 @@
|
|||
<PostBuildEvent>
|
||||
<Command>copy $(OutDir)ZJWebService.exe $(SolutionDir)..\..\..\release\win\x64\Release\</Command>
|
||||
</PostBuildEvent>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>OEM_ZHONGJING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='LSCRelease|x64'">
|
||||
<ClCompile>
|
||||
|
@ -616,6 +656,9 @@
|
|||
<PostBuildEvent>
|
||||
<Command>copy $(OutDir)LSCWebService.exe $(SolutionDir)..\..\..\release\win\x64\Release\</Command>
|
||||
</PostBuildEvent>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>OEM_LISICHENG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='CTSRelease|x64'">
|
||||
<ClCompile>
|
||||
|
@ -641,6 +684,9 @@
|
|||
<PostBuildEvent>
|
||||
<Command>copy $(OutDir)CTSWebService.exe $(SolutionDir)..\..\..\release\win\x64\Release\</Command>
|
||||
</PostBuildEvent>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>OEM_CANGTIAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 中文(简体,中国) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
|
||||
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
|
||||
#pragma code_page(936)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
#if defined(OEM_HANWANG)
|
||||
IDI_ICON_HGWEBSERVICE ICON "res\\HanvonScan_App.ico"
|
||||
#elif defined(OEM_LISICHENG)
|
||||
IDI_ICON_HGWEBSERVICE ICON "res\\LanxumScan_App.ico"
|
||||
#elif defined(OEM_CANGTIAN)
|
||||
IDI_ICON_HGWEBSERVICE ICON "res\\CumtennScan_App.ico"
|
||||
#elif defined(OEM_ZHONGJING)
|
||||
IDI_ICON_HGWEBSERVICE ICON "res\\MicrotekScan_App.ico"
|
||||
#elif defined(OEM_ZIGUANG)
|
||||
IDI_ICON_HGWEBSERVICE ICON "res\\UniScan_App.ico"
|
||||
#else
|
||||
IDI_ICON_HGWEBSERVICE ICON "res\\HuaGoScan_App.ico"
|
||||
#endif
|
||||
|
||||
#endif // 中文(简体,中国) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
|
@ -1,6 +1,11 @@
|
|||
#include "WSServer.h"
|
||||
#include "WSUser.h"
|
||||
#include "base/HGInfo.h"
|
||||
#if defined(HG_CMP_MSC)
|
||||
#include <shellapi.h>
|
||||
extern ULONG taskbarMsgId;
|
||||
extern NOTIFYICONDATAA nid;
|
||||
#endif
|
||||
|
||||
namespace ver_2
|
||||
{
|
||||
|
@ -38,6 +43,10 @@ namespace ver_2
|
|||
user->Open();
|
||||
++m_currUserId;
|
||||
m_vectorUser.push_back(user);
|
||||
#if defined(HG_CMP_MSC)
|
||||
lstrcpyA(nid.szTip, "扫描服务程序(已连接)");
|
||||
Shell_NotifyIconA(NIM_MODIFY, &nid);
|
||||
#endif
|
||||
}
|
||||
|
||||
void WSServer::Command(const WSCmdParam* param)
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
#include "WebServer.h"
|
||||
#include "WebUser.h"
|
||||
#include "base/HGInfo.h"
|
||||
#if defined(HG_CMP_MSC)
|
||||
#include <shellapi.h>
|
||||
extern ULONG taskbarMsgId;
|
||||
extern NOTIFYICONDATAA nid;
|
||||
#endif
|
||||
|
||||
WebServer::WebServer(HGMsgPump msgPump)
|
||||
{
|
||||
|
@ -134,6 +139,14 @@ void WebServer::DisConnect(const DisConnectParam* param)
|
|||
delete pUser;
|
||||
pUser = NULL;
|
||||
}
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
if (m_vectorUser.empty())
|
||||
{
|
||||
lstrcpyA(nid.szTip, "扫描服务程序(未连接)");
|
||||
Shell_NotifyIconA(NIM_MODIFY, &nid);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
|
|
|
@ -66,6 +66,30 @@ static void HGAPI ThreadFunc(HGThread thread, HGPointer param)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
#include <shellapi.h>
|
||||
#include "resource.h"
|
||||
#define WM_TRAY (WM_USER + 100)
|
||||
ULONG taskbarMsgId = 0;
|
||||
NOTIFYICONDATAA nid;
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (WM_DESTROY == uMsg)
|
||||
{
|
||||
Shell_NotifyIconA(NIM_DELETE, &nid);
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
else if (uMsg == taskbarMsgId)
|
||||
{
|
||||
//系统Explorer崩溃重启时,重新加载托盘
|
||||
Shell_NotifyIconA(NIM_ADD, &nid);
|
||||
}
|
||||
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE iPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
|
||||
#else
|
||||
|
@ -75,28 +99,73 @@ int main()
|
|||
HGBase_RegisterCrashFunc(CrashFunc, NULL);
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
HANDLE hMutex = CreateMutexW(NULL, FALSE, L"{1A67EFC9-B41C-4CE6-B95A-A16958E7010F}");
|
||||
assert(NULL != hMutex);
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
MessageBoxA(NULL, "扫描服务已打开", "提示", 0);
|
||||
CloseHandle(hMutex);
|
||||
return -1;
|
||||
}
|
||||
|
||||
WSADATA ws = { 0 };
|
||||
int ret = WSAStartup(MAKEWORD(2, 2), &ws);
|
||||
assert(0 == ret);
|
||||
#endif
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
HGMsgPump msgPump = NULL;
|
||||
HGBase_CreateMsgPump(&msgPump);
|
||||
|
||||
HGThread thread = NULL;
|
||||
HGBase_OpenThread(ThreadFunc, msgPump, &thread);
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
WNDCLASSA wc = { 0 };
|
||||
wc.style = NULL;
|
||||
wc.hIcon = NULL;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.lpfnWndProc = WndProc;
|
||||
wc.hbrBackground = NULL;
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = "HGWebServie";
|
||||
wc.hCursor = NULL;
|
||||
RegisterClassA(&wc);
|
||||
|
||||
HWND hWnd = CreateWindowExA(WS_EX_TOOLWINDOW, "HGWebServie", "HGWebServie", WS_POPUP, CW_USEDEFAULT,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
|
||||
|
||||
taskbarMsgId = RegisterWindowMessageA("TaskbarCreated");
|
||||
nid.cbSize = sizeof(NOTIFYICONDATAA);
|
||||
nid.hWnd = hWnd;
|
||||
nid.uID = IDI_ICON_HGWEBSERVICE;
|
||||
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP | NIF_INFO;
|
||||
nid.uCallbackMessage = WM_TRAY;
|
||||
nid.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON_HGWEBSERVICE));
|
||||
lstrcpyA(nid.szTip, "扫描服务程序(未连接)");
|
||||
Shell_NotifyIconA(NIM_ADD, &nid);
|
||||
|
||||
ShowWindow(hWnd, SW_HIDE);
|
||||
UpdateWindow(hWnd);
|
||||
|
||||
MSG msg;
|
||||
while (GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
HGBase_CloseThread(thread);
|
||||
thread = NULL;
|
||||
|
||||
HGBase_DestroyMsgPump(msgPump);
|
||||
msgPump = NULL;
|
||||
|
||||
curl_global_cleanup();
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
WSACleanup();
|
||||
CloseHandle(hMutex);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 70 KiB |
Binary file not shown.
After Width: | Height: | Size: 67 KiB |
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
|
@ -0,0 +1,16 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ 生成的包含文件。
|
||||
// 供 HGWebService.rc 使用
|
||||
//
|
||||
#define IDI_ICON_HGWEBSERVICE 101
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
Loading…
Reference in New Issue