添加项目文件。

This commit is contained in:
Bruce
2025-02-19 21:09:40 +08:00
parent 11c6392497
commit 3a70be9491
135 changed files with 12698 additions and 0 deletions

179
AppInstaller.sln Normal file
View File

@@ -0,0 +1,179 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppInstaller", "AppInstaller\AppInstaller.vcxproj", "{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}"
ProjectSection(ProjectDependencies) = postProject
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856} = {B897969C-6EA9-4DFC-B7E0-94F1C6D94856}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppLauncher", "AppLauncher\AppLauncher.vcxproj", "{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PackageManager", "PackageManagerAdd\AddPackageSample.vcxproj", "{59131AB7-2A7D-9A09-8223-174C3F5E0F57}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Base64Img", "Base64Img\Base64Img.vcxproj", "{911EDC63-DB20-4D61-9420-583A1C35427F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ToastNotification", "ToastNotification\ToastNotification.vcxproj", "{E10C6272-B876-4DC6-9E13-7CA646863B50}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PriReader2", "PriReader2\PriReader2.vcxproj", "{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CertificateManager", "CertificateManager\CertificateManager.vcxproj", "{22702832-C3FD-48E5-BC7D-3879CA50A2ED}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|Win32 = Release|Win32
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Debug|Any CPU.ActiveCfg = Debug|Win32
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Debug|Any CPU.Build.0 = Debug|Win32
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Debug|ARM.ActiveCfg = Debug|ARM
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Debug|ARM.Build.0 = Debug|ARM
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Debug|Win32.ActiveCfg = Debug|Win32
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Debug|Win32.Build.0 = Debug|Win32
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Debug|x64.ActiveCfg = Debug|x64
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Debug|x64.Build.0 = Debug|x64
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Debug|x86.ActiveCfg = Debug|Win32
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Debug|x86.Build.0 = Debug|Win32
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Release|Any CPU.ActiveCfg = Release|Win32
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Release|Any CPU.Build.0 = Release|Win32
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Release|ARM.ActiveCfg = Release|ARM
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Release|ARM.Build.0 = Release|ARM
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Release|Win32.ActiveCfg = Release|Win32
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Release|Win32.Build.0 = Release|Win32
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Release|x64.ActiveCfg = Release|x64
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Release|x64.Build.0 = Release|x64
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Release|x86.ActiveCfg = Release|Win32
{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}.Release|x86.Build.0 = Release|Win32
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Debug|Any CPU.ActiveCfg = Debug|Win32
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Debug|Any CPU.Build.0 = Debug|Win32
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Debug|ARM.ActiveCfg = Debug|ARM
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Debug|ARM.Build.0 = Debug|ARM
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Debug|Win32.ActiveCfg = Debug|Win32
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Debug|Win32.Build.0 = Debug|Win32
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Debug|x64.ActiveCfg = Debug|x64
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Debug|x64.Build.0 = Debug|x64
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Debug|x86.ActiveCfg = Debug|Win32
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Debug|x86.Build.0 = Debug|Win32
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Release|Any CPU.ActiveCfg = Release|Win32
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Release|Any CPU.Build.0 = Release|Win32
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Release|ARM.ActiveCfg = Release|ARM
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Release|ARM.Build.0 = Release|ARM
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Release|Win32.ActiveCfg = Release|Win32
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Release|Win32.Build.0 = Release|Win32
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Release|x64.ActiveCfg = Release|x64
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Release|x64.Build.0 = Release|x64
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Release|x86.ActiveCfg = Release|Win32
{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}.Release|x86.Build.0 = Release|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Debug|Any CPU.ActiveCfg = Debug|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Debug|Any CPU.Build.0 = Debug|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Debug|ARM.ActiveCfg = Debug|ARM
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Debug|ARM.Build.0 = Debug|ARM
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Debug|Win32.ActiveCfg = Debug|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Debug|Win32.Build.0 = Debug|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Debug|x64.ActiveCfg = Debug|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Debug|x86.ActiveCfg = Debug|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Debug|x86.Build.0 = Debug|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Release|Any CPU.ActiveCfg = Release|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Release|Any CPU.Build.0 = Release|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Release|ARM.ActiveCfg = Release|ARM
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Release|ARM.Build.0 = Release|ARM
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Release|Win32.ActiveCfg = Release|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Release|Win32.Build.0 = Release|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Release|x64.ActiveCfg = Release|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Release|x64.Build.0 = Release|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Release|x86.ActiveCfg = Release|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Release|x86.Build.0 = Release|Win32
{911EDC63-DB20-4D61-9420-583A1C35427F}.Debug|Any CPU.ActiveCfg = Debug|Win32
{911EDC63-DB20-4D61-9420-583A1C35427F}.Debug|Any CPU.Build.0 = Debug|Win32
{911EDC63-DB20-4D61-9420-583A1C35427F}.Debug|ARM.ActiveCfg = Debug|ARM
{911EDC63-DB20-4D61-9420-583A1C35427F}.Debug|ARM.Build.0 = Debug|ARM
{911EDC63-DB20-4D61-9420-583A1C35427F}.Debug|Win32.ActiveCfg = Debug|Win32
{911EDC63-DB20-4D61-9420-583A1C35427F}.Debug|Win32.Build.0 = Debug|Win32
{911EDC63-DB20-4D61-9420-583A1C35427F}.Debug|x64.ActiveCfg = Debug|x64
{911EDC63-DB20-4D61-9420-583A1C35427F}.Debug|x64.Build.0 = Debug|x64
{911EDC63-DB20-4D61-9420-583A1C35427F}.Debug|x86.ActiveCfg = Debug|Win32
{911EDC63-DB20-4D61-9420-583A1C35427F}.Debug|x86.Build.0 = Debug|Win32
{911EDC63-DB20-4D61-9420-583A1C35427F}.Release|Any CPU.ActiveCfg = Release|Win32
{911EDC63-DB20-4D61-9420-583A1C35427F}.Release|Any CPU.Build.0 = Release|Win32
{911EDC63-DB20-4D61-9420-583A1C35427F}.Release|ARM.ActiveCfg = Release|ARM
{911EDC63-DB20-4D61-9420-583A1C35427F}.Release|ARM.Build.0 = Release|ARM
{911EDC63-DB20-4D61-9420-583A1C35427F}.Release|Win32.ActiveCfg = Release|Win32
{911EDC63-DB20-4D61-9420-583A1C35427F}.Release|Win32.Build.0 = Release|Win32
{911EDC63-DB20-4D61-9420-583A1C35427F}.Release|x64.ActiveCfg = Release|x64
{911EDC63-DB20-4D61-9420-583A1C35427F}.Release|x64.Build.0 = Release|x64
{911EDC63-DB20-4D61-9420-583A1C35427F}.Release|x86.ActiveCfg = Release|Win32
{911EDC63-DB20-4D61-9420-583A1C35427F}.Release|x86.Build.0 = Release|Win32
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Debug|Any CPU.ActiveCfg = Debug|Win32
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Debug|Any CPU.Build.0 = Debug|Win32
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Debug|ARM.ActiveCfg = Debug|ARM
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Debug|ARM.Build.0 = Debug|ARM
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Debug|Win32.ActiveCfg = Debug|Win32
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Debug|Win32.Build.0 = Debug|Win32
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Debug|x64.ActiveCfg = Debug|Win32
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Debug|x86.ActiveCfg = Debug|Win32
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Debug|x86.Build.0 = Debug|Win32
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Release|Any CPU.ActiveCfg = Release|Win32
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Release|Any CPU.Build.0 = Release|Win32
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Release|ARM.ActiveCfg = Release|ARM
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Release|ARM.Build.0 = Release|ARM
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Release|Win32.ActiveCfg = Release|Win32
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Release|Win32.Build.0 = Release|Win32
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Release|x64.ActiveCfg = Release|Win32
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Release|x64.Build.0 = Release|Win32
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Release|x86.ActiveCfg = Release|Win32
{E10C6272-B876-4DC6-9E13-7CA646863B50}.Release|x86.Build.0 = Release|Win32
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Debug|Any CPU.ActiveCfg = Debug|Win32
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Debug|Any CPU.Build.0 = Debug|Win32
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Debug|ARM.ActiveCfg = Debug|ARM
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Debug|ARM.Build.0 = Debug|ARM
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Debug|Win32.ActiveCfg = Debug|Win32
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Debug|Win32.Build.0 = Debug|Win32
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Debug|x64.ActiveCfg = Debug|x64
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Debug|x64.Build.0 = Debug|x64
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Debug|x86.ActiveCfg = Debug|Win32
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Debug|x86.Build.0 = Debug|Win32
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Release|Any CPU.ActiveCfg = Release|Win32
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Release|Any CPU.Build.0 = Release|Win32
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Release|ARM.ActiveCfg = Release|ARM
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Release|ARM.Build.0 = Release|ARM
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Release|Win32.ActiveCfg = Release|Win32
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Release|Win32.Build.0 = Release|Win32
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Release|x64.ActiveCfg = Release|x64
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Release|x64.Build.0 = Release|x64
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Release|x86.ActiveCfg = Release|Win32
{B897969C-6EA9-4DFC-B7E0-94F1C6D94856}.Release|x86.Build.0 = Release|Win32
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Debug|Any CPU.ActiveCfg = Debug|Win32
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Debug|Any CPU.Build.0 = Debug|Win32
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Debug|ARM.ActiveCfg = Debug|ARM
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Debug|ARM.Build.0 = Debug|ARM
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Debug|Win32.ActiveCfg = Debug|Win32
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Debug|Win32.Build.0 = Debug|Win32
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Debug|x64.ActiveCfg = Debug|x64
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Debug|x64.Build.0 = Debug|x64
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Debug|x86.ActiveCfg = Debug|Win32
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Debug|x86.Build.0 = Debug|Win32
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Release|Any CPU.ActiveCfg = Release|Win32
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Release|Any CPU.Build.0 = Release|Win32
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Release|ARM.ActiveCfg = Release|ARM
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Release|ARM.Build.0 = Release|ARM
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Release|Win32.ActiveCfg = Release|Win32
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Release|Win32.Build.0 = Release|Win32
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Release|x64.ActiveCfg = Release|x64
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Release|x64.Build.0 = Release|x64
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Release|x86.ActiveCfg = Release|Win32
{22702832-C3FD-48E5-BC7D-3879CA50A2ED}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,529 @@
// Microsoft Visual C++ generated resource script.
//
#include <Windows.h>
#include "resource.h"
/////////////////////////////////////////////////////////////////////////////
// 中文(简体,中国) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
#pragma code_page(936)
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_MAINICON ICON "res/Icons/Main.ico"
ICON_TASKBAR ICON "res/Icons/Main.ico"
ICON_FILE ICON "res/Icons/FileIcon.ico"
ICON_WHITE ICON "res/Icons/IconWhite.ico"
ICON_COLOR ICON "res/Icons/IconColor.ico"
/////////////////////////////////////////////////////////////////////////////
//
// IMAGE
//
BLANK_NORMAL IMAGE "res/Button/Normal/blank.png"
BLANK_LIGHT IMAGE "res/Button/Normal/blank_light.png"
BLANK_PRESS IMAGE "res/Button/Normal/blank_press.png"
MIN_NORMAL IMAGE "res/Button/Normal/min_back.png"
MIN_LIGHT IMAGE "res/Button/Normal/min_light.png"
MIN_PRESS IMAGE "res/Button/Normal/min_press.png"
MAX_NORMAL IMAGE "res/Button/Normal/max_back.png"
MAX_LIGHT IMAGE "res/Button/Normal/max_light.png"
MAX_PRESS IMAGE "res/Button/Normal/max_press.png"
RESTORE_NORMAL IMAGE "res/Button/Normal/restore_back.png"
RESTORE_LIGHT IMAGE "res/Button/Normal/restore_light.png"
RESTORE_PRESS IMAGE "res/Button/Normal/restore_press.png"
CANCEL_NORMAL IMAGE "res/Button/Normal/cancel_back.png"
CANCEL_LIGHT IMAGE "res/Button/Normal/cancel_light.png"
CANCEL_PRESS IMAGE "res/Button/Normal/cancel_press.png"
BLANK_LARGR_NORMAL IMAGE "res/Button/Large/blank.png"
BLANK_LARGR_LIGHT IMAGE "res/Button/Large/blank_light.png"
BLANK_LARGR_PRESS IMAGE "res/Button/Large/blank_press.png"
MIN_LARGR_NORMAL IMAGE "res/Button/Large/min_normal.png"
MIN_LARGE_LIGHT IMAGE "res/Button/Large/min_light.png"
MIN_LARGR_PRESS IMAGE "res/Button/Large/min_press.png"
MAX_LARGE_NORMAL IMAGE "res/Button/Large/max_normal.png"
MAX_LARGE_LIGHT IMAGE "res/Button/Large/max_light.png"
MAX_LARGE_PRESS IMAGE "res/Button/Large/max_press.png"
RESTORE_LARGE_NORMAL IMAGE "res/Button/Large/restore_normal.png"
RESTORE_LARGE_LIGHT IMAGE "res/Button/Large/restore_light.png"
RESTORE_LARGE_PRESS IMAGE "res/Button/Large/restore_press.png"
CANCEL_LARGE_NORMAL IMAGE "res/Button/Large/cancel_window_normal.png"
CANCEL_LARGE_LIGHT IMAGE "res/Button/Large/cancel_window_light.png"
CANCEL_LARGE_PRESS IMAGE "res/Button/Large/cancel_window_press.png"
/////////////////////////////////////////////////////////////////////////////
//
// RCDATA
//
ICON_METRO RCDATA "res/Icons/IconTitleBar.ico"
/////////////////////////////////////////////////////////////////////////////
//
// RT_MANIFEST
//
IDR_MANIFEST1 RT_MANIFEST "res/manifest.xml"
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
IDR_VERSION_ZH_CN VERSIONINFO
FILEVERSION 1,0,1,7
PRODUCTVERSION 1,0,1,7
FILEFLAGSMASK 0x0L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x0L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080404b0"
BEGIN
VALUE "CompanyName", "Bruce Winter"
VALUE "FileDescription", "应用安装程序"
VALUE "FileVersion", "1.0.1.7"
VALUE "LegalCopyright", "\\xA9Bruce Winter. All rights reserved."
VALUE "ProductVersion", "1.0.1.7"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x804, 1200
END
END
IDR_VERSION_EN_US VERSIONINFO
FILEVERSION 1,0,1,7
PRODUCTVERSION 1,0,1,7
FILEFLAGSMASK 0x0L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x0L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e6"
BEGIN
VALUE "CompanyName", "Bruce Winter"
VALUE "FileDescription", "App Installer"
VALUE "FileVersion", "1.0.1.7"
VALUE "LegalCopyright", "\\xA9Bruce Winter. All rights reserved."
VALUE "ProductVersion", "1.0.1.7"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1254
END
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
WIN_TITLE "应用安装程序"
PAGE_LOADING "请稍候..."
PAGE_1_TITLE "安装 %ls"
PAGE_INFO_PUBLISHER "发布者: %ls"
END
STRINGTABLE
BEGIN
PAGE_INFO_VERSION "版本: %ls"
PAGE_FUNCTIONS "功能:"
PAGE_CHECK_RUNWHENREADY "当准备就绪时启动"
PAGE_2_LOADCERT "正在导入证书..."
PAGE_2_INSTALL "正在安装..."
PAGE_3_TITLE "请选择一个有效的安装源以继续"
PAGE_4_TITLE "%ls 已安装完成"
PAGE_5_TITLE "%ls 安装失败"
DIALOG_SELLET_APPX "Windows 应用包文件 (*.appx, *.appxbundle)"
DIALOG_SELLET_UNI "所有文件 (*.*)"
BUTTON_1_SER1 "安装"
BUTTON_3_SER1 "打开文件"
BUTTON_4_SER1 "启动"
BUTTON_5_SER1 "关闭"
DIALOG_WINTITLE "请选择有效的 Windows 应用包文件"
PAGE_1_APPHASINSTALLED "%ls 已安装"
END
STRINGTABLE
BEGIN
PAGE_2_TITLE "正在安装 %ls"
PAGE_1_APP "Microsoft Store 应用"
PAGE_2_LOADING "请稍候..."
PAGE_2_INSTALLING "正在安装 %d%%"
CLHELP_1 "命令行参数说明:\n\n"
CLHELP_2 "\t/?, /Help\n\t显示帮助窗口 (命令行参数说明)\n\n"
CLHELP_3 "\t/DisableFrame\n\t禁止使用自绘的窗口边框\n\n"
CLHELP_4 "\t/Win32Window\n\t不使用 WebUI改用 Win32 窗口\n\n"
CLHELP_5 "\t/Silent\n\t一般情况下会自动安装安装完成后在几秒后结束\n\n"
CLHELP_6 "\t/VerySilent\n\t静默安装安装时不会显示任何信息安装任务完成后自动结束\n\n"
END
STRINGTABLE
BEGIN
textSupportCPU "受支持的处理器架构: "
textSupportSystem "受支持的 Windows 版本: %ls 及更高版本(应用最低运行系统版本: %ls"
textSupportLanguage "受支持的语言: "
textDependency "以下是应用所需依赖包: "
textDependencyItem "%ls, 所需最低版本: %ls"
END
STRINGTABLE
BEGIN
INITWIDTH "656"
INITHEIGHT "412"
LIMITWIDTH "504"
LIMITHEIGHT "412"
END
STRINGTABLE
BEGIN
CLHELP_7 "\t/NoGUI\n\t使用 WSAppPkgIns 安装。安装时会弹出命令行窗口,安装完成后需手动关闭窗口\n\n"
END
STRINGTABLE
BEGIN
internetClient "访问您的 Internet 连接"
internetClientServer "访问您的 Internet 连接并充当服务器"
privateNetworkClientServer "访问您的家庭或工作网络"
documentsLibrary "使用您的文档库"
picturesLibrary "使用您的图片库"
videosLibrary "使用您的视频库"
musicLibrary "使用您的音乐库"
enterpriseAuthentication "使用您的企业域凭据"
sharedUserCertificates "使用您设备上可用的软件和硬件证书"
removableStorage "使用存储在外部存储设备上的数据"
appointments "使用日历中的事件"
contacts "使用您的联系人"
END
STRINGTABLE
BEGIN
phoneCall "访问您设备上的所有电话线路"
backgroundMediaPlayback "在后台播放媒体"
pointOfService "使用条形码扫描仪和磁卡读卡器"
allJoyn "发现并与支持 AllJoyn 的应用和设备交互"
phoneCallHistoryPublic "电话呼叫公开历史记录"
microphone "使用您的麦克风"
offlineMapsManagement "允许应用程序访问离线地图。"
objects3D "以编程方式访问您的 3D 对象"
graphicsCaptureWithoutBorder "允许无边框图形捕获"
bluetooth "与已配对的蓝牙设备通信"
lowLevelDevices "物联网低级总线硬件"
location "使用您的位置"
humaninterfacedevice "使用支持人机接口设备 (HID) 协议的设备"
recordedCallsFolder "访问您的通话记录"
proximity "使用支持近场通信 (NFC) 服务的设备"
webcam "使用您的网络摄像头"
END
STRINGTABLE
BEGIN
graphicsCaptureProgrammatic "允许使用图形捕获"
userNotificationListener "允许应用程序访问通知设置的当前状态"
userDataTasks "允许应用程序访问任务设置的当前状态"
userAccountInformation "访问您帐户的用户名和图片"
usb "访问您的 USB 连接设备"
systemManagement "物联网系统管理"
spatialPerception "查看您当前和过去的周围环境"
smsSend "发送 SMS 和 MMS 消息"
blockedChatMessages "阅读被垃圾邮件过滤器应用阻止的 SMS 和 MMS 消息"
chat "阅读和删除文本消息"
codeGeneration "动态生成代码"
voipCall "使用设备的 IP 语音 (VoIP) 服务"
enterpriseDataPolicy "为您的设备定义企业特定的政策"
inputInjectionBrokered "允许应用程序以编程方式将各种形式的输入注入系统,例如 HID、触摸、笔、键盘或鼠标。"
remoteSystem "允许应用程序访问与用户的 Microsoft 帐户关联的设备列表"
END
STRINGTABLE
BEGIN
inProcessMediaExtension "进程内媒体扩展"
webPlatformMediaExtension "Web 平台媒体扩展"
previewStore "Microsoft Store 预览功能"
confirmAppClose "关闭自己和自己的窗口,并延迟关闭其应用程序"
runFullTrust "使用所有系统资源"
previewUiComposition "预览 Windows UI Composition API 以接收反馈"
slapiQueryLicenseValue "查询软件许可政策"
localSystemServices "在使用最大权限运行的计算机上安装服务"
packageManagement "直接管理其他应用"
packageQuery "搜集有关其他应用的信息"
packagePolicySystem "控制与安装在设备上的应用相关的系统策略"
storeAppInstall "管理应用安装"
appLicensing "应用许可"
broadFileSystemAccess "文件系统"
allowElevation "以管理员身份运行"
unvirtualizedResources "写入在卸载时不会清除的注册表项和文件"
END
STRINGTABLE
BEGIN
extendedExecution "允许应用程序在进入后台后继续执行一段时间的操作"
appointmentsSystem "允许应用读取和修改用户日历上的所有事件"
contactsSystem "允许应用读取已指定为受限或敏感的联系人信息,以及修改现有的联系人信息。"
phoneCallSystem "允许应用访问设备上的所有电话线"
userDataAccounts "可访问电子邮件、联系人、日历等的用户数据帐户"
userDataTasksSystem "可访问系统任务项"
END
#endif // 中文(简体,中国) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// 英语(美国) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
WIN_TITLE "App Installer"
PAGE_LOADING "Please wait..."
PAGE_1_TITLE "Install %ls?"
PAGE_INFO_PUBLISHER "Publisher: %ls"
END
STRINGTABLE
BEGIN
PAGE_INFO_VERSION "Version: %ls"
PAGE_FUNCTIONS "Functions:"
PAGE_CHECK_RUNWHENREADY "Launch when ready"
PAGE_2_LOADCERT "Importing certificates..."
PAGE_2_INSTALL "Installing..."
PAGE_3_TITLE "Please select a valid installation source to continue"
PAGE_4_TITLE "%ls is ready"
PAGE_5_TITLE "%ls is failed"
DIALOG_SELLET_APPX "Windows App Package (*.appx, *.appxbundle)"
DIALOG_SELLET_UNI "All files (*.*)"
BUTTON_1_SER1 "Install"
BUTTON_3_SER1 "Open File"
BUTTON_4_SER1 "Launch"
BUTTON_5_SER1 "Cancel"
DIALOG_WINTITLE "Please select a valid app package file"
PAGE_1_APPHASINSTALLED "%ls has been installed"
END
STRINGTABLE
BEGIN
PAGE_2_TITLE "Installing %s"
PAGE_1_APP "Microsoft Store App"
PAGE_2_LOADING "Please wait..."
PAGE_2_INSTALLING "Installing %d%%"
CLHELP_1 "Usage:\n\n"
CLHELP_2 "\t/?, /Help\n\tDisplay help window (command line parameter description).\n\n"
CLHELP_3 "\t/DisableFrame\n\tDisable the use of self-drawn window borders.\n\n"
CLHELP_4 "\t/Win32Window\n\tDo not use WebUI, use Win32 window instead.\n\n"
CLHELP_5 "\t/Silent\n\tUnder normal circumstances, it will be automatically installed and will end after a few seconds.\n\n"
CLHELP_6 "\t/VerySilent\n\tSilent installation, no information will be displayed during installation, and the installation task will automatically end after completion.\n\n"
END
STRINGTABLE
BEGIN
textSupportCPU "Supported processor architectures: "
textSupportSystem "Supported Windows versions: %ls and later (minimum running system version of the app: %ls)"
textSupportLanguage "Supported languages:"
textDependency "The following are the dependencies required by the application:"
textDependencyItem "%ls, minimum required version: %ls"
END
STRINGTABLE
BEGIN
CLHELP_7 "\t/NoGUI\n\tUse WSAppPkgIns to install. A command line window will pop up during installation, and you need to manually close the window after installation.\n\n"
END
STRINGTABLE
BEGIN
internetClient "Access your Internet connection"
internetClientServer "Access your Internet connection and act as a server."
privateNetworkClientServer "Access your home or work networks"
documentsLibrary "Use your documents library"
picturesLibrary "Use your pictures library"
videosLibrary "Use your video library"
musicLibrary "Use your music library"
enterpriseAuthentication "Use your enterprise domain credentials"
sharedUserCertificates "Use the software and hardware certificates available on your device"
removableStorage "Use data stored on an external storage device"
appointments "Use the appointments in your calendar"
contacts "Use your contacts"
END
STRINGTABLE
BEGIN
phoneCall "Access all the phone lines on your device"
backgroundMediaPlayback "Play media in the background"
pointOfService "Use barcode scanners and magnetic card readers"
allJoyn "Discover and interact with AllJoyn enabled apps and devices"
phoneCallHistoryPublic "Phone Calls Public History"
microphone "Use your microphone"
offlineMapsManagement "Allows the application to access offline maps."
objects3D "Programmatically access your 3D Objects"
graphicsCaptureWithoutBorder "Allows borderless graphics capture"
bluetooth "Communicate with already paired Bluetooth devices"
lowLevelDevices "IoT Low-Level Bus Hardware"
location "Use your location"
humaninterfacedevice "Use your devices that support the Human Interface Device (HID) protocol"
recordedCallsFolder "Access your recorded calls"
proximity "Use devices that support Near Field Communication (NFC) services"
webcam "Use your webcam"
END
STRINGTABLE
BEGIN
graphicsCaptureProgrammatic "Allows use of graphics capture"
userNotificationListener
"Allows an application to access the current state of notification settings"
userDataTasks "Allows an application to access the current state of task settings"
userAccountInformation "Access to your Account's username and picture"
usb "Access your USB connected devices"
systemManagement "IoT System Adminstration"
spatialPerception "See your current and past surroundings"
smsSend "Send SMS and MMS messages"
blockedChatMessages "Read SMS and MMS messages that have been blocked by the Spam Filter app"
chat "Read and delete Text Messages"
codeGeneration "Generate code dynamically"
voipCall "Use your device's voice over IP (VoIP) services"
enterpriseDataPolicy "Define enterprise-specific policies for your device"
inputInjectionBrokered "Allows an application to programmatically inject various forms of input into the system, such as HID, touch, pen, keyboard, or mouse."
remoteSystem "Allows the application to access the list of devices associated with the user's Microsoft account"
END
STRINGTABLE
BEGIN
inProcessMediaExtension "In-process Media Extension"
webPlatformMediaExtension "Web Platform Media Extension"
previewStore "Microsoft Store Preview Features"
confirmAppClose "Close themselves and their own windows, and delay the closing of their app"
runFullTrust "Uses all system resources"
previewUiComposition "Preview the Windows UI Composition API to receive feedback"
slapiQueryLicenseValue "Query software licensing policies"
localSystemServices "Install a service on the machine that runs with maximum privileges"
packageManagement "Manage other apps directly"
packageQuery "Gather information about other apps"
packagePolicySystem "Control system policies related to apps that are installed on the device"
storeAppInstall "Store app installation"
appLicensing "App Licensing"
broadFileSystemAccess "File System"
allowElevation "Run as administrator"
unvirtualizedResources "Write registry entries and files that are not cleaned up on uninstall"
END
STRINGTABLE
BEGIN
extendedExecution "Allows the app to continue to perform operations for a period of time after entering the background"
appointmentsSystem "Allows the app to read and modify all appointments on the user's calendar"
contactsSystem "Allows the app to read information about contacts that have been designated as restricted or sensitive, and to modify existing contact information."
phoneCallSystem "Allows the app to access all phone lines on the device"
userDataAccounts "Allows the program to access user data such as email, contacts, calendar, etc."
userDataTasksSystem "Access to system tasks"
END
#endif // 英语(美国) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,333 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D417C165-3F17-40C4-8C7B-0F5AACEF62C5}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>AppInstaller</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>($SolutionDir)\AppLauncher;($SolutionDir)\PackageManagerAdd;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\AppLauncher;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PackageManagerAdd;($SolutionDir)\Base64Img;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\Base64Img;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ToastNotification;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PriReader2;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\CertificateManager;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>($SolutionDir)\AppLauncher;($SolutionDir)\PackageManagerAdd;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\AppLauncher;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PackageManagerAdd;($SolutionDir)\Base64Img;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\Base64Img;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ToastNotification;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PriReader2;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\CertificateManager;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>($SolutionDir)\AppLauncher;($SolutionDir)\PackageManagerAdd;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\AppLauncher;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PackageManagerAdd;($SolutionDir)\Base64Img;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\Base64Img;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ToastNotification;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PriReader2;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\CertificateManager;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>($SolutionDir)\AppLauncher;($SolutionDir)\PackageManagerAdd;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\AppLauncher;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PackageManagerAdd;($SolutionDir)\Base64Img;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\Base64Img;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ToastNotification;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PriReader2;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\CertificateManager;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>shlwapi.lib;dwmapi.lib;crypt32.lib;$(OutDir)PackageManager.lib;$(OutDir)AppLauncher.lib;$(OutDir)Base64Img.lib;$(OutDir)ToastNotification.lib;$(OutDir)PriReader2.lib;$(OutDir)CertificateManager.lib</AdditionalDependencies>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>shlwapi.lib;dwmapi.lib;crypt32.lib;$(OutDir)PackageManager.lib;$(OutDir)AppLauncher.lib;$(OutDir)Base64Img.lib;$(OutDir)ToastNotification.lib;$(OutDir)PriReader2.lib;$(OutDir)CertificateManager.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>false</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WholeProgramOptimization>false</WholeProgramOptimization>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>shlwapi.lib;dwmapi.lib;crypt32.lib;$(OutDir)PackageManager.lib;$(OutDir)AppLauncher.lib;$(OutDir)Base64Img.lib;$(OutDir)ToastNotification.lib;$(OutDir)PriReader2.lib;$(OutDir)CertificateManager.lib</AdditionalDependencies>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
</Link>
<Manifest>
<EnableDpiAwareness>false</EnableDpiAwareness>
</Manifest>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>shlwapi.lib;dwmapi.lib;crypt32.lib;$(OutDir)PackageManager.lib;$(OutDir)AppLauncher.lib;$(OutDir)Base64Img.lib;$(OutDir)ToastNotification.lib;$(OutDir)PriReader2.lib;$(OutDir)CertificateManager.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\AppLauncher\AppLauncher.h" />
<ClInclude Include="..\Base64Img\Base64Img.h" />
<ClInclude Include="..\CertificateManager\CertificateManager.h" />
<ClInclude Include="..\PackageManagerAdd\PackageManager.h" />
<ClInclude Include="..\PriReader2\PriReader2.h" />
<ClInclude Include="base64logo.h" />
<ClInclude Include="initread.h" />
<ClInclude Include="pkgcode.h" />
<ClInclude Include="pkginfo.h" />
<ClInclude Include="priread.h" />
<ClInclude Include="localeex.h" />
<ClInclude Include="res2.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="mainwnd.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="AppInstaller.rc" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing">
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Drawing.dll</HintPath>
</Reference>
<Reference Include="System.Drawing.Design">
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Drawing.Design.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms">
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Windows.Forms.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.Linq.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AppLauncher\AppLauncher.vcxproj">
<Project>{285130bc-cbf1-4c7a-a28d-6f5ee6c68384}</Project>
</ProjectReference>
<ProjectReference Include="..\Base64Img\Base64Img.vcxproj">
<Project>{911edc63-db20-4d61-9420-583a1c35427f}</Project>
</ProjectReference>
<ProjectReference Include="..\CertificateManager\CertificateManager.vcxproj">
<Project>{22702832-c3fd-48e5-bc7d-3879ca50a2ed}</Project>
</ProjectReference>
<ProjectReference Include="..\PackageManagerAdd\AddPackageSample.vcxproj">
<Project>{59131ab7-2a7d-9a09-8223-174c3f5e0f57}</Project>
</ProjectReference>
<ProjectReference Include="..\PriReader2\PriReader2.vcxproj">
<Project>{b897969c-6ea9-4dfc-b7e0-94f1c6d94856}</Project>
</ProjectReference>
<ProjectReference Include="..\ToastNotification\ToastNotification.vcxproj">
<Project>{e10c6272-b876-4dc6-9e13-7ca646863b50}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Image Include="res\Button\Large\blank.png" />
<Image Include="res\Button\Large\blank_light.png" />
<Image Include="res\Button\Large\blank_press.png" />
<Image Include="res\Button\Large\cancel_window_light.png" />
<Image Include="res\Button\Large\cancel_window_normal.png" />
<Image Include="res\Button\Large\cancel_window_press.png" />
<Image Include="res\Button\Large\max_light.png" />
<Image Include="res\Button\Large\max_normal.png" />
<Image Include="res\Button\Large\max_press.png" />
<Image Include="res\Button\Large\min_light.png" />
<Image Include="res\Button\Large\min_normal.png" />
<Image Include="res\Button\Large\min_press.png" />
<Image Include="res\Button\Large\restore_light.png" />
<Image Include="res\Button\Large\restore_normal.png" />
<Image Include="res\Button\Large\restore_press.png" />
<Image Include="res\Button\Normal\blank.png" />
<Image Include="res\Button\Normal\blank_light.png" />
<Image Include="res\Button\Normal\blank_press.png" />
<Image Include="res\Button\Normal\cancel_back.png" />
<Image Include="res\Button\Normal\cancel_light.png" />
<Image Include="res\Button\Normal\cancel_press.png" />
<Image Include="res\Button\Normal\max_back.png" />
<Image Include="res\Button\Normal\max_light.png" />
<Image Include="res\Button\Normal\max_press.png" />
<Image Include="res\Button\Normal\min_back.png" />
<Image Include="res\Button\Normal\min_light.png" />
<Image Include="res\Button\Normal\min_press.png" />
<Image Include="res\Button\Normal\restore_back.png" />
<Image Include="res\Button\Normal\restore_light.png" />
<Image Include="res\Button\Normal\restore_press.png" />
<Image Include="res\Icons\FileIcon.ico" />
<Image Include="res\Icons\IconColor.ico" />
<Image Include="res\Icons\IconTitleBar.ico" />
<Image Include="res\Icons\IconWhite.ico" />
<Image Include="res\Icons\Main.ico" />
</ItemGroup>
<ItemGroup>
<Xml Include="res\manifest.xml" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,178 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="res2.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="pkgcode.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\AppLauncher\AppLauncher.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\PackageManagerAdd\PackageManager.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="base64logo.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\Base64Img\Base64Img.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="priread.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="localeex.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="pkginfo.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\PriReader2\PriReader2.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\CertificateManager\CertificateManager.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="initread.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="mainwnd.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="AppInstaller.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="res\Icons\Main.ico">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Icons\FileIcon.ico">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Icons\IconWhite.ico">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Icons\IconColor.ico">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\blank.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\blank_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\blank_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\min_back.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\min_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\min_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\max_back.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\max_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\max_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\restore_back.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\restore_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\restore_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\cancel_back.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\cancel_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\cancel_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\blank.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\blank_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\blank_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\min_normal.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\min_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\min_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\max_normal.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\max_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\max_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\restore_normal.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\restore_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\restore_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\cancel_window_normal.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\cancel_window_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\cancel_window_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Icons\IconTitleBar.ico">
<Filter>资源文件</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<Xml Include="res\manifest.xml" />
</ItemGroup>
</Project>

291
AppInstaller/base64logo.h Normal file
View File

@@ -0,0 +1,291 @@
#pragma once
#include "Base64Img.h"
#include <iostream>
#include <map>
#include <regex>
#include "pkgcode.h"
#include "priread.h"
std::string GetFileNameWithoutExtension (LPCSTR filePath)
{
char pathCopy [MAX_PATH];
lstrcpynA (pathCopy, filePath, MAX_PATH);
char *fileName = PathFindFileNameA (pathCopy);
PathRemoveExtensionA (fileName);
return std::string (fileName);
}
std::wstring GetFileNameWithoutExtension (LPCWSTR filePath)
{
wchar_t pathCopy [MAX_PATH];
lstrcpynW (pathCopy, filePath, MAX_PATH);
wchar_t *fileName = PathFindFileNameW (pathCopy);
PathRemoveExtensionW (fileName);
return std::wstring (fileName);
}
std::string GetFileNameWithoutExtension (const std::string &filePath)
{
return GetFileNameWithoutExtension (filePath.c_str ());
}
std::wstring GetFileNameWithoutExtension (const std::wstring &filePath)
{
return GetFileNameWithoutExtension (filePath.c_str ());
}
std::string GetLogoBase64FromReader (PackageReader &reader, IStream **getOutput = NULL)
{
if (!&reader) return std::string ("");
if (!reader.isAvailable ()) return std::string ("");
std::wstring logoPath = reader.getPropertyLogo ();
if (logoPath.empty () || logoPath.length () == 0) return std::string ("");
PriReader pri (reader.getPriFileStream ());
if (pri.isAvailable ())
{
std::wstring logoPathFromPri = pri.findFilePathValue (logoPath);
if (!logoPathFromPri.empty () && logoPath.length () > 0) logoPath = logoPathFromPri;
}
IStream *imgfile = reader.extractFileToStream (logoPath);
if (getOutput) *getOutput = imgfile;
if (!imgfile)
{
std::wstring fileName = GetFileNameWithoutExtension (logoPath);
IAppxPackageReader *appxreader = reader.getAppxPackageReader ();
CComPtr <IAppxFilesEnumerator> fe = NULL;
HRESULT hr = appxreader->GetPayloadFiles (&fe);
if (SUCCEEDED (hr) && fe)
{
std::vector <std::wstring> files;
BOOL hasCurrent = FALSE;
hr = fe->GetHasCurrent (FALSE);
while (SUCCEEDED (hr) && hasCurrent)
{
CComPtr <IAppxFile> ifile = NULL;
hr = fe->GetCurrent (&ifile);
if (SUCCEEDED (hr) && ifile)
{
LPWSTR lpstr = NULL;
if (SUCCEEDED (ifile->GetName (&lpstr)) && lpstr)
{
std::wstring strWillSearch = StringToUpper (StringTrim (lpstr));
std::wstring strWillToSearch = StringToUpper (StringTrim (fileName));
if (StrStrW (strWillSearch.c_str (), strWillToSearch.c_str ()))
{
bool isFind = LabelEqual (PathFindExtensionW (lpstr), L".png");
if (!isFind) isFind = LabelEqual (PathFindExtensionW (lpstr), L".jpg");
if (!isFind) isFind = LabelEqual (PathFindExtensionW (lpstr), L".jpeg");
if (!isFind) isFind = LabelEqual (PathFindExtensionW (lpstr), L".bmp");
if (isFind)
{
std::wstring temp (L"");
if (lpstr) temp += lpstr;
if (temp.length () > 0) push_no_repeat (files, temp);
}
}
}
}
}
bool isFindSuit = false;
{
std::map <int, std::wstring> scaleFiles;
std::wregex pattern (L"(scale-(\\d+))");
for (auto it : files)
{
if (StrStrW (it.c_str (), L"contrast-")) continue;
std::wsmatch match;
if (std::regex_search (it, match, pattern))
{
int temp = StrToIntW (match [1].str ().c_str ());
if (!temp)
{
scaleFiles [temp] = it;
}
}
}
if (scaleFiles.find (GetDPI ()) != scaleFiles.end ())
{
isFindSuit = true;
logoPath = scaleFiles [GetDPI ()];
}
else
{
bool isFindScale = false;
for (auto it : scaleFiles)
{
if (it.first >= GetDPI ())
{
isFindScale = true;
logoPath = scaleFiles [GetDPI ()];
break;
}
}
if (!isFindScale)
{
for (auto it : scaleFiles)
{
if (it.first >= 100)
{
isFindScale = true;
logoPath = scaleFiles [GetDPI ()];
break;
}
}
}
if (!isFindScale)
{
for (auto it : scaleFiles)
{
isFindScale = true;
logoPath = scaleFiles [GetDPI ()];
break;
}
}
isFindSuit = isFindScale;
}
}
if (!isFindSuit)
{
std::map <int, std::wstring> scaleFiles;
std::wregex pattern (L"(scale-(\\d+))");
for (auto it : files)
{
if (StrStrW (it.c_str (), L"contrast-white")) continue;
std::wsmatch match;
if (std::regex_search (it, match, pattern))
{
int temp = StrToIntW (match [1].str ().c_str ());
if (!temp)
{
scaleFiles [temp] = it;
}
}
}
if (scaleFiles.find (GetDPI ()) != scaleFiles.end ())
{
isFindSuit = true;
logoPath = scaleFiles [GetDPI ()];
}
else
{
bool isFindScale = false;
for (auto it : scaleFiles)
{
if (it.first >= GetDPI ())
{
isFindScale = true;
logoPath = scaleFiles [GetDPI ()];
break;
}
}
if (!isFindScale)
{
for (auto it : scaleFiles)
{
if (it.first >= 100)
{
isFindScale = true;
logoPath = scaleFiles [GetDPI ()];
break;
}
}
}
if (!isFindScale)
{
for (auto it : scaleFiles)
{
isFindScale = true;
logoPath = scaleFiles [GetDPI ()];
break;
}
}
isFindSuit = isFindScale;
}
}
if (!isFindSuit)
{
std::map <int, std::wstring> scaleFiles;
std::wregex pattern (L"(scale-(\\d+))");
for (auto it : files)
{
if (StrStrW (it.c_str (), L"contrast-black")) continue;
std::wsmatch match;
if (std::regex_search (it, match, pattern))
{
int temp = StrToIntW (match [1].str ().c_str ());
if (!temp)
{
scaleFiles [temp] = it;
}
}
}
if (scaleFiles.find (GetDPI ()) != scaleFiles.end ())
{
isFindSuit = true;
logoPath = scaleFiles [GetDPI ()];
}
else
{
bool isFindScale = false;
for (auto it : scaleFiles)
{
if (it.first >= GetDPI ())
{
isFindScale = true;
logoPath = scaleFiles [GetDPI ()];
break;
}
}
if (!isFindScale)
{
for (auto it : scaleFiles)
{
if (it.first >= 100)
{
isFindScale = true;
logoPath = scaleFiles [GetDPI ()];
break;
}
}
}
if (!isFindScale)
{
for (auto it : scaleFiles)
{
isFindScale = true;
logoPath = scaleFiles [GetDPI ()];
break;
}
}
isFindSuit = isFindScale;
}
}
if (!isFindSuit)
{
for (auto it : files)
{
logoPath = std::wstring (L"") + it;
break;
}
}
}
imgfile = reader.extractFileToStream (logoPath);
}
if (getOutput) *getOutput = imgfile;
if (!imgfile) return std::string ("");
std::string b64res ("");
LPSTR szRes = StreamToBase64 (imgfile);
if (!getOutput)
{
if (imgfile)
{
imgfile->Release ();
imgfile = NULL;
}
}
if (!szRes) return b64res;
if (szRes) b64res += szRes;
free (szRes);
if (b64res.length () > 0)
{
b64res = "data:image/png;base64," + b64res;
}
return b64res;
}

194
AppInstaller/initread.h Normal file
View File

@@ -0,0 +1,194 @@
#pragma once
#include <Windows.h>
#include <string>
#include <cstdlib>
#include <cstdio>
#include "pkgcode.h"
unsigned _wtou (const wchar_t *str)
{
unsigned value = 0;
if (str)
{
swscanf (str, L"%u", &value);
}
return value;
}
unsigned long _wtoul (const wchar_t *str)
{
unsigned value = 0;
if (str)
{
swscanf (str, L"%'u", &value);
}
return value;
}
unsigned long long _wtou64 (const wchar_t *str)
{
unsigned long long value = 0;
if (str)
{
swscanf (str, L"%llu", &value);
}
return value;
}
double _wtod (const wchar_t *str)
{
if (!str || !*str) return 0.0; // 避免空指针或空字符串
double value = 0.0;
if (swscanf (str, L"%lg", &value) == 1)
{
return value;
}
return 0.0; // 解析失败时返回 0.0
}
std::string GetPrivateProfileStringA (std::string filePath, std::string section, std::string key, LPCSTR defaultValue = "")
{
char buf [32768] = {0};
GetPrivateProfileStringA (section.c_str (), key.c_str (), defaultValue, buf, 32767, filePath.c_str ());
return buf;
}
std::wstring GetPrivateProfileStringW (std::wstring filePath, std::wstring section, std::wstring key, LPCWSTR defaultValue = L"")
{
WCHAR buf [32768] = {0};
GetPrivateProfileStringW (section.c_str (), key.c_str (), defaultValue, buf, 32767, filePath.c_str ());
return buf;
}
UINT GetPrivateProfileIntA (std::string filePath, std::string section, std::string key, INT defaultValue = 0)
{
return GetPrivateProfileIntA (section.c_str (), key.c_str (), defaultValue, filePath.c_str ());
}
UINT GetPrivateProfileIntW (std::wstring filePath, std::wstring section, std::wstring key, INT defaultValue = 0)
{
return GetPrivateProfileIntW (section.c_str (), key.c_str (), defaultValue, filePath.c_str ());
}
class WInitFile
{
private:
std::wstring m_filePath;
template <class t> std::wstring numberToString (t src, std::wstring format)
{
WCHAR buf [256] = {0};
swprintf (buf, format.c_str (), src);
return buf;
}
public:
WInitFile (LPCWSTR lpswFilePath = L""): m_filePath (lpswFilePath) {}
void setFilePath (std::wstring filePath)
{
this->m_filePath = L"";
this->m_filePath += filePath;
}
std::wstring getFilePath () const { return this->m_filePath; }
std::wstring readStringValue (std::wstring section, std::wstring key, std::wstring defaultValue = L"")
{
return GetPrivateProfileStringW (this->m_filePath, section, key, defaultValue.c_str ());
}
bool readBoolValue (std::wstring section, std::wstring key, bool defaultValue = false)
{
std::wstring res = this->readStringValue (section, key, (defaultValue ? L"true" : L"false"));
if (LabelEqual (res, L"true") || LabelEqual (res, L"zhen") || LabelEqual (res, L"1") || LabelEqual (res, L"yes") || LabelEqual (res, L""))
{
return true;
}
else if (LabelEqual (res, L"false") || LabelEqual (res, L"jia") || LabelEqual (res, L"0") || LabelEqual (res, L"no") || LabelEqual (res, L""))
{
return false;
}
return false;
}
int readIntValue (std::wstring section, std::wstring key, int defaultValue = 0)
{
WCHAR buf [256] = {0};
swprintf (buf, L"%d", defaultValue);
return _wtoi (this->readStringValue (section, key, buf).c_str ());
}
unsigned readUIntValue (std::wstring section, std::wstring key, unsigned defaultValue = 0)
{
WCHAR buf [256] = {0};
swprintf (buf, L"%u", defaultValue);
return _wtou (this->readStringValue (section, key, buf).c_str ());
}
long readLongValue (std::wstring section, std::wstring key, long defaultValue = 0)
{
WCHAR buf [256] = {0};
swprintf (buf, L"%ld", defaultValue);
return _wtol (this->readStringValue (section, key, buf).c_str ());
}
unsigned long readULongValue (std::wstring section, std::wstring key, unsigned long defaultValue = 0)
{
WCHAR buf [256] = {0};
swprintf (buf, L"%lu", defaultValue);
return _wtoul (this->readStringValue (section, key, buf).c_str ());
}
long long readLongLongValue (std::wstring section, std::wstring key, long long defaultValue = 0)
{
WCHAR buf [256] = {0};
swprintf (buf, L"%lld", defaultValue);
return _wtoll (this->readStringValue (section, key, buf).c_str ());
}
unsigned long long readULongLongValue (std::wstring section, std::wstring key, unsigned long long defaultValue = 0)
{
WCHAR buf [256] = {0};
swprintf (buf, L"%llu", defaultValue);
return _wtou64 (this->readStringValue (section, key, buf).c_str ());
}
float readFloatValue (std::wstring section, std::wstring key, float defaultValue = 0)
{
WCHAR buf [256] = {0};
swprintf (buf, L"%f", defaultValue);
return _wtof (this->readStringValue (section, key, buf).c_str ());
}
double readDoubleValue (std::wstring section, std::wstring key, double defaultValue = 0)
{
WCHAR buf [256] = {0};
swprintf (buf, L"%lf", defaultValue);
return _wtod (this->readStringValue (section, key, buf).c_str ());
}
bool writeStringValue (std::wstring section, std::wstring key, std::wstring value)
{
return WritePrivateProfileStringW (section.c_str (), key.c_str (), value.c_str (), this->m_filePath.c_str ());
}
bool writeBoolValue (std::wstring section, std::wstring key, bool value)
{
return this->writeBoolValue (section, key, value ? L"true" : L"false");
}
bool writeIntValue (std::wstring section, std::wstring key, int value)
{
return this->writeStringValue (section, key, this->numberToString (value, L"%d"));
}
bool writeUIntValue (std::wstring section, std::wstring key, unsigned value)
{
return this->writeStringValue (section, key, this->numberToString (value, L"%u"));
}
bool writeLongValue (std::wstring section, std::wstring key, long value)
{
return this->writeStringValue (section, key, this->numberToString (value, L"%ld"));
}
bool writeULongValue (std::wstring section, std::wstring key, unsigned long value)
{
return this->writeStringValue (section, key, this->numberToString (value, L"%lu"));
}
bool writeLongLongValue (std::wstring section, std::wstring key, long long value)
{
return this->writeStringValue (section, key, this->numberToString (value, L"%lld"));
}
bool writeULongLongValue (std::wstring section, std::wstring key, unsigned long long value)
{
return this->writeStringValue (section, key, this->numberToString (value, L"%llu"));
}
bool writeFloatValue (std::wstring section, std::wstring key, float value)
{
return this->writeStringValue (section, key, this->numberToString (value, L"%g"));
}
bool writeDoublegValue (std::wstring section, std::wstring key, double value)
{
return this->writeStringValue (section, key, this->numberToString (value, L"%g"));
}
bool isAvaliable ()
{
return IsFileExists (this->m_filePath);
}
};

111
AppInstaller/localeex.h Normal file
View File

@@ -0,0 +1,111 @@
#pragma once
#include <Windows.h>
#include <WinNls.h>
#include <stringapiset.h>
#include <string>
std::wstring StringToWString (const std::string &str, UINT codePage = CP_ACP)
{
if (str.empty ()) return std::wstring ();
int len = MultiByteToWideChar (codePage, 0, str.c_str (), -1, nullptr, 0);
if (len == 0) return std::wstring ();
std::wstring wstr (len - 1, L'\0');
MultiByteToWideChar (codePage, 0, str.c_str (), -1, &wstr [0], len);
return wstr;
}
std::string GetLocaleInfoA (LCID code, LCTYPE type)
{
char buf [LOCALE_NAME_MAX_LENGTH] = {0};
GetLocaleInfoA (code, type, buf, LOCALE_NAME_MAX_LENGTH);
return buf;
}
std::wstring GetLocaleInfoW (LCID code, LCTYPE type)
{
WCHAR buf [LOCALE_NAME_MAX_LENGTH] = {0};
GetLocaleInfoW (code, type, buf, LOCALE_NAME_MAX_LENGTH);
return buf;
}
int GetLocaleInfoEx (std::wstring lpLocaleName, LCTYPE type, std::wstring &output)
{
WCHAR buf [LOCALE_NAME_MAX_LENGTH] = {0};
int res = GetLocaleInfoEx (lpLocaleName.c_str (), type, buf, LOCALE_NAME_MAX_LENGTH);
if (&output) output = std::wstring (buf);
return res;
}
BOOL SetLocaleInfoA (LCID code, LCTYPE type, const std::string lcData)
{
return SetLocaleInfoA (code, type, lcData.c_str ());
}
BOOL SetLocaleInfoW (LCID code, LCTYPE type, const std::wstring lcData)
{
return SetLocaleInfoW (code, type, lcData.c_str ());
}
std::string GetLocaleRestrictedCodeFromLcidA (LCID lcid)
{
return GetLocaleInfoA (lcid, 89);
}
std::wstring GetLocaleRestrictedCodeFromLcidW (LCID lcid)
{
return GetLocaleInfoW (lcid, 89);
}
std::string GetLocaleElaboratedCodeFromLcidA (LCID lcid)
{
return GetLocaleInfoA (lcid, 90);
}
std::wstring GetLocaleElaboratedCodeFromLcidW (LCID lcid)
{
return GetLocaleInfoW (lcid, 90);
}
LCID LocaleCodeToLcidW (LPCWSTR localeCode)
{
BYTE buf [LOCALE_NAME_MAX_LENGTH * sizeof (WCHAR)] = {0};
int res = GetLocaleInfoEx (localeCode, LOCALE_RETURN_NUMBER | LOCALE_ILANGUAGE, (LPWSTR)buf, LOCALE_NAME_MAX_LENGTH);
LCID lcid = *((LCID *)buf);
return lcid;
}
LCID LocaleCodeToLcidA (LPCSTR localeCode)
{
std::wstring lcWide = StringToWString (std::string (localeCode));
return LocaleCodeToLcidW (lcWide.c_str ());
}
std::string GetLocaleRestrictedCodeA (LPCSTR lc)
{
return GetLocaleInfoA (LocaleCodeToLcidA (lc), 89);
}
std::string GetLocaleRestrictedCodeA (const std::string lc)
{
return GetLocaleInfoA (LocaleCodeToLcidA (lc.c_str ()), 89);
}
std::wstring GetLocaleRestrictedCodeW (LPCWSTR lc)
{
return GetLocaleInfoW (LocaleCodeToLcidW (lc), 89);
}
std::wstring GetLocaleRestrictedCodeW (const std::wstring lc)
{
return GetLocaleInfoW (LocaleCodeToLcidW (lc.c_str ()), 89);
}
std::string GetLocaleElaboratedCodeA (LPCSTR lc)
{
return GetLocaleInfoA (LocaleCodeToLcidA (lc), 90);
}
std::string GetLocaleElaboratedCodeA (const std::string lc)
{
return GetLocaleInfoA (LocaleCodeToLcidA (lc.c_str ()), 90);
}
std::wstring GetLocaleElaboratedCodeW (LPCWSTR lc)
{
return GetLocaleInfoW (LocaleCodeToLcidW (lc), 90);
}
std::wstring GetLocaleElaboratedCodeW (const std::wstring lc)
{
return GetLocaleInfoW (LocaleCodeToLcidW (lc.c_str ()), 90);
}
std::string LcidToLocaleCodeA (LCID lcid, char divide = '-')
{
return GetLocaleRestrictedCodeFromLcidA (lcid) + divide + GetLocaleElaboratedCodeFromLcidA (lcid);
}
std::wstring LcidToLocaleCodeW (LCID lcid, WCHAR divide = L'-')
{
return GetLocaleRestrictedCodeFromLcidW (lcid) + divide + GetLocaleElaboratedCodeFromLcidW (lcid);
}

1464
AppInstaller/mainwnd.cpp Normal file

File diff suppressed because it is too large Load Diff

2062
AppInstaller/pkgcode.h Normal file

File diff suppressed because it is too large Load Diff

196
AppInstaller/pkginfo.h Normal file
View File

@@ -0,0 +1,196 @@
#pragma once
#include "pkgcode.h"
#include "priread.h"
#include <algorithm>
// 用于处理信息
struct PackageInfomation
{
struct Identity
{
std::wstring name = L"";
std::wstring publisher = L"";
VERSION version;
std::vector <APPX_PACKAGE_ARCHITECTURE> architectures;
} identities;
struct Resources
{
std::vector <std::wstring> languages;
} resources;
struct Prerequisites
{
VERSION osMinVersion;
} prerequisites;
struct Property
{
std::wstring name = L"";
std::wstring description = L"";
std::wstring publisher = L"";
std::string logoBase64 = "";
CComPtr <IStream> logoStream = NULL;
} properties;
std::vector <appmap> applications;
std::vector <std::wstring> capabilities;
std::vector <DEPINFO> dependencies;
bool isMsResourceLabel (LPCSTR lpstr)
{
if (!lpstr) return false;
const std::string mslabel ("ms-resource:");
std::string sub = StringTrim (std::string (lpstr)).substr (0, mslabel.length ());
return LabelEqual (sub, mslabel);
}
bool isMsResourceLabel (LPCWSTR lpstr)
{
if (!lpstr) return false;
const std::wstring mslabel (L"ms-resource:");
std::wstring sub = StringTrim (std::wstring (lpstr)).substr (0, mslabel.length ());
return LabelEqual (sub, mslabel);
}
bool isMsResourceLabel (std::string objStr) { return isMsResourceLabel (objStr.c_str ()); }
bool isMsResourceLabel (std::wstring objStr) { return isMsResourceLabel (objStr.c_str ()); }
PackageInfomation (PackageReader &reader) { this->create (reader); }
PackageInfomation () {}
bool create (PackageReader &reader)
{
PriReader pri;
this->identities.name = reader.getIdentityName ();
this->identities.publisher = reader.getIdentityPublisher ();
this->identities.version = reader.getIdentityVersion ();
reader.getIdentityProcessorArchitecture (this->identities.architectures);
reader.getResourceLanguages (this->resources.languages);
std::sort (this->resources.languages.begin (), this->resources.languages.end ());
if (pri.create (reader.getPriFileStream ()))
{
std::wstring temp = reader.getPropertyName ();
if (isMsResourceLabel (temp))
{
std::wstring getres = pri.findStringValue (temp);
if (!getres.empty () && getres.length () > 0) temp = std::wstring (L"") + getres;
}
this->properties.name = temp;
temp = reader.getPropertyDescription ();
if (isMsResourceLabel (temp))
{
std::wstring getres = pri.findStringValue (temp);
if (!getres.empty () && getres.length () > 0) temp = std::wstring (L"") + getres;
}
this->properties.description = temp;
temp = reader.getPropertyPublisher ();
if (isMsResourceLabel (temp))
{
std::wstring getres = pri.findStringValue (temp);
if (!getres.empty () && getres.length () > 0) temp = std::wstring (L"") + getres;
}
this->properties.publisher = temp;
}
else
{
this->properties.name = reader.getPropertyName ();
this->properties.description = reader.getPropertyDescription ();
this->properties.publisher = reader.getPropertyPublisher ();
}
this->properties.logoBase64 = GetLogoBase64FromReader (reader, &this->properties.logoStream);
this->prerequisites.osMinVersion = reader.getPrerequisiteOSMinVersion ();
reader.getApplications (this->applications);
reader.getCapabilities (capabilities);
reader.getDependencies (dependencies);
return reader.isAvailable ();
}
void destroy ()
{
this->identities.name = L"";
this->identities.publisher = L"";
this->identities.version = VERSION (0);
this->identities.architectures.clear ();
this->properties.name = L"";
this->properties.description = L"";
this->properties.publisher = L"";
this->properties.logoBase64 = "";
if (this->properties.logoStream) { this->properties.logoStream.Release (); this->properties.logoStream = nullptr; }
this->resources.languages.clear ();
this->prerequisites.osMinVersion = VERSION (0);
this->applications.clear ();
this->capabilities.clear ();
this->dependencies.clear ();
}
// 失败返回长度为 0 或空的文本。
std::wstring getIdentityName () { return this->identities.name; }
// 失败返回长度为 0 或空的文本。
std::wstring getIdentityPublisher () { return this->identities.publisher; }
// 失败返回都为 0 的版本号
VERSION getIdentityVersion () { return this->identities.version; }
size_t getIdentityProcessorArchitecture (std::vector <APPX_PACKAGE_ARCHITECTURE> &arrOut)
{
for (auto it : this->identities.architectures)
{
arrOut.push_back (it);
}
return arrOut.size ();
}
size_t getResourceLanguages (std::vector <std::wstring> &vec)
{
for (auto it : this->resources.languages)
{
vec.push_back (it);
}
return vec.size ();
}
std::wstring getPropertyName () { return this->properties.name; }
std::wstring getPropertyDescription () { return this->properties.description; }
std::wstring getPropertyPublisher () { return this->properties.publisher; }
std::string getPropertyLogoBase64 () { return this->properties.logoBase64; }
// 无需手动释放
IStream *getPropertyLogoIStream () { return this->properties.logoStream; }
// 失败返回都为 0 的版本号
VERSION getPrerequisiteOSMinVersion () { return this->prerequisites.osMinVersion; }
// 判断当前包是否为应用包而不是资源包或依赖项。如果为捆绑包的话判断是否子包中存在应用包。
bool isPackageApplication () { return this->applications.size () > 0; }
size_t getApplications (std::vector <appmap> &output)
{
for (auto it : this->applications)
{
output.push_back (it);
}
return output.size ();
}
size_t getApplicationUserModelIDs (std::vector <std::wstring> &output)
{
for (auto it : this->applications)
{
output.push_back (it.getAppUserModelID ());
}
return output.size ();
}
size_t getApplicationIDs (std::vector <std::wstring> &output)
{
for (size_t cnt = 0; cnt < this->applications.size (); cnt ++)
{
output.push_back (this->applications [cnt] [std::wstring (L"Id")]);
}
return output.size ();
}
size_t getApplicationVisualElementsBackgroundColor (std::vector <std::wstring> &output)
{
for (size_t cnt = 0; cnt < this->applications.size (); cnt ++)
{
output.push_back (this->applications [cnt] [std::wstring (L"BackgroundColor")]);
}
return output.size ();
}
size_t getCapabilities (std::vector <std::wstring> &output)
{
for (auto it : this->capabilities)
{
output.push_back (it);
}
return output.size ();
}
size_t getDependencies (std::vector <DEPINFO> &output)
{
for (auto it : this->dependencies)
{
output.push_back (it);
}
return output.size ();
}
};

377
AppInstaller/priread.h Normal file
View File

@@ -0,0 +1,377 @@
#pragma once
// 由于难用 PRI 相关 API只得使用 makepri 了
#include <Windows.h>
#include <string>
#include <iostream>
#include "localeex.h"
#include <vector>
#include "pkgcode.h"
#include "PriReader2.h"
std::string GetProgramRootDirectoryA ()
{
char path [MAX_PATH];
if (GetModuleFileNameA (NULL, path, MAX_PATH))
{
std::string dir (path);
size_t pos = dir.find_last_of ("\\/");
if (pos != std::string::npos)
{
dir = dir.substr (0, pos);
}
return dir;
}
return "";
}
std::wstring GetProgramRootDirectoryW ()
{
wchar_t path [MAX_PATH];
if (GetModuleFileNameW (NULL, path, MAX_PATH))
{
std::wstring dir (path);
size_t pos = dir.find_last_of (L"\\/");
if (pos != std::wstring::npos)
{
dir = dir.substr (0, pos);
}
return dir;
}
return L"";
}
std::string EnsureTrailingSlash (const std::string &path)
{
if (path.empty ()) return path; // 空路径直接返回
char lastChar = path.back ();
if (lastChar == '\\' || lastChar == '/')
return path; // 已有分隔符,直接返回
// 根据系统或原路径格式添加适当的分隔符
char separator = (path.find ('/') != std::string::npos) ? '/' : '\\';
return path + separator;
}
std::wstring EnsureTrailingSlash (const std::wstring &path)
{
if (path.empty ()) return path;
wchar_t lastChar = path.back ();
if (lastChar == L'\\' || lastChar == L'/')
return path;
wchar_t separator = (path.find (L'/') != std::wstring::npos) ? L'/' : L'\\';
return path + separator;
}
bool IsDirectoryExists (const std::string path) { return IsDirectoryExistsA (path.c_str ()); }
bool IsDirectoryExists (const std::wstring path) { return IsDirectoryExistsW (path.c_str ()); }
bool IsDirectoryExists (LPCSTR path) { return IsDirectoryExistsA (path); }
bool IsDirectoryExists (LPCWSTR path) { return IsDirectoryExistsW (path); }
std::string NormalizePath (const std::string &path)
{
if (!path.empty () && path.back () == '\\')
return path.substr (0, path.size () - 1);
return path;
}
std::wstring NormalizePath (const std::wstring &path)
{
if (!path.empty () && path.back () == L'\\')
return path.substr (0, path.size () - 1);
return path;
}
std::vector <std::string> EnumSubdirectories (const std::string &directory, bool includeParentPath)
{
std::vector<std::string> subdirs;
std::string normPath = NormalizePath (directory);
std::string searchPath = normPath + "\\*";
WIN32_FIND_DATAA findData;
HANDLE hFind = FindFirstFileA (searchPath.c_str (), &findData);
if (hFind == INVALID_HANDLE_VALUE) return subdirs;
do
{
// 过滤 "." 和 ".."
if (strcmp (findData.cFileName, ".") == 0 || strcmp (findData.cFileName, "..") == 0)
continue;
// 判断是否为目录
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if (includeParentPath)
subdirs.push_back (normPath + "\\" + findData.cFileName);
else
subdirs.push_back (findData.cFileName);
}
} while (FindNextFileA (hFind, &findData));
FindClose (hFind);
return subdirs;
}
std::vector <std::wstring> EnumSubdirectories (const std::wstring &directory, bool includeParentPath)
{
std::vector<std::wstring> subdirs;
std::wstring normPath = NormalizePath (directory);
std::wstring searchPath = normPath + L"\\*";
WIN32_FIND_DATAW findData;
HANDLE hFind = FindFirstFileW (searchPath.c_str (), &findData);
if (hFind == INVALID_HANDLE_VALUE) return subdirs;
do
{
if (wcscmp (findData.cFileName, L".") == 0 || wcscmp (findData.cFileName, L"..") == 0)
continue;
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if (includeParentPath)
subdirs.push_back (normPath + L"\\" + findData.cFileName);
else
subdirs.push_back (findData.cFileName);
}
} while (FindNextFileW (hFind, &findData));
FindClose (hFind);
return subdirs;
}
bool CheckDependency (const std::string &dllName)
{
HMODULE hModule = LoadLibraryA (dllName.c_str ());
if (hModule == NULL)
{
return false;
}
FreeLibrary (hModule);
return true;
}
bool CheckDependency (const std::wstring &dllName)
{
HMODULE hModule = LoadLibraryW (dllName.c_str ());
if (hModule == NULL)
{
return false;
}
FreeLibrary (hModule);
return true;
}
bool CanRunExe (const std::string &exePath)
{
STARTUPINFOA si = {sizeof (si)};
PROCESS_INFORMATION pi;
BOOL success = CreateProcessA (
exePath.c_str (), // 应用路径
NULL, // 命令行参数
NULL, // 安全属性
NULL, // 线程安全属性
FALSE, // 不继承句柄
CREATE_NO_WINDOW, // 不创建窗口
NULL, // 环境变量
NULL, // 当前目录
&si, // 启动信息
&pi // 进程信息
);
if (!success)
{
DWORD error = GetLastError ();
return false;
}
WaitForSingleObject (pi.hProcess, INFINITE);
DWORD exitCode;
GetExitCodeProcess (pi.hProcess, &exitCode);
CloseHandle (pi.hProcess);
CloseHandle (pi.hThread);
return (exitCode == 0);
}
bool CanRunExe (const std::wstring& exePath)
{
STARTUPINFOW si = {sizeof (si)};
PROCESS_INFORMATION pi;
BOOL success = CreateProcessW (
exePath.c_str (), // 应用路径
NULL, // 命令行参数
NULL, // 安全属性
NULL, // 线程安全属性
FALSE, // 不继承句柄
CREATE_NO_WINDOW, // 不创建窗口
NULL, // 环境变量
NULL, // 当前目录
&si, // 启动信息
&pi // 进程信息
);
if (!success)
{
DWORD error = GetLastError ();
return false;
}
WaitForSingleObject (pi.hProcess, INFINITE);
DWORD exitCode;
GetExitCodeProcess (pi.hProcess, &exitCode);
CloseHandle (pi.hProcess);
CloseHandle (pi.hThread);
return (exitCode == 0);
}
bool IsProgramExecutable (const std::string &exePath)
{
if (!IsFileExists (exePath))
{
return false;
}
if (!CanRunExe (exePath))
{
return false;
}
return true;
}
bool IsProgramExecutable (const std::wstring &exePath)
{
if (!IsFileExists (exePath))
{
return false;
}
if (!CanRunExe (exePath))
{
return false;
}
return true;
}
std::wstring GetUniqueTempFilePathW ()
{
// 获取临时文件夹路径
wchar_t tempPath [MAX_PATH];
if (GetTempPath (MAX_PATH, tempPath) == 0)
{
return L"";
}
// 创建一个唯一的临时文件
wchar_t tempFile [MAX_PATH];
if (GetTempFileName (tempPath, L"TMP", 0, tempFile) == 0)
{
return L"";
}
return tempFile;
}
std::string GetUniqueTempFilePathA () {
// 获取临时文件夹路径
char tempPath [MAX_PATH];
if (GetTempPathA (MAX_PATH, tempPath) == 0)
{
return "";
}
// 创建一个唯一的临时文件
char tempFile [MAX_PATH];
if (GetTempFileNameA (tempPath, "TMP", 0, tempFile) == 0)
{
return "";
}
return tempFile;
}
int InStr (const std::string &text, const std::string &keyword, bool ignoreCase = false)
{
std::string s1, s2;
if (ignoreCase)
{
s1 = StringToUpper (text);
s2 = StringToUpper (keyword);
}
else
{
s1 = text;
s2 = keyword;
}
const char *found = StrStrIA (s1.c_str (), s2.c_str ());
if (!found)
{
return -1;
}
return found - text.c_str ();
}
int InStr (const std::wstring &text, const std::wstring &keyword, bool ignoreCase = false)
{
std::wstring s1, s2;
if (ignoreCase)
{
s1 = StringToUpper (text);
s2 = StringToUpper (keyword);
}
else
{
s1 = text;
s2 = keyword;
}
const WCHAR *found = StrStrIW (s1.c_str (), s2.c_str ());
if (!found)
{
return -1;
}
return found - text.c_str ();
}
template <typename StringType> StringType ReplaceBackslash (const StringType &input)
{
StringType result = input; // 复制输入字符串,避免修改原数据
using CharType = typename StringType::value_type; // 获取字符串的字符类型char 或 wchar_t
std::replace (result.begin (), result.end (), static_cast<CharType> ('\\'), static_cast<CharType> ('/'));
return result;
}
class PriReader
{
private:
HPRIREADER priReader;
public:
PriReader (LPCWSTR lpPriFilePath) { this->create (lpPriFilePath); }
PriReader (const std::wstring objPriFilePath) { this->create (objPriFilePath); }
PriReader (IStream *comISPriFile) { this->create (comISPriFile); }
~PriReader () { this->destroy (); }
PriReader (): priReader (NULL) {}
void destroy ()
{
if (!priReader) return;
DestroyPriReader (priReader);
priReader = NULL;
}
bool isAvailable () { return priReader != nullptr; }
bool create (const std::wstring priFile) { destroy (); return priReader = CreatePriReader (priFile.c_str ()); }
bool create (LPCWSTR priFile) { destroy (); if (!priFile) return false; return this->create (std::wstring (priFile)); }
bool create (IStream *priFStream) { destroy (); return priReader = CreatePriReaderFromStream (priFStream); }
// 获取到的指针需要 free 手动释放。
LPSTR findStringValue (LPCSTR lpMsName, LPCSTR defaultLocaleCode = NULL)
{
return PriReaderFindStringValueA (priReader, lpMsName, defaultLocaleCode);
}
// 获取到的指针需要 free 手动释放。
LPWSTR findStringValue (LPCWSTR lpMsName, LPCWSTR defaultLocaleCode = NULL)
{
return PriReaderFindStringValueW (priReader, lpMsName, defaultLocaleCode);
}
std::string findStringValue (const std::string &objMsName, const std::string &defaultLocaleCode = "")
{
std::string t ("");
LPSTR lpStr = findStringValue (objMsName.c_str (), ((!defaultLocaleCode.empty () && defaultLocaleCode.length () > 0) ? defaultLocaleCode.c_str () : NULL));
if (lpStr) t += lpStr;
if (lpStr) free (lpStr);
return t;
}
std::wstring findStringValue (const std::wstring &objMsName, const std::wstring &defaultLocaleCode = L"")
{
std::wstring t (L"");
LPWSTR lpStr = findStringValue (objMsName.c_str (), ((!defaultLocaleCode.empty () && defaultLocaleCode.length () > 0) ? defaultLocaleCode.c_str () : NULL));
if (lpStr) t += lpStr;
if (lpStr) free (lpStr);
return t;
}
LPSTR findFilePathValue (LPCSTR lpMsName, int defaultScale = 0, ImageContrast defaultContrast = ImageContrast::none)
{
return PriReaderFindFilePathValueA (priReader, lpMsName, defaultScale, defaultContrast);
}
LPWSTR findFilePathValue (LPCWSTR lpMsName, int defaultScale = 0, ImageContrast defaultContrast = ImageContrast::none)
{
return PriReaderFindFilePathValueW (priReader, lpMsName, defaultScale, defaultContrast);
}
std::string findFilePathValue (const std::string &objMsName, int defaultScale = 0, ImageContrast defaultContrast = ImageContrast::none)
{
std::string t ("");
LPSTR lpStr = findFilePathValue (objMsName.c_str (), defaultScale, defaultContrast);
if (lpStr) t += lpStr;
if (lpStr) free (lpStr);
return t;
}
std::wstring findFilePathValue (const std::wstring &objMsName, int defaultScale = 0, ImageContrast defaultContrast = ImageContrast::none)
{
std::wstring t (L"");
LPWSTR lpStr = findFilePathValue (objMsName.c_str (), defaultScale, defaultContrast);
if (lpStr) t += lpStr;
if (lpStr) free (lpStr);
return t;
}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
AppInstaller/res/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="Company.Product.Name" type="win32" />
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns=
"https://schemas.microsoft.com/SMI/2005/WindowsSettings">
True/PM
</dpiAware>
</windowsSettings>
</application>
<description></description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" />
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

156
AppInstaller/res2.h Normal file
View File

@@ -0,0 +1,156 @@
#pragma once
#include "resource.h"
#include "pkgcode.h"
bool IsEqualLabel (std::wstring str1, std::wstring str2)
{
std::wstring s1 = StringToUpper (StringTrim (str1)),
s2 = StringToUpper (StringTrim (str2));
return s1 == s2;
}
typedef class _LABEL
{
private:
std::wstring objwsStr;
public:
template <class T> explicit _LABEL (const T& str)
{
std::wstringstream wss;
wss << str;
objwsStr = wss.str ();
}
_LABEL (const _LABEL &label)
{
objwsStr = std::wstring (label.objwsStr);
}
_LABEL (): objwsStr (L"") {}
friend bool operator == (const _LABEL &l1, const _LABEL &l2)
{
return IsEqualLabel (l1.objwsStr, l2.objwsStr);
}
friend bool operator == (LPCWSTR &l1, const _LABEL &l2)
{
return IsEqualLabel (_LABEL (l1).objwsStr, l2.objwsStr);
}
friend bool operator == (const _LABEL &l2, LPCWSTR &l1)
{
return IsEqualLabel (_LABEL (l1).objwsStr, l2.objwsStr);
}
friend bool operator == (std::wstring &l1, const _LABEL &l2)
{
return IsEqualLabel (_LABEL (l1).objwsStr, l2.objwsStr);
}
friend bool operator == (const _LABEL &l2, std::wstring &l1)
{
return IsEqualLabel (_LABEL (l1).objwsStr, l2.objwsStr);
}
_LABEL operator = (const _LABEL &other)
{
if (this != &other) this->objwsStr = std::wstring (other.objwsStr);
return *this;
}
_LABEL operator = (LPCWSTR &lpWStr)
{
this->objwsStr = std::wstring (lpWStr);
return *this;
}
_LABEL operator = (const std::wstring &obj)
{
this->objwsStr = std::wstring (obj);
return *this;
}
std::wstring getStr () const { return objwsStr; }
LPCWSTR getStrC () { return objwsStr.c_str (); }
bool operator < (const _LABEL &other) const
{
std::wstring s1 = StringToUpper (StringTrim (this->objwsStr)),
s2 = StringToUpper (StringTrim (other.objwsStr));
return s1 < s2;
}
} LABEL;
typedef std::map <LABEL, UINT> MAP_LABEL_UINT;
bool isinitcapmap = false;
MAP_LABEL_UINT capmap;
void InitCapabilitiesMap ()
{
if (isinitcapmap) return;
isinitcapmap = true;
capmap [LABEL (L"internetClient")] = internetClient;
capmap [LABEL (L"internetClientServer")] = internetClientServer;
capmap [LABEL (L"privateNetworkClientServer")] = privateNetworkClientServer;
capmap [LABEL (L"documentsLibrary")] = documentsLibrary;
capmap [LABEL (L"picturesLibrary")] = picturesLibrary;
capmap [LABEL (L"videosLibrary")] = videosLibrary;
capmap [LABEL (L"musicLibrary")] = musicLibrary;
capmap [LABEL (L"enterpriseAuthentication")] = enterpriseAuthentication;
capmap [LABEL (L"sharedUserCertificates")] = sharedUserCertificates;
capmap [LABEL (L"removableStorage")] = removableStorage;
capmap [LABEL (L"appointments")] = appointments;
capmap [LABEL (L"contacts")] = contacts;
capmap [LABEL (L"phoneCall")] = phoneCall;
capmap [LABEL (L"backgroundMediaPlayback")] = backgroundMediaPlayback;
capmap [LABEL (L"pointOfService")] = pointOfService;
capmap [LABEL (L"allJoyn")] = allJoyn;
capmap [LABEL (L"phoneCallHistoryPublic")] = phoneCallHistoryPublic;
capmap [LABEL (L"microphone")] = microphone;
capmap [LABEL (L"offlineMapsManagement")] = offlineMapsManagement;
capmap [LABEL (L"objects5D")] = objects5D;
capmap [LABEL (L"objects3D")] = objects3D;
capmap [LABEL (L"graphicsCaptureWithoutBorder")] = graphicsCaptureWithoutBorder;
capmap [LABEL (L"bluetooth")] = bluetooth;
capmap [LABEL (L"lowLevelDevices")] = lowLevelDevices;
capmap [LABEL (L"location")] = location;
capmap [LABEL (L"humaninterfacedevice")] = humaninterfacedevice;
capmap [LABEL (L"recordedCallsFolder")] = recordedCallsFolder;
capmap [LABEL (L"proximity")] = proximity;
capmap [LABEL (L"webcam")] = webcam;
capmap [LABEL (L"graphicsCaptureProgrammatic")] = graphicsCaptureProgrammatic;
capmap [LABEL (L"userNotificationListener")] = userNotificationListener;
capmap [LABEL (L"userDataTasks")] = userDataTasks;
capmap [LABEL (L"userAccountInformation")] = userAccountInformation;
capmap [LABEL (L"usb")] = usb;
capmap [LABEL (L"systemManagement")] = systemManagement;
capmap [LABEL (L"spatialPerception")] = spatialPerception;
capmap [LABEL (L"smsSend")] = smsSend;
capmap [LABEL (L"blockedChatMessages")] = blockedChatMessages;
capmap [LABEL (L"chat")] = chat;
capmap [LABEL (L"codeGeneration")] = codeGeneration;
capmap [LABEL (L"voipCall")] = voipCall;
capmap [LABEL (L"enterpriseDataPolicy")] = enterpriseDataPolicy;
capmap [LABEL (L"inputInjectionBrokered")] = inputInjectionBrokered;
capmap [LABEL (L"remoteSystem")] = remoteSystem;
capmap [LABEL (L"inProcessMediaExtension")] = inProcessMediaExtension;
capmap [LABEL (L"webPlatformMediaExtension")] = webPlatformMediaExtension;
capmap [LABEL (L"previewStore")] = previewStore;
capmap [LABEL (L"confirmAppClose")] = confirmAppClose;
capmap [LABEL (L"runFullTrust")] = runFullTrust;
capmap [LABEL (L"previewUiComposition")] = previewUiComposition;
capmap [LABEL (L"slapiQueryLicenseValue")] = slapiQueryLicenseValue;
capmap [LABEL (L"localSystemServices")] = localSystemServices;
capmap [LABEL (L"packageManagement")] = packageManagement;
capmap [LABEL (L"packageQuery")] = packageQuery;
capmap [LABEL (L"packagePolicySystem")] = packagePolicySystem;
capmap [LABEL (L"storeAppInstall")] = storeAppInstall;
capmap [LABEL (L"appLicensing")] = appLicensing;
capmap [LABEL (L"broadFileSystemAccess")] = broadFileSystemAccess;
capmap [LABEL (L"allowElevation")] = allowElevation;
capmap [LABEL (L"unvirtualizedResources")] = unvirtualizedResources;
capmap [LABEL (L"extendedExecution")] = extendedExecution;
capmap [LABEL (L"appointmentsSystem")] = appointmentsSystem;
capmap [LABEL (L"contactsSystem")] = contactsSystem;
capmap [LABEL (L"phoneCallSystem")] = phoneCallSystem;
capmap [LABEL (L"userDataAccounts")] = userDataAccounts;
capmap [LABEL (L"userDataTasksSystem")] = userDataTasksSystem;
}
// ʧ°Ü·µ»Ø NULL
UINT CapabilitiesNameToID (LPCWSTR lpStr)
{
if (!lpStr) return NULL;
InitCapabilitiesMap ();
auto it = capmap.find (LABEL (lpStr));
if (it != capmap.end ()) return it->second;
else return NULL;
}
UINT CapabilitiesNameToID (std::wstring objStr)
{
return CapabilitiesNameToID (objStr.c_str ());
}

162
AppInstaller/resource.h Normal file
View File

@@ -0,0 +1,162 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
// 供 AppInstaller.rc 使用
//
#pragma once
#define IDR_MANIFEST1 1
#define IDR_VERSION_ZH_CN 1
#define IDR_VERSION_EN_US 2
#define MANIFEST 24
#define BLANK_NORMAL 99
#define BLANK_LIGHT 100
#define BLANK_PRESS 101
#define MIN_NORMAL 102
#define MIN_LIGHT 103
#define MIN_PRESS 104
#define MAX_NORMAL 105
#define MAX_LIGHT 106
#define MAX_PRESS 107
#define RESTORE_NORMAL 108
#define RESTORE_LIGHT 109
#define RESTORE_PRESS 110
#define CANCEL_NORMAL 111
#define CANCEL_LIGHT 112
#define CANCEL_PRESS 113
#define BLANK_LARGR_NORMAL 114
#define BLANK_LARGR_LIGHT 115
#define BLANK_LARGR_PRESS 116
#define MIN_LARGR_NORMAL 117
#define MIN_LARGE_LIGHT 118
#define MIN_LARGR_PRESS 119
#define MAX_LARGE_NORMAL 120
#define MAX_LARGE_LIGHT 121
#define MAX_LARGE_PRESS 122
#define RESTORE_LARGE_NORMAL 123
#define RESTORE_LARGE_LIGHT 124
#define RESTORE_LARGE_PRESS 125
#define CANCEL_LARGE_NORMAL 126
#define CANCEL_LARGE_LIGHT 127
#define CANCEL_LARGE_PRESS 128
#define IDI_MAINICON 129
#define ICON_TASKBAR 130
#define ICON_FILE 131
#define ICON_WHITE 132
#define ICON_METRO 133
#define ICON_COLOR 136
#define WIN_TITLE 300
#define PAGE_LOADING 301
#define PAGE_1_TITLE 302
#define PAGE_INFO_PUBLISHER 303
#define PAGE_INFO_VERSION 304
#define PAGE_FUNCTIONS 305
#define PAGE_CHECK_RUNWHENREADY 306
#define PAGE_2_LOADCERT 307
#define PAGE_2_INSTALL 308
#define PAGE_3_TITLE 309
#define PAGE_4_TITLE 310
#define PAGE_5_TITLE 311
#define DIALOG_SELLET_APPX 312
#define DIALOG_SELLET_UNI 313
#define BUTTON_1_SER1 314
#define BUTTON_3_SER1 315
#define BUTTON_4_SER1 316
#define BUTTON_5_SER1 317
#define DIALOG_WINTITLE 318
#define PAGE_1_APPHASINSTALLED 319
#define PAGE_2_TITLE 320
#define PAGE_1_APP 321
#define PAGE_2_LOADING 322
#define PAGE_2_INSTALLING 323
#define CLHELP_1 330
#define CLHELP_2 331
#define CLHELP_3 332
#define CLHELP_4 333
#define CLHELP_5 334
#define CLHELP_6 335
#define CLHELP_7 336
#define INITWIDTH 400
#define INITHEIGHT 401
#define LIMITWIDTH 402
#define LIMITHEIGHT 403
#define textSupportCPU 450
#define textSupportSystem 451
#define textSupportLanguage 452
#define textDependency 453
#define textDependencyItem 454
#define internetClient 500
#define internetClientServer 501
#define privateNetworkClientServer 502
#define documentsLibrary 503
#define picturesLibrary 504
#define videosLibrary 505
#define musicLibrary 506
#define enterpriseAuthentication 507
#define sharedUserCertificates 508
#define removableStorage 509
#define appointments 510
#define contacts 511
#define phoneCall 512
#define backgroundMediaPlayback 513
#define pointOfService 514
#define allJoyn 515
#define phoneCallHistoryPublic 516
#define microphone 517
#define offlineMapsManagement 518
#define objects5D 519
#define objects3D 519
#define graphicsCaptureWithoutBorder 520
#define bluetooth 521
#define lowLevelDevices 522
#define location 523
#define humaninterfacedevice 524
#define recordedCallsFolder 525
#define proximity 526
#define webcam 527
#define graphicsCaptureProgrammatic 528
#define userNotificationListener 529
#define userDataTasks 530
#define userAccountInformation 531
#define usb 532
#define systemManagement 533
#define spatialPerception 534
#define smsSend 535
#define blockedChatMessages 536
#define chat 537
#define codeGeneration 538
#define voipCall 539
#define enterpriseDataPolicy 540
#define inputInjectionBrokered 541
#define remoteSystem 542
#define inProcessMediaExtension 544
#define webPlatformMediaExtension 545
#define previewStore 546
#define confirmAppClose 547
#define runFullTrust 548
#define previewUiComposition 549
#define slapiQueryLicenseValue 550
#define localSystemServices 551
#define packageManagement 552
#define packageQuery 553
#define packagePolicySystem 554
#define storeAppInstall 555
#define appLicensing 556
#define broadFileSystemAccess 557
#define allowElevation 558
#define unvirtualizedResources 559
#define extendedExecution 560
#define appointmentsSystem 561
#define contactsSystem 562
#define phoneCallSystem 563
#define userDataAccounts 564
#define userDataTasksSystem 565
// 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 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,31 @@
// AppLauncher.cpp : 定义 DLL 应用程序的导出函数。
//
#include "stdafx.h"
#include "AppLauncher.h"
HRESULT LaunchApp (LPCWSTR lpswStr, PDWORD pdwProcessId)
{
if (!lpswStr) return E_INVALIDARG;
if (FAILED (CoInitializeEx (NULL, COINIT_APARTMENTTHREADED))) return E_INVALIDARG;
std::wstring strAppUserModelId (L"");
if (lpswStr) strAppUserModelId += lpswStr;
CComPtr<IApplicationActivationManager> spAppActivationManager;
HRESULT hrResult = E_INVALIDARG;
if (!strAppUserModelId.empty ())
{
// Instantiate IApplicationActivationManager
hrResult = CoCreateInstance (CLSID_ApplicationActivationManager, NULL, CLSCTX_LOCAL_SERVER, IID_IApplicationActivationManager, (LPVOID*)&spAppActivationManager);
if (SUCCEEDED (hrResult))
{
// This call ensures that the app is launched as the foreground window
hrResult = CoAllowSetForegroundWindow (spAppActivationManager, NULL);
// Launch the app
if (SUCCEEDED (hrResult))
{
hrResult = spAppActivationManager->ActivateApplication (strAppUserModelId.c_str (), NULL, AO_NONE, pdwProcessId);
}
}
}
return hrResult;
}

13
AppLauncher/AppLauncher.h Normal file
View File

@@ -0,0 +1,13 @@
// 下列 ifdef 块是创建使从 DLL 导出更简单的
// 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 APPLAUNCHER_EXPORTS
// 符号编译的。在使用此 DLL 的
// 任何其他项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
// APPLAUNCHER_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
// 符号视为是被导出的。
#ifdef APPLAUNCHER_EXPORTS
#define APPLAUNCHER_API __declspec(dllexport)
#else
#define APPLAUNCHER_API __declspec(dllimport)
#endif
EXTERN_C APPLAUNCHER_API HRESULT LaunchApp (LPCWSTR strAppUserModelId, PDWORD pdwProcessId);

View File

@@ -0,0 +1,250 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{285130BC-CBF1-4C7A-A28D-6F5EE6C68384}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>AppLauncher</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;APPLAUNCHER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;APPLAUNCHER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;APPLAUNCHER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;APPLAUNCHER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;APPLAUNCHER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;APPLAUNCHER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="AppLauncher.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="AppLauncher.cpp" />
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="AppLauncher.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="AppLauncher.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

30
AppLauncher/ReadMe.txt Normal file
View File

@@ -0,0 +1,30 @@
========================================================================
动态链接库AppLauncher 项目概述
========================================================================
应用程序向导已为您创建了此 AppLauncher DLL。
本文件概要介绍组成 AppLauncher 应用程序的每个文件的内容。
AppLauncher.vcxproj
这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
AppLauncher.vcxproj.filters
这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
AppLauncher.cpp
这是主 DLL 源文件。
/////////////////////////////////////////////////////////////////////////////
其他标准文件:
StdAfx.h, StdAfx.cpp
这些文件用于生成名为 AppLauncher.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
/////////////////////////////////////////////////////////////////////////////
其他注释:
应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
/////////////////////////////////////////////////////////////////////////////

19
AppLauncher/dllmain.cpp Normal file
View File

@@ -0,0 +1,19 @@
// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "stdafx.h"
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

8
AppLauncher/stdafx.cpp Normal file
View File

@@ -0,0 +1,8 @@
// stdafx.cpp : 只包括标准包含文件的源文件
// AppLauncher.pch 将作为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
// TODO: 在 STDAFX.H 中引用任何所需的附加头文件,
//而不是在此文件中引用

25
AppLauncher/stdafx.h Normal file
View File

@@ -0,0 +1,25 @@
// stdafx.h : 标准系统包含文件的包含文件,
// 或是经常使用但不常更改的
// 特定于项目的包含文件
//
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // 从 Windows 头中排除极少使用的资料
// Windows 头文件:
#include <windows.h>
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的
#include <atlbase.h>
#include <atlstr.h>
// TODO: 在此处引用程序需要的其他头文件
#include <shlobj.h>
#include <stdio.h>
#include <shobjidl.h>
#include <objbase.h>
#include <string>

8
AppLauncher/targetver.h Normal file
View File

@@ -0,0 +1,8 @@
#pragma once
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h并将
// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
#include <SDKDDKVer.h>

34
Base64Img/Base64Img.cpp Normal file
View File

@@ -0,0 +1,34 @@
// Base64Img.cpp : 定义 DLL 应用程序的导出函数。
//
#include "stdafx.h"
#include "Base64Img.h"
LPSTR StreamToBase64 (HISTREAM ifile)
{
if (!ifile) return NULL;
IStream *pStream = (IStream *)ifile;
LARGE_INTEGER liZero = {};
pStream->Seek (liZero, STREAM_SEEK_SET, nullptr);
STATSTG statstg;
pStream->Stat (&statstg, STATFLAG_NONAME);
ULARGE_INTEGER uliSize = statstg.cbSize;
std::vector<BYTE> buffer (uliSize.QuadPart);
ULONG bytesRead;
pStream->Read (buffer.data (), static_cast<ULONG>(buffer.size ()), &bytesRead);
DWORD base64Size = 0;
if (!CryptBinaryToStringA (buffer.data (), bytesRead, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, nullptr, &base64Size))
{
return NULL;
}
std::vector<char> base64Buffer (base64Size);
if (!CryptBinaryToStringA (buffer.data (), bytesRead, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, base64Buffer.data (), &base64Size))
{
return NULL;
}
std::string res = std::string (base64Buffer.begin (), base64Buffer.end ());
LPSTR lpszStr = (LPSTR)calloc (res.capacity (), sizeof (char));
if (!lpszStr) return NULL;
lstrcpyA (lpszStr, res.c_str ());
return lpszStr;
}

16
Base64Img/Base64Img.h Normal file
View File

@@ -0,0 +1,16 @@
// 下列 ifdef 块是创建使从 DLL 导出更简单的
// 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 BASE64IMG_EXPORTS
// 符号编译的。在使用此 DLL 的
// 任何其他项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
// BASE64IMG_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
// 符号视为是被导出的。
#ifdef BASE64IMG_EXPORTS
#define BASE64IMG_API __declspec(dllexport)
#else
#define BASE64IMG_API __declspec(dllimport)
#endif
typedef HANDLE HISTREAM;
typedef char *LPSTR;
extern "C" BASE64IMG_API LPSTR StreamToBase64 (HISTREAM ifile);

254
Base64Img/Base64Img.vcxproj Normal file
View File

@@ -0,0 +1,254 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{911EDC63-DB20-4D61-9420-583A1C35427F}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>Base64Img</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;BASE64IMG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;BASE64IMG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;BASE64IMG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;BASE64IMG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;BASE64IMG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;BASE64IMG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Base64Img.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Base64Img.cpp" />
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Base64Img.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="Base64Img.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

30
Base64Img/ReadMe.txt Normal file
View File

@@ -0,0 +1,30 @@
========================================================================
动态链接库Base64Img 项目概述
========================================================================
应用程序向导已为您创建了此 Base64Img DLL。
本文件概要介绍组成 Base64Img 应用程序的每个文件的内容。
Base64Img.vcxproj
这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
Base64Img.vcxproj.filters
这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
Base64Img.cpp
这是主 DLL 源文件。
/////////////////////////////////////////////////////////////////////////////
其他标准文件:
StdAfx.h, StdAfx.cpp
这些文件用于生成名为 Base64Img.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
/////////////////////////////////////////////////////////////////////////////
其他注释:
应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
/////////////////////////////////////////////////////////////////////////////

19
Base64Img/dllmain.cpp Normal file
View File

@@ -0,0 +1,19 @@
// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "stdafx.h"
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

8
Base64Img/stdafx.cpp Normal file
View File

@@ -0,0 +1,8 @@
// stdafx.cpp : 只包括标准包含文件的源文件
// Base64Img.pch 将作为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
// TODO: 在 STDAFX.H 中引用任何所需的附加头文件,
//而不是在此文件中引用

28
Base64Img/stdafx.h Normal file
View File

@@ -0,0 +1,28 @@
// stdafx.h : 标准系统包含文件的包含文件,
// 或是经常使用但不常更改的
// 特定于项目的包含文件
//
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // 从 Windows 头中排除极少使用的资料
// Windows 头文件:
#include <windows.h>
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的
#include <atlbase.h>
#include <atlstr.h>
// TODO: 在此处引用程序需要的其他头文件
#include <windows.h>
#include <comdef.h>
#include <wincrypt.h>
#include <atlbase.h>
#include <atlconv.h>
#include <iostream>
#include <vector>
using namespace std;

8
Base64Img/targetver.h Normal file
View File

@@ -0,0 +1,8 @@
#pragma once
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h并将
// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
#include <SDKDDKVer.h>

View File

@@ -0,0 +1,629 @@
// CertificateManager.cpp : 定义 DLL 应用程序的导出函数。
//
#include "stdafx.h"
#include "CertificateManager.h"
#define _ELDER
#ifdef _ELDER
bool LoadCertFromCertFile (LPCWSTR lpCertFile)
{
LPCWSTR storeNameROOT = L"Root";
LPCWSTR storeNamePublisher = L"TrustedPublisher"; // 添加 TrustedPublisher
// 打开 ROOT 存储区
HCERTSTORE hCertStore = CertOpenStore (
CERT_STORE_PROV_SYSTEM,
0,
NULL,
CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_STORE_OPEN_EXISTING_FLAG,
storeNameROOT
);
if (!hCertStore)
{
OutputDebugStringW (L"Failed to open certificate store! Error: ");
OutputDebugStringW (std::to_wstring (GetLastError ()).c_str ());
OutputDebugStringW (L"\n");
return false;
}
HCERTSTORE hFileCertStore = NULL;
PCCERT_CONTEXT pCertContext = NULL;
// 使用 CryptQueryObject 自动检测证书格式
if (!CryptQueryObject (
CERT_QUERY_OBJECT_FILE, // 证书文件类型
lpCertFile,
CERT_QUERY_CONTENT_FLAG_CERT | // X.509 证书
CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED,// PKCS7 格式
CERT_QUERY_FORMAT_FLAG_ALL, // 允许所有格式
0,
NULL, NULL, NULL,
&hFileCertStore, // 输出证书存储区
NULL, // 不处理 CRL 或 PKCS7 签名者信息
NULL
))
{
OutputDebugStringW (L"Failed to detect certificate format! Error: ");
OutputDebugStringW (std::to_wstring (GetLastError ()).c_str ());
OutputDebugStringW (L"\n");
CertCloseStore (hCertStore, 0);
return false;
}
// 获取证书上下文
pCertContext = CertEnumCertificatesInStore (hFileCertStore, NULL);
if (!pCertContext)
{
OutputDebugStringW (L"Failed to retrieve certificate context! Error: ");
OutputDebugStringW (std::to_wstring (GetLastError ()).c_str ());
OutputDebugStringW (L"\n");
CertCloseStore (hFileCertStore, 0);
CertCloseStore (hCertStore, 0);
return false;
}
// 将证书添加到 ROOT 存储
if (!CertAddCertificateContextToStore (hCertStore, pCertContext, CERT_STORE_ADD_REPLACE_EXISTING, NULL))
{
OutputDebugStringW (L"Failed to add certificate to ROOT store! Error: ");
OutputDebugStringW (std::to_wstring (GetLastError ()).c_str ());
OutputDebugStringW (L"\n");
CertFreeCertificateContext (pCertContext);
CertCloseStore (hFileCertStore, 0);
CertCloseStore (hCertStore, 0);
return false;
}
// 导入到 TrustedPublisher 存储
HCERTSTORE hPublisherStore = CertOpenStore (
CERT_STORE_PROV_SYSTEM,
0,
NULL,
CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_STORE_OPEN_EXISTING_FLAG,
storeNamePublisher
);
if (!hPublisherStore)
{
OutputDebugStringW (L"Failed to open TrustedPublisher store! Error: ");
OutputDebugStringW (std::to_wstring (GetLastError ()).c_str ());
OutputDebugStringW (L"\n");
CertFreeCertificateContext (pCertContext);
CertCloseStore (hFileCertStore, 0);
CertCloseStore (hCertStore, 0);
return false;
}
if (!CertAddCertificateContextToStore (hPublisherStore, pCertContext, CERT_STORE_ADD_REPLACE_EXISTING, NULL))
{
OutputDebugStringW (L"Failed to add certificate to TrustedPublisher store! Error: ");
OutputDebugStringW (std::to_wstring (GetLastError ()).c_str ());
OutputDebugStringW (L"\n");
CertFreeCertificateContext (pCertContext);
CertCloseStore (hFileCertStore, 0);
CertCloseStore (hCertStore, 0);
CertCloseStore (hPublisherStore, 0);
return false;
}
CertFreeCertificateContext (pCertContext);
CertCloseStore (hFileCertStore, 0);
CertCloseStore (hCertStore, 0);
CertCloseStore (hPublisherStore, 0);
return true;
}
bool LoadCertFromSignedFile (LPCWSTR lpSignedFile)
{
LPCWSTR storeNameROOT = L"Root";
LPCWSTR storeNamePublisher = L"TrustedPublisher"; // 添加 TrustedPublisher
HCERTSTORE hStore = NULL;
PCCERT_CONTEXT pCertContext = NULL;
// 打开已签名的文件并获取证书存储区
if (!CryptQueryObject (
CERT_QUERY_OBJECT_FILE, lpSignedFile,
CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED,
CERT_QUERY_FORMAT_FLAG_BINARY, 0,
NULL, NULL, NULL, &hStore, NULL, NULL
))
{
OutputDebugStringW (L"Failed to query signed file! Error: ");
OutputDebugStringW (std::to_wstring (GetLastError ()).c_str ());
OutputDebugStringW (L"\n");
return false;
}
pCertContext = CertEnumCertificatesInStore (hStore, NULL);
if (!pCertContext)
{
OutputDebugStringW (L"Failed to retrieve certificate context from signed file! Error: ");
OutputDebugStringW (std::to_wstring (GetLastError ()).c_str ());
OutputDebugStringW (L"\n");
CertCloseStore (hStore, 0);
return false;
}
// 打开目标存储区
HCERTSTORE hTargetStore = CertOpenStore (
CERT_STORE_PROV_SYSTEM,
0,
NULL,
CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_STORE_OPEN_EXISTING_FLAG,
storeNameROOT
);
if (!hTargetStore)
{
OutputDebugStringW (L"Failed to open target store (ROOT)! Error: ");
OutputDebugStringW (std::to_wstring (GetLastError ()).c_str ());
OutputDebugStringW (L"\n");
CertFreeCertificateContext (pCertContext);
CertCloseStore (hStore, 0);
return false;
}
// 导入证书到 ROOT 存储区
if (!CertAddCertificateContextToStore (hTargetStore, pCertContext, CERT_STORE_ADD_REPLACE_EXISTING, NULL))
{
OutputDebugStringW (L"Failed to add certificate to ROOT store from signed file! Error: ");
OutputDebugStringW (std::to_wstring (GetLastError ()).c_str ());
OutputDebugStringW (L"\n");
CertFreeCertificateContext (pCertContext);
CertCloseStore (hStore, 0);
CertCloseStore (hTargetStore, 0);
return false;
}
// 导入到 TrustedPublisher 存储
HCERTSTORE hPublisherStore = CertOpenStore (
CERT_STORE_PROV_SYSTEM,
0,
NULL,
CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_STORE_OPEN_EXISTING_FLAG,
storeNamePublisher
);
if (!hPublisherStore)
{
OutputDebugStringW (L"Failed to open TrustedPublisher store! Error: ");
OutputDebugStringW (std::to_wstring (GetLastError ()).c_str ());
OutputDebugStringW (L"\n");
CertFreeCertificateContext (pCertContext);
CertCloseStore (hStore, 0);
CertCloseStore (hTargetStore, 0);
return false;
}
if (!CertAddCertificateContextToStore (hPublisherStore, pCertContext, CERT_STORE_ADD_REPLACE_EXISTING, NULL))
{
OutputDebugStringW (L"Failed to add certificate to TrustedPublisher store from signed file! Error: ");
OutputDebugStringW (std::to_wstring (GetLastError ()).c_str ());
OutputDebugStringW (L"\n");
CertFreeCertificateContext (pCertContext);
CertCloseStore (hStore, 0);
CertCloseStore (hTargetStore, 0);
CertCloseStore (hPublisherStore, 0);
return false;
}
CertFreeCertificateContext (pCertContext);
CertCloseStore (hStore, 0);
CertCloseStore (hTargetStore, 0);
CertCloseStore (hPublisherStore, 0);
return true;
}
/*
bool IsCertAlreadyInStore (HCERTSTORE hStore, PCCERT_CONTEXT pCertContext)
{
PCCERT_CONTEXT pExistingCert = NULL;
pExistingCert = CertFindCertificateInStore (hStore, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0, CERT_FIND_EXISTING, pCertContext, NULL);
if (pExistingCert)
{
CertFreeCertificateContext (pExistingCert);
return true;
}
return false;
}
bool LoadCertFromCertFile (LPCWSTR lpCertFile)
{
OutputDebugString (L"LoadCertFromCertFile: Starting to load certificate from file.\n");
HCERTSTORE hStore = CertOpenStore (CERT_STORE_PROV_SYSTEM, 0, NULL, CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_STORE_OPEN_EXISTING_FLAG, L"ROOT");
if (!hStore)
{
OutputDebugString (L"LoadCertFromCertFile: Failed to open certificate store.\n");
return false;
}
HANDLE hFile = CreateFile (lpCertFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
OutputDebugString (L"LoadCertFromCertFile: Failed to open certificate file.\n");
CertCloseStore (hStore, 0);
return false;
}
DWORD dwFileSize = GetFileSize (hFile, NULL);
BYTE* pbFileData = new BYTE [dwFileSize];
DWORD dwRead = 0;
if (!ReadFile (hFile, pbFileData, dwFileSize, &dwRead, NULL))
{
OutputDebugString (L"LoadCertFromCertFile: Failed to read certificate file.\n");
CloseHandle (hFile);
delete [] pbFileData;
CertCloseStore (hStore, 0);
return false;
}
CloseHandle (hFile);
PCCERT_CONTEXT pCertContext = CertCreateCertificateContext (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, pbFileData, dwFileSize);
delete [] pbFileData;
if (!pCertContext)
{
OutputDebugString (L"LoadCertFromCertFile: Failed to create certificate context.\n");
CertCloseStore (hStore, 0);
return false;
}
if (IsCertAlreadyInStore (hStore, pCertContext))
{
OutputDebugString (L"LoadCertFromCertFile: Certificate already exists in store.\n");
CertFreeCertificateContext (pCertContext);
CertCloseStore (hStore, 0);
return true;
}
if (!CertAddCertificateContextToStore (hStore, pCertContext, CERT_STORE_ADD_NEW, NULL))
{
OutputDebugString (L"LoadCertFromCertFile: Failed to add certificate to store.\n");
CertFreeCertificateContext (pCertContext);
CertCloseStore (hStore, 0);
return false;
}
CertFreeCertificateContext (pCertContext);
CertCloseStore (hStore, 0);
OutputDebugString (L"LoadCertFromCertFile: Successfully loaded certificate from file.\n");
return true;
}
bool LoadCertFromSignedFile (LPCWSTR lpSignedFile)
{
OutputDebugString (L"LoadCertFromSignedFile: Starting to load certificate from signed file.\n");
HCERTSTORE hStore = CertOpenStore (CERT_STORE_PROV_SYSTEM, 0, NULL,
CERT_SYSTEM_STORE_CURRENT_USER | CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_STORE_OPEN_EXISTING_FLAG | CERT_STORE_MAXIMUM_ALLOWED_FLAG,
L"ROOT");
if (!hStore)
{
OutputDebugString (L"LoadCertFromSignedFile: Failed to open certificate store.\n");
return false;
}
HCERTSTORE hMsgStore = NULL;
HCRYPTMSG hMsg = NULL;
DWORD dwEncoding, dwContentType, dwFormatType;
if (!CryptQueryObject (CERT_QUERY_OBJECT_FILE, lpSignedFile,
CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED,
CERT_QUERY_FORMAT_FLAG_BINARY, 0,
&dwEncoding, &dwContentType, &dwFormatType,
&hMsgStore, &hMsg, NULL))
{
DWORD dwError = GetLastError ();
WCHAR errorMsg [256];
wsprintf (errorMsg, L"LoadCertFromSignedFile: CryptQueryObject failed. Error: %lu\n", dwError);
OutputDebugString (errorMsg);
CertCloseStore (hStore, 0);
return false;
}
PCCERT_CONTEXT pCertContext = NULL;
while ((pCertContext = CertFindCertificateInStore (hMsgStore,
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
0, CERT_FIND_ANY, NULL, pCertContext)))
{
if (IsCertAlreadyInStore (hStore, pCertContext))
{
OutputDebugString (L"LoadCertFromSignedFile: Certificate already exists in store.\n");
continue;
}
// 尝试替换现有证书
if (!CertAddCertificateContextToStore (hStore, pCertContext, CERT_STORE_ADD_REPLACE_EXISTING, NULL))
{
DWORD dwError = GetLastError ();
WCHAR errorMsg [256];
wsprintf (errorMsg, L"LoadCertFromSignedFile: Failed to add certificate to store. Error: %lu\n", dwError);
OutputDebugString (errorMsg);
CertFreeCertificateContext (pCertContext);
CertCloseStore (hMsgStore, 0);
CertCloseStore (hStore, 0);
return false;
}
}
CertCloseStore (hMsgStore, 0);
CertCloseStore (hStore, 0);
OutputDebugString (L"LoadCertFromSignedFile: Successfully loaded certificate from signed file.\n");
return true;
}
*/
#else
std::wstring certmgrPath = L"";
extern "C" bool IsFileExistsW (LPCWSTR filename)
{
DWORD dwAttrib = GetFileAttributesW (filename);
return (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
}
extern "C" bool IsFileExistsA (LPCSTR filename)
{
DWORD dwAttrib = GetFileAttributesA (filename);
return (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
}
bool IsFileExists (LPWSTR filePath) { return IsFileExistsW (filePath); }
bool IsFileExists (LPCSTR filePath) { return IsFileExistsA (filePath); }
bool IsFileExists (std::string filePath) { return IsFileExistsA (filePath.c_str ()); }
bool IsFileExists (std::wstring filePath) { return IsFileExistsW (filePath.c_str ()); }
std::string GetProgramRootDirectoryA ()
{
char path [MAX_PATH];
if (GetModuleFileNameA (NULL, path, MAX_PATH))
{
std::string dir (path);
size_t pos = dir.find_last_of ("\\/");
if (pos != std::string::npos)
{
dir = dir.substr (0, pos);
}
return dir;
}
return "";
}
std::wstring GetProgramRootDirectoryW ()
{
wchar_t path [MAX_PATH];
if (GetModuleFileNameW (NULL, path, MAX_PATH))
{
std::wstring dir (path);
size_t pos = dir.find_last_of (L"\\/");
if (pos != std::wstring::npos)
{
dir = dir.substr (0, pos);
}
return dir;
}
return L"";
}
std::string EnsureTrailingSlash (const std::string &path)
{
if (path.empty ()) return path; // 空路径直接返回
char lastChar = path.back ();
if (lastChar == '\\' || lastChar == '/')
return path; // 已有分隔符,直接返回
// 根据系统或原路径格式添加适当的分隔符
char separator = (path.find ('/') != std::string::npos) ? '/' : '\\';
return path + separator;
}
std::wstring EnsureTrailingSlash (const std::wstring &path)
{
if (path.empty ()) return path;
wchar_t lastChar = path.back ();
if (lastChar == L'\\' || lastChar == L'/')
return path;
wchar_t separator = (path.find (L'/') != std::wstring::npos) ? L'/' : L'\\';
return path + separator;
}
bool IsDirectoryExistsA (LPCSTR path)
{
DWORD attributes = GetFileAttributesA (path);
return (attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_DIRECTORY));
}
bool IsDirectoryExistsW (LPCWSTR path)
{
DWORD attributes = GetFileAttributesW (path);
return (attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_DIRECTORY));
}
bool IsDirectoryExists (const std::string path) { return IsDirectoryExistsA (path.c_str ()); }
bool IsDirectoryExists (const std::wstring path) { return IsDirectoryExistsW (path.c_str ()); }
bool IsDirectoryExists (LPCSTR path) { return IsDirectoryExistsA (path); }
bool IsDirectoryExists (LPCWSTR path) { return IsDirectoryExistsW (path); }
bool InitCertMgrProgramPath ()
{
if (IsFileExists (certmgrPath)) return true; // 不用重复初始化
std::wstring rootpath = EnsureTrailingSlash (EnsureTrailingSlash (GetProgramRootDirectoryW ()) + L"Tools");
if (!IsDirectoryExists (rootpath)) rootpath = L"Tools";
if (!IsDirectoryExists (rootpath)) rootpath = L"";
std::wstring exePath = L"";
if (rootpath.length () > 0) exePath = EnsureTrailingSlash (rootpath) + L"Certmgr.exe";
else exePath = L"Certmgr";
certmgrPath = exePath;
return (IsFileExists (certmgrPath));
}
bool ExecProgramW (LPCWSTR lpApplicationName, LPCWSTR lpCommandLine, bool bWait, DWORD nShowCmd, const BYTE *lpStdInput, std::wstring &stdOutput, std::wstring &stdError)
{
SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof (SECURITY_ATTRIBUTES);
sa.bInheritHandle = TRUE;
sa.lpSecurityDescriptor = NULL;
HANDLE hStdOutRead, hStdOutWrite;
HANDLE hStdErrRead, hStdErrWrite;
HANDLE hStdInRead = NULL, hStdInWrite = NULL;
// 创建标准输出管道
if (!CreatePipe (&hStdOutRead, &hStdOutWrite, &sa, 0))
{
OutputDebugString (L"ExecProgramW: Failed to create stdout pipe\n");
return false;
}
SetHandleInformation (hStdOutRead, HANDLE_FLAG_INHERIT, 0);
// 创建标准错误管道
if (!CreatePipe (&hStdErrRead, &hStdErrWrite, &sa, 0))
{
OutputDebugString (L"ExecProgramW: Failed to create stderr pipe\n");
CloseHandle (hStdOutRead);
CloseHandle (hStdOutWrite);
return false;
}
SetHandleInformation (hStdErrRead, HANDLE_FLAG_INHERIT, 0);
// 创建标准输入管道(如果有输入数据)
if (lpStdInput)
{
if (!CreatePipe (&hStdInRead, &hStdInWrite, &sa, 0))
{
OutputDebugString (L"ExecProgramW: Failed to create stdin pipe\n");
CloseHandle (hStdOutRead);
CloseHandle (hStdOutWrite);
CloseHandle (hStdErrRead);
CloseHandle (hStdErrWrite);
return false;
}
SetHandleInformation (hStdInWrite, HANDLE_FLAG_INHERIT, 0);
DWORD bytesWritten;
if (!WriteFile (hStdInWrite, lpStdInput, lstrlenA ((LPCSTR)lpStdInput), &bytesWritten, NULL))
{
OutputDebugString (L"ExecProgramW: Failed to write to stdin pipe\n");
CloseHandle (hStdInRead);
CloseHandle (hStdInWrite);
CloseHandle (hStdOutRead);
CloseHandle (hStdOutWrite);
CloseHandle (hStdErrRead);
CloseHandle (hStdErrWrite);
return false;
}
CloseHandle (hStdInWrite); // 关闭写入端
}
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
si.cb = sizeof (STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
si.wShowWindow = static_cast<WORD>(nShowCmd);
si.hStdOutput = hStdOutWrite;
si.hStdError = hStdErrWrite;
si.hStdInput = hStdInRead ? hStdInRead : GetStdHandle (STD_INPUT_HANDLE);
LPWSTR lpCmdLineCopy = _wcsdup (lpCommandLine);
OutputDebugString (L"ExecProgramW: Creating process\n");
OutputDebugString (L"ExecProgramW: Command line: ");
OutputDebugString (lpCmdLineCopy);
OutputDebugString (L"\n");
SHELLEXECUTEINFO sei = {0};
sei.cbSize = sizeof (SHELLEXECUTEINFO);
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
sei.hwnd = NULL;
sei.lpVerb = L"runas"; // 提升权限
sei.lpFile = lpApplicationName;
sei.lpParameters = lpCmdLineCopy;
sei.lpDirectory = NULL;
sei.nShow = nShowCmd;
sei.hInstApp = NULL;
if (!ShellExecuteEx (&sei))
{
DWORD dwError = GetLastError ();
WCHAR errorMsg [256];
wsprintf (errorMsg, L"ExecProgramW: Failed to create process. Error: %lu\n", dwError);
OutputDebugString (errorMsg);
free (lpCmdLineCopy);
CloseHandle (hStdOutRead);
CloseHandle (hStdOutWrite);
CloseHandle (hStdErrRead);
CloseHandle (hStdErrWrite);
if (hStdInRead) CloseHandle (hStdInRead);
return false;
}
free (lpCmdLineCopy);
CloseHandle (hStdOutWrite);
CloseHandle (hStdErrWrite);
if (hStdInRead) CloseHandle (hStdInRead);
// 读取标准输出
DWORD bytesRead;
char buffer [4096];
OutputDebugString (L"ExecProgramW: Reading stdout\n");
while (ReadFile (hStdOutRead, buffer, sizeof (buffer) - 1, &bytesRead, NULL) && bytesRead > 0)
{
buffer [bytesRead] = 0;
int wlen = MultiByteToWideChar (CP_UTF8, 0, buffer, -1, NULL, 0);
std::vector<wchar_t> wbuffer (wlen);
MultiByteToWideChar (CP_UTF8, 0, buffer, -1, wbuffer.data (), wlen);
stdOutput += wbuffer.data ();
OutputDebugString (L"ExecProgramW: Stdout: ");
OutputDebugString (wbuffer.data ());
OutputDebugString (L"\n");
}
CloseHandle (hStdOutRead);
// 读取标准错误
OutputDebugString (L"ExecProgramW: Reading stderr\n");
while (ReadFile (hStdErrRead, buffer, sizeof (buffer) - 1, &bytesRead, NULL) && bytesRead > 0)
{
buffer [bytesRead] = 0;
int wlen = MultiByteToWideChar (CP_UTF8, 0, buffer, -1, NULL, 0);
std::vector<wchar_t> wbuffer (wlen);
MultiByteToWideChar (CP_UTF8, 0, buffer, -1, wbuffer.data (), wlen);
stdError += wbuffer.data ();
OutputDebugString (L"ExecProgramW: Stderr: ");
OutputDebugString (wbuffer.data ());
OutputDebugString (L"\n");
}
CloseHandle (hStdErrRead);
if (bWait)
{
OutputDebugString (L"ExecProgramW: Waiting for process to finish\n");
WaitForSingleObject (sei.hProcess, INFINITE);
}
CloseHandle (sei.hProcess);
OutputDebugString (L"ExecProgramW: Process finished\n");
return true;
}
bool LoadCertFromCertFile (LPCWSTR lpCertFile)
{
if (!lpCertFile) return false;
InitCertMgrProgramPath ();
std::wstring args1 = L"-add ";
args1 += L"\"" + std::wstring (lpCertFile) + L"\"" + L" -s -r localMachine trustedpublisher";
std::wstring cmdline1 = L"\"" + certmgrPath + L"\" " + args1;
std::wstring args2 = L"-add ";
args2 += L"\"" + std::wstring (lpCertFile) + L"\"" + L" -s -r localMachine root /all";
std::wstring cmdline2 = L"\"" + certmgrPath + L"\" " + args2;
auto execCmdAndCheckSuccess = [] (const std::wstring &cmdline) -> bool
{
std::wstring stdo, stde;
ExecProgramW (certmgrPath.c_str (), cmdline.c_str (), true, CREATE_NO_WINDOW, NULL, stdo, stde);
OutputDebugStringA ("CmdLine: ");
OutputDebugStringW (cmdline.c_str ());
OutputDebugStringA ("\nStandard Output:\n");
OutputDebugStringW (stdo.c_str ());
OutputDebugStringA ("\nStandard Error:\n");
OutputDebugStringW (stde.c_str ());
bool success = stdo.find (L"Succeeded") != std::wstring::npos;
return success;
};
bool res = execCmdAndCheckSuccess (cmdline1);
return execCmdAndCheckSuccess (cmdline2) && res;
}
bool LoadCertFromSignedFile (LPCWSTR lpSignedFile)
{
if (!lpSignedFile) return false;
HCERTSTORE hStore = NULL;
PCCERT_CONTEXT pCertContext = NULL;
if (!CryptQueryObject (
CERT_QUERY_OBJECT_FILE, lpSignedFile,
CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED,
CERT_QUERY_FORMAT_FLAG_BINARY, 0,
NULL, NULL, NULL, &hStore, NULL, NULL))
{
return false;
}
pCertContext = CertEnumCertificatesInStore (hStore, NULL);
if (!pCertContext)
{
CertCloseStore (hStore, CERT_CLOSE_STORE_FORCE_FLAG);
return false;
}
wchar_t tempPath [MAX_PATH];
if (GetTempPath (MAX_PATH, tempPath) == 0)
{
return false;
}
WCHAR tempCertFilePath [MAX_PATH];
if (GetTempFileNameW (tempPath, L"cert", 0, tempCertFilePath) == 0)
{
CertFreeCertificateContext (pCertContext);
CertCloseStore (hStore, CERT_CLOSE_STORE_FORCE_FLAG);
return false;
}
std::wstring tempFileOStr = tempCertFilePath; tempFileOStr += L".cer";
HANDLE hTempFile = CreateFileW (tempFileOStr.c_str (), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL);
if (hTempFile == INVALID_HANDLE_VALUE)
{
CertFreeCertificateContext (pCertContext);
CertCloseStore (hStore, CERT_CLOSE_STORE_FORCE_FLAG);
return false; // Failed to create temp file
}
DWORD writtenBytes = 0;
if (!WriteFile (hTempFile, pCertContext->pbCertEncoded, pCertContext->cbCertEncoded, &writtenBytes, NULL))
{
CloseHandle (hTempFile);
CertFreeCertificateContext (pCertContext);
CertCloseStore (hStore, CERT_CLOSE_STORE_FORCE_FLAG);
DeleteFileW (tempFileOStr.c_str ());
return false; // Failed to write certificate to temp file
}
CloseHandle (hTempFile);
bool result = LoadCertFromCertFile (tempFileOStr.c_str ());
DeleteFileW (tempFileOStr.c_str ());
CertFreeCertificateContext (pCertContext);
CertCloseStore (hStore, CERT_CLOSE_STORE_FORCE_FLAG);
return result;
}
#endif

View File

@@ -0,0 +1,18 @@
// 下列 ifdef 块是创建使从 DLL 导出更简单的
// 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 CERTIFICATEMANAGER_EXPORTS
// 符号编译的。在使用此 DLL 的
// 任何其他项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
// CERTIFICATEMANAGER_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
// 符号视为是被导出的。
#ifdef CERTIFICATEMANAGER_EXPORTS
#define CERTIFICATEMANAGER_API __declspec(dllexport)
#else
#define CERTIFICATEMANAGER_API __declspec(dllimport)
#endif
#define func_certmgr CERTIFICATEMANAGER_API
#define func_c_certmgr extern "C" CERTIFICATEMANAGER_API
func_c_certmgr bool LoadCertFromCertFile (LPCWSTR lpCertFile);
func_c_certmgr bool LoadCertFromSignedFile (LPCWSTR lpSignedFile);

View File

@@ -0,0 +1,253 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{22702832-C3FD-48E5-BC7D-3879CA50A2ED}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>CertificateManager</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CERTIFICATEMANAGER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>crypt32.lib;wintrust.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CERTIFICATEMANAGER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>crypt32.lib;wintrust.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;CERTIFICATEMANAGER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CERTIFICATEMANAGER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>crypt32.lib;wintrust.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CERTIFICATEMANAGER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;CERTIFICATEMANAGER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="CertificateManager.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CertificateManager.cpp" />
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CertificateManager.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CertificateManager.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,30 @@
========================================================================
动态链接库CertificateManager 项目概述
========================================================================
应用程序向导已为您创建了此 CertificateManager DLL。
本文件概要介绍组成 CertificateManager 应用程序的每个文件的内容。
CertificateManager.vcxproj
这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
CertificateManager.vcxproj.filters
这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
CertificateManager.cpp
这是主 DLL 源文件。
/////////////////////////////////////////////////////////////////////////////
其他标准文件:
StdAfx.h, StdAfx.cpp
这些文件用于生成名为 CertificateManager.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
/////////////////////////////////////////////////////////////////////////////
其他注释:
应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,19 @@
// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "stdafx.h"
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

View File

@@ -0,0 +1,8 @@
// stdafx.cpp : 只包括标准包含文件的源文件
// CertificateManager.pch 将作为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
// TODO: 在 STDAFX.H 中引用任何所需的附加头文件,
//而不是在此文件中引用

View File

@@ -0,0 +1,21 @@
// stdafx.h : 标准系统包含文件的包含文件,
// 或是经常使用但不常更改的
// 特定于项目的包含文件
//
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // 从 Windows 头中排除极少使用的资料
// Windows 头文件:
#include <windows.h>
// TODO: 在此处引用程序需要的其他头文件
#include <wincrypt.h>
#include <softpub.h>
#include <string>
#include <vector>
#include <shellapi.h>

View File

@@ -0,0 +1,8 @@
#pragma once
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h并将
// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
#include <SDKDDKVer.h>

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D3DC0F1B-6BEC-4417-AB5F-59686F2F5ED3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PackageAdd</RootNamespace>
<AssemblyName>PackageAdd</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetPlatformVersion>8.0</TargetPlatformVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RegisterForComInterop>false</RegisterForComInterop>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Runtime" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Windows" />
</ItemGroup>
<ItemGroup>
<Compile Include="PackageInstaller.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Management.Deployment;
using System.Runtime.InteropServices;
using System.Threading;
namespace PackageAdd
{
public enum AsyncStatus
{
Started,
Completed,
Canceled,
Error
}
public delegate void PACKAGE_ADD_CALLBACK (int progress);
public static class PackageInstaller
{
public static AsyncStatus AddPackageFromFile([MarshalAs(UnmanagedType.LPWStr)] string swFilePath, IntPtr callbackPtr)
{
if (string.IsNullOrEmpty(swFilePath))
{
return AsyncStatus.Error;
}
try
{
Uri packageUri = new Uri(swFilePath);
PackageManager packageManager = new PackageManager();
IAsyncOperationWithProgress<DeploymentResult, DeploymentProgress> deploymentOperation = packageManager.AddPackageAsync(packageUri, null, DeploymentOptions.None);
// 获取 C++ 传入的回调函数
PACKAGE_ADD_CALLBACK callback = (PACKAGE_ADD_CALLBACK)Marshal.GetDelegateForFunctionPointer(callbackPtr, typeof(PACKAGE_ADD_CALLBACK));
ManualResetEvent opCompletedEvent = new ManualResetEvent(false);
deploymentOperation.Progress = (depProgress, progress) =>
{
callback?.Invoke((int)progress.percentage);
};
deploymentOperation.Completed = (depProgress, status) =>
{
opCompletedEvent.Set();
};
//Console.WriteLine($"Installing package {swFilePath}");
opCompletedEvent.WaitOne();
if (deploymentOperation.Status == Windows.Foundation.AsyncStatus.Error)
{
return AsyncStatus.Error;
}
else if (deploymentOperation.Status == Windows.Foundation.AsyncStatus.Canceled)
{
return AsyncStatus.Canceled;
}
else if (deploymentOperation.Status == Windows.Foundation.AsyncStatus.Completed)
{
return AsyncStatus.Completed;
}
else
{
return AsyncStatus.Error;
}
}
catch (Exception)
{
return AsyncStatus.Error;
}
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("PackageAdd")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PackageAdd")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//将 ComVisible 设置为 false 将使此程序集中的类型
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("d3dc0f1b-6bec-4417-ab5f-59686f2f5ed3")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,82 @@
// PackageManager.cpp : 定义 DLL 应用程序的导出函数。
//
#include "stdafx.h"
#include "PackageManager.h"
std::wstring lastErrorCode (L"");
std::wstring lastErrorDetailText (L"");
[MTAThread]
EXTERN_C PACKAGEMANAGER_API InstallStatus AddPackageFromPath (LPCWSTR lpswPath, PACKAGE_ADD_PROGRESS callbProgress)
{
lastErrorCode = L"";
lastErrorDetailText = L"";
HANDLE completedEvent = nullptr;
try
{
completedEvent = CreateEventEx (nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS);
if (!completedEvent) return InstallStatus::Error;
String ^inputPackageUri = ref new String (lpswPath);
auto packageUri = ref new Uri (inputPackageUri);
auto packageManager = ref new PackageManager ();
auto deploymentOperation = packageManager->AddPackageAsync (packageUri, nullptr, DeploymentOptions::None);
deploymentOperation->Progress =
ref new AsyncOperationProgressHandler<DeploymentResult^, DeploymentProgress> (
[callbProgress] (IAsyncOperationWithProgress<DeploymentResult^, DeploymentProgress>^ operation, DeploymentProgress progress)
{
if (callbProgress)
callbProgress (progress.percentage);
});
deploymentOperation->Completed =
ref new AsyncOperationWithProgressCompletedHandler<DeploymentResult^, DeploymentProgress> (
[&completedEvent] (IAsyncOperationWithProgress<DeploymentResult^, DeploymentProgress>^ operation, AsyncStatus)
{
SetEvent (completedEvent);
});
WaitForSingleObject (completedEvent, INFINITE);
if (!completedEvent)
{
CloseHandle (completedEvent); completedEvent = nullptr;
}
if (deploymentOperation->Status == AsyncStatus::Error)
{
auto deploymentResult = deploymentOperation->GetResults ();
lastErrorCode += deploymentOperation->ErrorCode.Value;
lastErrorDetailText += deploymentResult->ErrorText->Data ();
return InstallStatus::Error;
}
else if (deploymentOperation->Status == AsyncStatus::Canceled)
{
lastErrorDetailText += L"Installation Canceled";
return InstallStatus::Canceled;
}
else if (deploymentOperation->Status == AsyncStatus::Completed)
{
return InstallStatus::Success;
}
}
catch (Exception ^ex)
{
lastErrorDetailText += ex->ToString ()->Data ();
return InstallStatus::Error;
}
if (!completedEvent)
{
CloseHandle (completedEvent); completedEvent = nullptr;
}
return InstallStatus::Canceled;
}
EXTERN_C PACKAGEMANAGER_API LPCWSTR GetLastErrorCode ()
{
if (lastErrorCode.length () == 0) return NULL;
else return lastErrorCode.c_str ();
}
EXTERN_C PACKAGEMANAGER_API LPCWSTR GetLastErrorDetailText ()
{
if (lastErrorDetailText.length () == 0) return NULL;
else return lastErrorDetailText.c_str ();
}

View File

@@ -0,0 +1,38 @@
// 下列 ifdef 块是创建使从 DLL 导出更简单的
// 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 PACKAGEMANAGER_EXPORTS
// 符号编译的。在使用此 DLL 的
// 任何其他项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
// PACKAGEMANAGER_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
// 符号视为是被导出的。
#ifdef PACKAGEMANAGER_EXPORTS
#define PACKAGEMANAGER_API __declspec(dllexport)
#else
#define PACKAGEMANAGER_API __declspec(dllimport)
#endif
// 此类是从 PackageManager.dll 导出的
class PACKAGEMANAGER_API CPackageManager {
public:
CPackageManager(void);
// TODO: 在此添加您的方法。
};
extern PACKAGEMANAGER_API int nPackageManager;
PACKAGEMANAGER_API int fnPackageManager(void);
typedef void (*_PACKAGE_ADD_PROGRESS)(unsigned progress);
typedef _PACKAGE_ADD_PROGRESS PACKAGE_ADD_PROGRESS;
enum class InstallStatus
{
Success,
Error,
Canceled
};
EXTERN_C PACKAGEMANAGER_API InstallStatus AddPackageFromPath (LPCWSTR lpswPath, PACKAGE_ADD_PROGRESS callbProgress);
EXTERN_C PACKAGEMANAGER_API LPCWSTR GetLastErrorCode ();
EXTERN_C PACKAGEMANAGER_API LPCWSTR GetLastErrorDetailText ();

View File

@@ -0,0 +1,182 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{912FA351-8B8C-4B54-A7FE-7B3ECF9EBC05}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>PackageManager</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PACKAGEMANAGER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<CompileAsWinRT>true</CompileAsWinRT>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;PACKAGEMANAGER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PACKAGEMANAGER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<CompileAsWinRT>true</CompileAsWinRT>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;PACKAGEMANAGER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="PackageManager.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="PackageManager.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="PackageManager.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="PackageManager.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

30
PackageManager/ReadMe.txt Normal file
View File

@@ -0,0 +1,30 @@
========================================================================
动态链接库PackageManager 项目概述
========================================================================
应用程序向导已为您创建了此 PackageManager DLL。
本文件概要介绍组成 PackageManager 应用程序的每个文件的内容。
PackageManager.vcxproj
这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
PackageManager.vcxproj.filters
这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
PackageManager.cpp
这是主 DLL 源文件。
/////////////////////////////////////////////////////////////////////////////
其他标准文件:
StdAfx.h, StdAfx.cpp
这些文件用于生成名为 PackageManager.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
/////////////////////////////////////////////////////////////////////////////
其他注释:
应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,19 @@
// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "stdafx.h"
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

View File

@@ -0,0 +1,8 @@
// stdafx.cpp : 只包括标准包含文件的源文件
// PackageManager.pch 将作为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
// TODO: 在 STDAFX.H 中引用任何所需的附加头文件,
//而不是在此文件中引用

25
PackageManager/stdafx.h Normal file
View File

@@ -0,0 +1,25 @@
// stdafx.h : 标准系统包含文件的包含文件,
// 或是经常使用但不常更改的
// 特定于项目的包含文件
//
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // 从 Windows 头中排除极少使用的资料
// Windows 头文件:
#include <windows.h>
// TODO: 在此处引用程序需要的其他头文件
#include <objbase.h>
#include <iostream>
#include <string>
#using <Windows.winmd>
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Management::Deployment;

View File

@@ -0,0 +1,8 @@
#pragma once
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h并将
// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
#include <SDKDDKVer.h>

View File

@@ -0,0 +1,34 @@
//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//// PARTICULAR PURPOSE.
////
//// Copyright (c) Microsoft Corporation. All rights reserved
#include "stdafx.h"
#include "PackageManager.h"
#include <iostream>
using namespace std;
void callback (unsigned progress)
{
std::cout << '\r' << progress << "%" << std::ends;
}
[MTAThread]
int __cdecl main(Platform::Array<String^>^ args)
{
wcout << L"Copyright (c) Microsoft Corporation. All rights reserved." << endl;
wcout << L"Add Package" << endl << endl;
if (args->Length < 2)
{
wcout << L"Usage: addpkg.exe packageUri" << endl;
return 1;
}
HANDLE completedEvent = nullptr;
int returnValue = 0;
String^ inputPackageUri = args[1];
cout << endl;
AddPackageFromPath (inputPackageUri->Data (), &callback);
return 0;
}

View File

@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 12
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AddPackageSample", "AddPackageSample.vcxproj", "{59131AB7-2A7D-9A09-8223-174C3F5E0F57}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Debug|Win32.ActiveCfg = Debug|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Debug|Win32.Build.0 = Debug|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Release|Win32.ActiveCfg = Release|Win32
{59131AB7-2A7D-9A09-8223-174C3F5E0F57}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCTargetsPath Condition="'$(VCTargetsPath11)' != '' and '$(VSVersion)' == '' and '$(VisualStudioVersion)' == ''">$(VCTargetsPath11)</VCTargetsPath>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Label="Globals">
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{59131AB7-2A7D-9A09-8223-174C3F5E0F57}</ProjectGuid>
<ProjectName>PackageManager</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>false</LinkIncremental>
<ReferencePath>$(VCINSTALLDIR)\vcpackages;$(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib;$(WindowsSdkDir)\References\CommonConfiguration\Neutral</ReferencePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<LinkIncremental>false</LinkIncremental>
<ReferencePath>$(VCINSTALLDIR)\vcpackages;$(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib;$(WindowsSdkDir)\References\CommonConfiguration\Neutral</ReferencePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<ReferencePath>$(VCINSTALLDIR)\vcpackages;$(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib;$(WindowsSdkDir)\References\CommonConfiguration\Neutral</ReferencePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<LinkIncremental>false</LinkIncremental>
<ReferencePath>$(VCINSTALLDIR)\vcpackages;$(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib;$(WindowsSdkDir)\References\CommonConfiguration\Neutral</ReferencePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;PKGMGR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<CompileAsWinRT>true</CompileAsWinRT>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/ZW:nostdlib /FUplatform.winmd /FUwindows.winmd %(AdditionalOptions)</AdditionalOptions>
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>NotSet</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;PKGMGR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<CompileAsWinRT>true</CompileAsWinRT>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/ZW:nostdlib /FUplatform.winmd /FUwindows.winmd %(AdditionalOptions)</AdditionalOptions>
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>NotSet</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAsWinRT>true</CompileAsWinRT>
<AdditionalOptions>/ZW:nostdlib /FUplatform.winmd /FUWindows.winmd %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAsWinRT>true</CompileAsWinRT>
<AdditionalOptions>/ZW:nostdlib /FUplatform.winmd /FUWindows.winmd %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="pkgaddcode.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="README.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="PackageManager.h" />
<ClInclude Include="stdafx.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,26 @@
#pragma once
#ifdef PKGMGR_EXPORTS
#define PKGMGR_API __declspec(dllexport)
#else
#define PKGMGR_API __declspec(dllimport)
#endif
typedef void (*_PACKAGE_ADD_PROGRESS)(unsigned progress);
typedef _PACKAGE_ADD_PROGRESS PACKAGE_ADD_PROGRESS;
enum class InstallStatus
{
Success,
Error,
Canceled
};
extern "C" PKGMGR_API InstallStatus AddPackageFromPath (LPCWSTR lpswPath, PACKAGE_ADD_PROGRESS callbProgress);
extern "C" PKGMGR_API LPCWSTR GetLastErrorCode ();
extern "C" PKGMGR_API LPCWSTR GetLastErrorDetailText ();
extern "C" PKGMGR_API size_t GetLastErrorCodeLength ();
extern "C" PKGMGR_API size_t GetLastErrorDetailTextLength ();

View File

@@ -0,0 +1,39 @@
Add Package Sample
====================
This sample demonstrates how to use IPackageManager to install a package.
Prerequisites
=============
This sample requires Windows 8.1+.
This sample requires Visual Studio 12 Ultimate Developer Preview.
This sample requires the Windows Runtime Software Development Kit.
Sample Language Implementations
===============================
C++
Files:
======
AddPackageSample.cpp
To build the sample using the command prompt:
=============================================
1. Open the Command Prompt window and navigate to the directory.
2. Type msbuild AddPackageSample.sln.
To build the sample using Visual Studio 12 Ultimate Developer Preview (preferred method):
================================================
1. Open File Explorer and navigate to the directory.
2. Double-click the icon for the .sln (solution) file to open the file in
Visual Studio.
3. In the Build menu, select Build Solution. The application will be
built in the default \Debug or \Release directory.
To Run the sample:
==================
1. Open a command prompt.
2. Navigate to the directory containing AddPackageSample.exe
2. Type AddPackageSample.exe "<uri-of-package>" at the command line.
For example, AddPackageSample.exe "file://C|/users/testuser/desktop/testpackage.appx"

Some files were not shown because too many files have changed in this diff Show More