mirror of
https://github.com/modernw/App-Installer-For-Windows-8.x-Reset.git
synced 2026-04-21 18:40:25 +10:00
添加项目文件。
This commit is contained in:
58
AppInstallerReset.sln
Normal file
58
AppInstallerReset.sln
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
|
||||||
|
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", "AppInstallerReset\AppInstallerReset.vcxproj", "{C96219BE-8AFF-4914-8933-B6B7047A94D8}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pkgread", "pkgread\pkgread.vcxproj", "{A7753282-AA16-43D9-8ACA-7065239DD702}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "prireader", "prireader\prireader.vcxproj", "{D8CFAA98-0A77-4C5B-A61B-11EF44206712}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dlltest", "dlltest\dlltest.vcxproj", "{F5CCB3AB-AC43-432A-862D-4F264760B09B}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{C96219BE-8AFF-4914-8933-B6B7047A94D8}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{C96219BE-8AFF-4914-8933-B6B7047A94D8}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{C96219BE-8AFF-4914-8933-B6B7047A94D8}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{C96219BE-8AFF-4914-8933-B6B7047A94D8}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{C96219BE-8AFF-4914-8933-B6B7047A94D8}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{C96219BE-8AFF-4914-8933-B6B7047A94D8}.Release|x64.Build.0 = Release|x64
|
||||||
|
{C96219BE-8AFF-4914-8933-B6B7047A94D8}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{C96219BE-8AFF-4914-8933-B6B7047A94D8}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{A7753282-AA16-43D9-8ACA-7065239DD702}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{A7753282-AA16-43D9-8ACA-7065239DD702}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{A7753282-AA16-43D9-8ACA-7065239DD702}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{A7753282-AA16-43D9-8ACA-7065239DD702}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{A7753282-AA16-43D9-8ACA-7065239DD702}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{A7753282-AA16-43D9-8ACA-7065239DD702}.Release|x64.Build.0 = Release|x64
|
||||||
|
{A7753282-AA16-43D9-8ACA-7065239DD702}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{A7753282-AA16-43D9-8ACA-7065239DD702}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{D8CFAA98-0A77-4C5B-A61B-11EF44206712}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{D8CFAA98-0A77-4C5B-A61B-11EF44206712}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{D8CFAA98-0A77-4C5B-A61B-11EF44206712}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{D8CFAA98-0A77-4C5B-A61B-11EF44206712}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{D8CFAA98-0A77-4C5B-A61B-11EF44206712}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{D8CFAA98-0A77-4C5B-A61B-11EF44206712}.Release|x64.Build.0 = Release|x64
|
||||||
|
{D8CFAA98-0A77-4C5B-A61B-11EF44206712}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{D8CFAA98-0A77-4C5B-A61B-11EF44206712}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{F5CCB3AB-AC43-432A-862D-4F264760B09B}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{F5CCB3AB-AC43-432A-862D-4F264760B09B}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{F5CCB3AB-AC43-432A-862D-4F264760B09B}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{F5CCB3AB-AC43-432A-862D-4F264760B09B}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{F5CCB3AB-AC43-432A-862D-4F264760B09B}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{F5CCB3AB-AC43-432A-862D-4F264760B09B}.Release|x64.Build.0 = Release|x64
|
||||||
|
{F5CCB3AB-AC43-432A-862D-4F264760B09B}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{F5CCB3AB-AC43-432A-862D-4F264760B09B}.Release|x86.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
154
AppInstallerReset/AppInstallerReset.vcxproj
Normal file
154
AppInstallerReset/AppInstallerReset.vcxproj
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
<?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>{C96219BE-8AFF-4914-8933-B6B7047A94D8}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>AppInstallerReset</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||||
|
<ProjectName>appinstaller</ProjectName>
|
||||||
|
</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>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</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 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>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</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>MaxSpeed</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>
|
||||||
|
</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>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
17
AppInstallerReset/AppInstallerReset.vcxproj.filters
Normal file
17
AppInstallerReset/AppInstallerReset.vcxproj.filters
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?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>
|
||||||
|
</Project>
|
||||||
160
dlltest/dlltest.vcxproj
Normal file
160
dlltest/dlltest.vcxproj
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
<?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>{F5CCB3AB-AC43-432A-862D-4F264760B09B}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>dlltest</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||||
|
</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>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</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 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>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>$(OutDir)pkgread.lib;%(AdditionalDependencies)</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;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\pkgread\pkgread.vcxproj">
|
||||||
|
<Project>{a7753282-aa16-43d9-8aca-7065239dd702}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="main.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
22
dlltest/dlltest.vcxproj.filters
Normal file
22
dlltest/dlltest.vcxproj.filters
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?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>
|
||||||
|
<ClCompile Include="main.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
76
dlltest/main.cpp
Normal file
76
dlltest/main.cpp
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
#include <Windows.h>
|
||||||
|
#include "..\pkgread\pkgread.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
int main (int argc, char *argv [])
|
||||||
|
{
|
||||||
|
// 1. 创建 Reader 对象
|
||||||
|
HPKGREAD hReader = CreatePackageReader ();
|
||||||
|
if (!hReader) {
|
||||||
|
std::wcerr << L"CreatePackageReader failed!" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
std::wcout << L"CreatePackageReader succeeded!" << std::endl;
|
||||||
|
|
||||||
|
// 2. 加载包文件
|
||||||
|
std::wcout << L"Please enter the file path: " << std::endl;
|
||||||
|
std::wcout << L"\\> ";
|
||||||
|
std::wstring pkgPathStr;
|
||||||
|
std::getline (std::wcin, pkgPathStr);
|
||||||
|
if (!pkgPathStr.empty () && pkgPathStr.front () == L'\"' && pkgPathStr.back () == L'\"' && pkgPathStr.size () >= 2) {
|
||||||
|
pkgPathStr = pkgPathStr.substr (1, pkgPathStr.size () - 2);
|
||||||
|
}
|
||||||
|
LPCWSTR pkgPath = pkgPathStr.c_str ();
|
||||||
|
if (!LoadPackageFromFile (hReader, pkgPath)) {
|
||||||
|
std::wcerr << L"LoadPackageFromFile failed for " << pkgPath << std::endl;
|
||||||
|
DestroyPackageReader (hReader);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
std::wcout << L"LoadPackageFromFile succeeded!" << std::endl;
|
||||||
|
|
||||||
|
// 3. 验证包类型
|
||||||
|
WORD type = GetPackageType (hReader);
|
||||||
|
std::wcout << L"Package Type: " << type << std::endl;
|
||||||
|
|
||||||
|
// 4. 验证包有效性
|
||||||
|
BOOL valid = IsPackageValid (hReader);
|
||||||
|
std::wcout << L"IsPackageValid: " << (valid ? L"True" : L"False") << std::endl;
|
||||||
|
|
||||||
|
// 5. 获取包名称
|
||||||
|
LPWSTR pkgName = GetPackageIdentityStringValue (hReader, PKG_IDENTITY_NAME);
|
||||||
|
if (pkgName)
|
||||||
|
std::wcout << L"Package Name: " << pkgName << std::endl;
|
||||||
|
else
|
||||||
|
std::wcerr << L"GetPackageIdentityStringValue PKG_IDENTITY_NAME failed!" << std::endl;
|
||||||
|
|
||||||
|
// 6. 获取包版本
|
||||||
|
VERSION ver;
|
||||||
|
if (GetPackageIdentityVersion (hReader, &ver, FALSE)) {
|
||||||
|
std::wcout << L"Package Version: " << ver.major << L"." << ver.minor << L"." << ver.build << L"." << ver.revision << std::endl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::wcerr << L"GetPackageIdentityVersion failed!" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7. 列举所有 Application 名称
|
||||||
|
HLIST_PVOID appList = GetAllApplicationItemsName ();
|
||||||
|
if (appList) {
|
||||||
|
std::wcout << L"Application Count: " << appList->dwSize << std::endl;
|
||||||
|
for (DWORD i = 0; i < appList->dwSize; ++i) {
|
||||||
|
LPCWSTR appName = (LPCWSTR)appList->alpVoid [i];
|
||||||
|
if (appName)
|
||||||
|
std::wcout << L"App[" << i << L"]: " << appName << std::endl;
|
||||||
|
}
|
||||||
|
DestroyApplicationItemsName (appList);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::wcerr << L"GetAllApplicationItemsName failed!" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 8. 清理
|
||||||
|
DestroyPackageReader (hReader);
|
||||||
|
|
||||||
|
system ("pause");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
30
pkgread/ReadMe.txt
Normal file
30
pkgread/ReadMe.txt
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
========================================================================
|
||||||
|
动态链接库:pkgread 项目概述
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
应用程序向导已为您创建了此 pkgread DLL。
|
||||||
|
|
||||||
|
本文件概要介绍组成 pkgread 应用程序的每个文件的内容。
|
||||||
|
|
||||||
|
|
||||||
|
pkgread.vcxproj
|
||||||
|
这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
|
||||||
|
|
||||||
|
pkgread.vcxproj.filters
|
||||||
|
这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
|
||||||
|
|
||||||
|
pkgread.cpp
|
||||||
|
这是主 DLL 源文件。
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
其他标准文件:
|
||||||
|
|
||||||
|
StdAfx.h, StdAfx.cpp
|
||||||
|
这些文件用于生成名为 pkgread.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
其他注释:
|
||||||
|
|
||||||
|
应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
21
pkgread/dllmain.cpp
Normal file
21
pkgread/dllmain.cpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// 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:
|
||||||
|
CoInitializeEx (NULL, COINIT_MULTITHREADED); break;
|
||||||
|
case DLL_THREAD_DETACH:
|
||||||
|
case DLL_PROCESS_DETACH:
|
||||||
|
CoUninitialize ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
77
pkgread/dynarr.h
Normal file
77
pkgread/dynarr.h
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
template <class T> bool compare_default (const T &l, const T &r) { return l == r; }
|
||||||
|
template <class T> bool find_vec (std::vector <T> &vec, const T &value, const std::function <void (size_t)> &callback, std::function<bool (const T &, const T &)> compare = compare_default <T>, bool sorted = false)
|
||||||
|
{
|
||||||
|
const size_t n = vec.size ();
|
||||||
|
if (!compare) compare = compare_default<T>;
|
||||||
|
if (sorted)
|
||||||
|
{
|
||||||
|
size_t left = 0, right = n;
|
||||||
|
while (left < right)
|
||||||
|
{
|
||||||
|
size_t mid = left + (right - left) / 2;
|
||||||
|
if (compare (vec [mid], value))
|
||||||
|
{
|
||||||
|
callback (mid);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (vec [mid] < value) left = mid + 1;
|
||||||
|
else right = mid;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (n < 64)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
if (compare (vec [i], value))
|
||||||
|
{
|
||||||
|
callback (i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const size_t blockSize = 8;
|
||||||
|
size_t i = 0;
|
||||||
|
for (; i + blockSize <= n; i += blockSize)
|
||||||
|
{
|
||||||
|
for (size_t j = 0; j < blockSize; j ++)
|
||||||
|
{
|
||||||
|
if (compare (vec [i + j], value))
|
||||||
|
{
|
||||||
|
callback (i + j);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (; i < n; i ++)
|
||||||
|
{
|
||||||
|
if (compare (vec [i], value))
|
||||||
|
{
|
||||||
|
callback (i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
template <class T> void push_unique (std::vector <T> &vec, const T &value, std::function <bool (const T &, const T &)> compare = compare_default <T>)
|
||||||
|
{
|
||||||
|
bool found = find_vec <T> (
|
||||||
|
vec, value,
|
||||||
|
[] (size_t) {},
|
||||||
|
compare);
|
||||||
|
if (!found) vec.push_back (value);
|
||||||
|
}
|
||||||
|
template <class T> void push_normal (std::vector <T> &vec, const T &value)
|
||||||
|
{
|
||||||
|
vec.push_back (value);
|
||||||
|
}
|
||||||
|
template <class T> void push_normal (std::vector <T> &target, const std::vector <T> &another)
|
||||||
|
{
|
||||||
|
target.insert (target.end (), another.begin (), another.end ());
|
||||||
|
}
|
||||||
163
pkgread/localeex.h
Normal file
163
pkgread/localeex.h
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <WinNls.h>
|
||||||
|
#include <string>
|
||||||
|
static 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef GetLocaleInfo
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
void GetLocaleInfo (LCID code, LCTYPE type, std::wstring &output)
|
||||||
|
{
|
||||||
|
output = GetLocaleInfoW (code, type);
|
||||||
|
}
|
||||||
|
void GetLocaleInfo (LCID code, LCTYPE type, std::string &output)
|
||||||
|
{
|
||||||
|
output = GetLocaleInfoA (code, type);
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef SetLocaleInfo
|
||||||
|
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 ());
|
||||||
|
}
|
||||||
|
BOOL SetLocaleInfo (LCID code, LCTYPE type, const std::wstring &lcData)
|
||||||
|
{
|
||||||
|
return SetLocaleInfoW (code, type, lcData);
|
||||||
|
}
|
||||||
|
BOOL SetLocaleInfo (LCID code, LCTYPE type, const std::string &lcData)
|
||||||
|
{
|
||||||
|
return SetLocaleInfoA (code, type, lcData);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetLocaleRestrictedCodeFromLcidA (LCID lcid)
|
||||||
|
{
|
||||||
|
return GetLocaleInfoA (lcid, 89);
|
||||||
|
}
|
||||||
|
std::wstring GetLocaleRestrictedCodeFromLcidW (LCID lcid)
|
||||||
|
{
|
||||||
|
return GetLocaleInfoW (lcid, 89);
|
||||||
|
}
|
||||||
|
void GetLocaleRestrictedCodeFromLcid (LCID lcid, std::string &ret)
|
||||||
|
{
|
||||||
|
ret = GetLocaleRestrictedCodeFromLcidA (lcid);
|
||||||
|
}
|
||||||
|
void GetLocaleRestrictedCodeFromLcid (LCID lcid, std::wstring &ret)
|
||||||
|
{
|
||||||
|
ret = GetLocaleRestrictedCodeFromLcidW (lcid);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetLocaleElaboratedCodeFromLcidA (LCID lcid)
|
||||||
|
{
|
||||||
|
return GetLocaleInfoA (lcid, 90);
|
||||||
|
}
|
||||||
|
std::wstring GetLocaleElaboratedCodeFromLcidW (LCID lcid)
|
||||||
|
{
|
||||||
|
return GetLocaleInfoW (lcid, 90);
|
||||||
|
}
|
||||||
|
void GetLocaleElaboratedCodeFromLcid (LCID lcid, std::wstring &ret)
|
||||||
|
{
|
||||||
|
ret = GetLocaleElaboratedCodeFromLcidW (lcid);
|
||||||
|
}
|
||||||
|
void GetLocaleElaboratedCodeFromLcid (LCID lcid, std::string &ret)
|
||||||
|
{
|
||||||
|
ret = GetLocaleElaboratedCodeFromLcidA (lcid);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 ());
|
||||||
|
}
|
||||||
|
LCID LocaleCodeToLcid (const std::wstring &loccode)
|
||||||
|
{
|
||||||
|
return LocaleCodeToLcidW (loccode.c_str ());
|
||||||
|
}
|
||||||
|
LCID LocaleCodeToLcid (const std::string &loccode)
|
||||||
|
{
|
||||||
|
return LocaleCodeToLcidA (loccode.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::wstring GetLocaleRestrictedCode (const std::wstring &lc) { return GetLocaleRestrictedCodeW (lc); }
|
||||||
|
std::string GetLocaleRestrictedCode (const std::string &lc) { return GetLocaleRestrictedCodeA (lc); }
|
||||||
|
|
||||||
|
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::wstring GetLocaleElaboratedCode (const std::wstring &lc) { return GetLocaleElaboratedCodeW (lc); }
|
||||||
|
std::string GetLocaleElaboratedCode (const std::string &lc) { return GetLocaleElaboratedCodeA (lc); }
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
std::wstring LcidToLocaleCode (LCID lcid, WCHAR divide = L'-') { return LcidToLocaleCodeW (lcid, divide); }
|
||||||
|
std::string LcidToLocaleCode (LCID lcid, char divide = '-') { return LcidToLocaleCodeA (lcid, divide); }
|
||||||
419
pkgread/norstr.h
Normal file
419
pkgread/norstr.h
Normal file
@@ -0,0 +1,419 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include <locale>
|
||||||
|
#include <cctype>
|
||||||
|
namespace l0km
|
||||||
|
{
|
||||||
|
template <typename E, typename TR = std::char_traits <E>, typename AL = std::allocator <E>> inline std::basic_string<E, TR, AL> toupper (const std::basic_string <E, TR, AL> &src)
|
||||||
|
{
|
||||||
|
std::basic_string <E, TR, AL> dst = src;
|
||||||
|
static const std::locale loc;
|
||||||
|
const std::ctype <E> &ctype = std::use_facet <std::ctype <E>> (loc);
|
||||||
|
for (typename std::basic_string <E, TR, AL>::size_type i = 0; i < src.size (); ++ i)
|
||||||
|
{
|
||||||
|
dst [i] = ctype.toupper (src [i]);
|
||||||
|
}
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
template <typename E, typename TR = std::char_traits <E>, typename AL = std::allocator <E>> inline std::basic_string <E, TR, AL> tolower (const std::basic_string <E, TR, AL> &src)
|
||||||
|
{
|
||||||
|
std::basic_string <E, TR, AL> dst = src;
|
||||||
|
static const std::locale loc;
|
||||||
|
const std::ctype <E> &ctype = std::use_facet <std::ctype <E>> (loc);
|
||||||
|
for (typename std::basic_string <E, TR, AL>::size_type i = 0; i < src.size (); ++ i)
|
||||||
|
{
|
||||||
|
dst [i] = ctype.tolower (src [i]);
|
||||||
|
}
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
inline char toupper (char ch)
|
||||||
|
{
|
||||||
|
static const std::locale loc;
|
||||||
|
return std::use_facet <std::ctype <char>> (loc).toupper (ch);
|
||||||
|
}
|
||||||
|
inline char tolower (char ch)
|
||||||
|
{
|
||||||
|
static const std::locale loc;
|
||||||
|
return std::use_facet <std::ctype <char>> (loc).tolower (ch);
|
||||||
|
}
|
||||||
|
inline wchar_t toupper (wchar_t ch)
|
||||||
|
{
|
||||||
|
static const std::locale loc;
|
||||||
|
return std::use_facet <std::ctype <wchar_t>> (loc).toupper (ch);
|
||||||
|
}
|
||||||
|
inline wchar_t tolower (wchar_t ch)
|
||||||
|
{
|
||||||
|
static const std::locale loc;
|
||||||
|
return std::use_facet <std::ctype <wchar_t>> (loc).tolower (ch);
|
||||||
|
}
|
||||||
|
inline int toupper (int ch)
|
||||||
|
{
|
||||||
|
static const std::locale loc;
|
||||||
|
return std::use_facet <std::ctype <int>> (loc).toupper (ch);
|
||||||
|
}
|
||||||
|
inline int tolower (int ch)
|
||||||
|
{
|
||||||
|
static const std::locale loc;
|
||||||
|
return std::use_facet <std::ctype <int>> (loc).tolower (ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
template <typename ct> bool is_blank (ct &ch)
|
||||||
|
{
|
||||||
|
return ch == ct (' ') || ch == ct ('\t') || ch == ct ('\n');
|
||||||
|
}
|
||||||
|
template <typename E, typename TR = std::char_traits <E>, typename AL = std::allocator <E>> std::basic_string <E, TR, AL> NormalizeString (const std::basic_string <E, TR, AL> &str, bool upper = false, bool includemidblank = false)
|
||||||
|
{
|
||||||
|
typedef std::basic_string <E, TR, AL> string_type;
|
||||||
|
string_type result;
|
||||||
|
if (str.empty ()) return result;
|
||||||
|
auto begin_it = str.begin ();
|
||||||
|
auto end_it = str.end ();
|
||||||
|
while (begin_it != end_it && is_blank (*begin_it)) ++begin_it;
|
||||||
|
while (end_it != begin_it && is_blank (*(end_it - 1))) --end_it;
|
||||||
|
bool in_space = false;
|
||||||
|
for (auto it = begin_it; it != end_it; ++ it)
|
||||||
|
{
|
||||||
|
if (is_blank (*it))
|
||||||
|
{
|
||||||
|
if (includemidblank)
|
||||||
|
{
|
||||||
|
if (!in_space)
|
||||||
|
{
|
||||||
|
result.push_back (E (' '));
|
||||||
|
in_space = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.push_back (*it);
|
||||||
|
in_space = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.push_back (*it);
|
||||||
|
in_space = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (upper) return l0km::toupper (result);
|
||||||
|
else return l0km::tolower (result);
|
||||||
|
}
|
||||||
|
template <typename E, typename TR = std::char_traits <E>, typename AL = std::allocator <E>> bool IsNormalizeStringEquals (const std::basic_string <E, TR, AL> &l, const std::basic_string <E, TR, AL> &r, bool includemidblank = false)
|
||||||
|
{
|
||||||
|
auto skip_blank = [&] (auto &it, auto &end)
|
||||||
|
{
|
||||||
|
while (it != end && is_blank (*it)) ++ it;
|
||||||
|
};
|
||||||
|
auto it_l = l.begin (), it_r = r.begin ();
|
||||||
|
auto end_l = l.end (), end_r = r.end ();
|
||||||
|
skip_blank (it_l, end_l);
|
||||||
|
skip_blank (it_r, end_r);
|
||||||
|
while (it_l != end_l && it_r != end_r)
|
||||||
|
{
|
||||||
|
E ch_l = *it_l;
|
||||||
|
E ch_r = *it_r;
|
||||||
|
ch_l = l0km::tolower (ch_l);
|
||||||
|
ch_r = l0km::tolower (ch_r);
|
||||||
|
if (ch_l != ch_r) return false;
|
||||||
|
++ it_l;
|
||||||
|
++ it_r;
|
||||||
|
if (includemidblank)
|
||||||
|
{
|
||||||
|
if (is_blank (ch_l))
|
||||||
|
{
|
||||||
|
skip_blank (it_l, end_l);
|
||||||
|
skip_blank (it_r, end_r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
skip_blank (it_l, end_l);
|
||||||
|
skip_blank (it_r, end_r);
|
||||||
|
return it_l == end_l && it_r == end_r;
|
||||||
|
}
|
||||||
|
template <typename E, typename TR = std::char_traits <E>, typename AL = std::allocator <E>> int64_t NormalizeStringCompare (const std::basic_string <E, TR, AL> &l, const std::basic_string <E, TR, AL> &r, bool includemidblank = false)
|
||||||
|
{
|
||||||
|
auto skip_blank = [&] (auto &it, auto &end)
|
||||||
|
{
|
||||||
|
while (it != end && is_blank (*it)) ++ it;
|
||||||
|
};
|
||||||
|
auto it_l = l.begin (), it_r = r.begin ();
|
||||||
|
auto end_l = l.end (), end_r = r.end ();
|
||||||
|
skip_blank (it_l, end_l);
|
||||||
|
skip_blank (it_r, end_r);
|
||||||
|
while (it_l != end_l && it_r != end_r)
|
||||||
|
{
|
||||||
|
E ch_l = l0km::tolower (*it_l);
|
||||||
|
E ch_r = l0km::tolower (*it_r);
|
||||||
|
if (ch_l != ch_r) return ch_l < ch_r ? -1 : 1;
|
||||||
|
++ it_l;
|
||||||
|
++ it_r;
|
||||||
|
if (includemidblank)
|
||||||
|
{
|
||||||
|
if (is_blank (*it_l) || is_blank (*it_r))
|
||||||
|
{
|
||||||
|
skip_blank (it_l, end_l);
|
||||||
|
skip_blank (it_r, end_r);
|
||||||
|
if (it_l != end_l && it_r != end_r)
|
||||||
|
{
|
||||||
|
ch_l = l0km::tolower (*it_l);
|
||||||
|
ch_r = l0km::tolower (*it_r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
skip_blank (it_l, end_l);
|
||||||
|
skip_blank (it_r, end_r);
|
||||||
|
if (it_l == end_l && it_r == end_r) return 0;
|
||||||
|
if (it_l == end_l) return -1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
template <typename CharT> bool IsNormalizeStringEquals (const CharT *l, const CharT *r, bool includemidblank = false)
|
||||||
|
{
|
||||||
|
if (!l || !r) return l == r;
|
||||||
|
auto skip_blank = [] (const CharT *&p)
|
||||||
|
{
|
||||||
|
while (*p && is_blank (*p)) ++ p;
|
||||||
|
};
|
||||||
|
const CharT *p1 = l;
|
||||||
|
const CharT *p2 = r;
|
||||||
|
skip_blank (p1);
|
||||||
|
skip_blank (p2);
|
||||||
|
while (*p1 && *p2)
|
||||||
|
{
|
||||||
|
CharT ch1 = l0km::tolower (*p1);
|
||||||
|
CharT ch2 = l0km::tolower (*p2);
|
||||||
|
if (ch1 != ch2) return false;
|
||||||
|
++ p1;
|
||||||
|
++ p2;
|
||||||
|
if (includemidblank)
|
||||||
|
{
|
||||||
|
if (is_blank (*p1) || is_blank (*p2))
|
||||||
|
{
|
||||||
|
skip_blank (p1);
|
||||||
|
skip_blank (p2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
skip_blank (p1);
|
||||||
|
skip_blank (p2);
|
||||||
|
return *p1 == 0 && *p2 == 0;
|
||||||
|
}
|
||||||
|
template <typename CharT> int64_t NormalizeStringCompare (const CharT *l, const CharT *r, bool includemidblank = false)
|
||||||
|
{
|
||||||
|
if (!l || !r) return l ? 1 : (r ? -1 : 0);
|
||||||
|
auto skip_blank = [] (const CharT *&p)
|
||||||
|
{
|
||||||
|
while (*p && is_blank (*p)) ++ p;
|
||||||
|
};
|
||||||
|
const CharT *p1 = l;
|
||||||
|
const CharT *p2 = r;
|
||||||
|
skip_blank (p1);
|
||||||
|
skip_blank (p2);
|
||||||
|
while (*p1 && *p2)
|
||||||
|
{
|
||||||
|
CharT ch1 = l0km::tolower (*p1);
|
||||||
|
CharT ch2 = l0km::tolower (*p2);
|
||||||
|
if (ch1 != ch2) return (ch1 < ch2) ? -1 : 1;
|
||||||
|
++ p1;
|
||||||
|
++ p2;
|
||||||
|
if (includemidblank)
|
||||||
|
{
|
||||||
|
if (is_blank (*p1) || is_blank (*p2))
|
||||||
|
{
|
||||||
|
skip_blank (p1);
|
||||||
|
skip_blank (p2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
skip_blank (p1);
|
||||||
|
skip_blank (p2);
|
||||||
|
if (*p1 == 0 && *p2 == 0) return 0;
|
||||||
|
if (*p1 == 0) return -1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
template <typename E, typename TR = std::char_traits <E>, typename AL = std::allocator <E>> bool IsNormalizeStringEmpty (const std::basic_string <E, TR, AL> &str)
|
||||||
|
{
|
||||||
|
return IsNormalizeStringEquals (str, std::basic_string <E, TR, AL> ());
|
||||||
|
}
|
||||||
|
template <typename E, typename TR = std::char_traits <E>, typename AL = std::allocator <E>> std::basic_string <E, TR, AL> StringTrim (const std::basic_string <E, TR, AL> &str, bool includemidblank = false)
|
||||||
|
{
|
||||||
|
typedef std::basic_string <E, TR, AL> string_type;
|
||||||
|
typedef typename string_type::size_type size_type;
|
||||||
|
if (str.empty ()) return string_type ();
|
||||||
|
size_type first = 0;
|
||||||
|
size_type last = str.size ();
|
||||||
|
while (first < last && is_blank (str [first])) ++first;
|
||||||
|
while (last > first && is_blank (str [last - 1])) --last;
|
||||||
|
if (first == last) return string_type ();
|
||||||
|
string_type result;
|
||||||
|
result.reserve (last - first);
|
||||||
|
bool in_space = false;
|
||||||
|
for (size_type i = first; i < last; ++ i)
|
||||||
|
{
|
||||||
|
if (is_blank (str [i]))
|
||||||
|
{
|
||||||
|
if (includemidblank)
|
||||||
|
{
|
||||||
|
if (!in_space)
|
||||||
|
{
|
||||||
|
result.push_back (E (' '));
|
||||||
|
in_space = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.push_back (str [i]);
|
||||||
|
in_space = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.push_back (str [i]);
|
||||||
|
in_space = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
template <typename E, typename TR = std::char_traits<E>, typename AL = std::allocator <E>> size_t GetNormalizeStringLength (const std::basic_string <E, TR, AL> &str, bool includemidblank = false)
|
||||||
|
{
|
||||||
|
typedef typename std::basic_string <E, TR, AL>::size_type size_type;
|
||||||
|
if (str.empty ()) return 0;
|
||||||
|
size_type first = 0, last = str.size ();
|
||||||
|
while (first < last && is_blank (str [first])) ++first;
|
||||||
|
while (last > first && is_blank (str [last - 1])) --last;
|
||||||
|
if (first == last) return 0;
|
||||||
|
size_t length = 0;
|
||||||
|
bool in_space = false;
|
||||||
|
for (size_type i = first; i < last; ++i)
|
||||||
|
{
|
||||||
|
if (is_blank (str [i]))
|
||||||
|
{
|
||||||
|
if (includemidblank)
|
||||||
|
{
|
||||||
|
if (!in_space)
|
||||||
|
{
|
||||||
|
++ length;
|
||||||
|
in_space = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++ length;
|
||||||
|
in_space = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++ length;
|
||||||
|
in_space = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
|
||||||
|
template <typename ct, typename tr = std::char_traits <ct>, typename al = std::allocator <ct>> class basic_nstring: public std::basic_string <ct, tr, al>
|
||||||
|
{
|
||||||
|
using base = std::basic_string <ct, tr, al>;
|
||||||
|
bool default_upper = false, default_include_blank_in_str = false;
|
||||||
|
public:
|
||||||
|
using typename base::size_type;
|
||||||
|
using typename base::value_type;
|
||||||
|
using base::base;
|
||||||
|
basic_nstring (): base (), default_upper (false), default_include_blank_in_str (false) {}
|
||||||
|
basic_nstring (const ct *pStr): base (pStr), default_upper (false), default_include_blank_in_str (false) {}
|
||||||
|
basic_nstring (const base &str): base (str) {}
|
||||||
|
basic_nstring (base &&str): base (std::move (str)) {}
|
||||||
|
bool upper_default () const { return this->default_upper; }
|
||||||
|
bool upper_default (bool value) { return this->default_upper = value; }
|
||||||
|
bool include_blank_in_str_middle () const { return this->default_include_blank_in_str; }
|
||||||
|
bool include_blank_in_str_middle (bool value) { return this->default_include_blank_in_str = value; }
|
||||||
|
base normalize (bool upper, bool includemidblank) const
|
||||||
|
{
|
||||||
|
return NormalizeString <ct, tr, al> (*this, upper, includemidblank);
|
||||||
|
}
|
||||||
|
base normalize (bool upper) const
|
||||||
|
{
|
||||||
|
return this->normalize (upper, default_include_blank_in_str);
|
||||||
|
}
|
||||||
|
base normalize () const { return this->normalize (default_upper); }
|
||||||
|
base upper (bool includemidblank) const
|
||||||
|
{
|
||||||
|
return NormalizeString <ct, tr, al> (*this, true, includemidblank);
|
||||||
|
}
|
||||||
|
base upper () const { return this->upper (default_include_blank_in_str); }
|
||||||
|
base lower (bool includemidblank) const
|
||||||
|
{
|
||||||
|
return NormalizeString <ct, tr, al> (*this, false, includemidblank);
|
||||||
|
}
|
||||||
|
base lower () const { return this->lower (default_include_blank_in_str); }
|
||||||
|
base trim (bool includemidblank) const
|
||||||
|
{
|
||||||
|
return StringTrim <ct, tr, al> (*this, includemidblank);
|
||||||
|
}
|
||||||
|
base trim () const { return this->trim (default_include_blank_in_str); }
|
||||||
|
size_t length (bool includemidblank) const { return GetNormalizeStringLength (*this, includemidblank); }
|
||||||
|
size_t length () const { return length (default_include_blank_in_str); }
|
||||||
|
bool empty () const
|
||||||
|
{
|
||||||
|
return IsNormalizeStringEmpty (*this);
|
||||||
|
}
|
||||||
|
bool equals (const base &another, bool includemidblank) const
|
||||||
|
{
|
||||||
|
return IsNormalizeStringEquals <ct, tr, al> (*this, another, includemidblank);
|
||||||
|
}
|
||||||
|
bool equals (const base &another) const { return equals (another, default_include_blank_in_str); }
|
||||||
|
int64_t compare (const base &another, bool includemidblank) const
|
||||||
|
{
|
||||||
|
return NormalizeStringCompare <ct, tr, al> (*this, another, includemidblank);
|
||||||
|
}
|
||||||
|
int64_t compare (const base &another) const { return compare (another, default_include_blank_in_str); }
|
||||||
|
base &string () { return *this; }
|
||||||
|
base to_string (bool upper, bool includemidblank) const { return this->normalize (upper, includemidblank); }
|
||||||
|
base to_string (bool upper) const { return this->normalize (upper, default_include_blank_in_str); }
|
||||||
|
base to_string () const { return this->normalize (default_upper); }
|
||||||
|
bool operator == (const base &other) const { return equals (other, false); }
|
||||||
|
bool operator != (const base &other) const { return !equals (other, false); }
|
||||||
|
bool operator < (const base &other) const { return compare (other, false) < 0; }
|
||||||
|
bool operator > (const base &other) const { return compare (other, false) > 0; }
|
||||||
|
bool operator <= (const base &other) const { return compare (other, false) <= 0; }
|
||||||
|
bool operator >= (const base &other) const { return compare (other, false) >= 0; }
|
||||||
|
int64_t operator - (const base &other) const { return compare (other, false); }
|
||||||
|
template <typename E, typename TR = std::char_traits <E>, typename AL = std::allocator <E>>
|
||||||
|
static bool equals (const std::basic_string <E> &l, const std::basic_string <E> &r, bool remove_mid_blank = false)
|
||||||
|
{
|
||||||
|
return IsNormalizeStringEquals <E, TR, AL> (l, r, remove_mid_blank);
|
||||||
|
}
|
||||||
|
template <typename E, typename TR = std::char_traits <E>, typename AL = std::allocator <E>>
|
||||||
|
static int64_t compare (const std::basic_string <E> &l, const std::basic_string <E> &r, bool remove_mid_blank = false)
|
||||||
|
{
|
||||||
|
return NormalizeStringCompare <E, TR, AL> (l, r, remove_mid_blank);
|
||||||
|
}
|
||||||
|
template <typename E, typename TR = std::char_traits <E>, typename AL = std::allocator <E>>
|
||||||
|
static std::basic_string <E, TR, AL> normalize (const std::basic_string <E> &str, bool to_upper = false, bool remove_mid_blank = false)
|
||||||
|
{
|
||||||
|
return NormalizeString <E, TR, AL> (str, to_upper, remove_mid_blank);
|
||||||
|
}
|
||||||
|
template <typename E, typename TR = std::char_traits <E>, typename AL = std::allocator <E>>
|
||||||
|
static std::basic_string <E, TR, AL> trim (const std::basic_string <E> &str, bool remove_mid_blank = false)
|
||||||
|
{
|
||||||
|
return StringTrim <E, TR, AL> (str, remove_mid_blank);
|
||||||
|
}
|
||||||
|
template <typename E, typename TR = std::char_traits <E>, typename AL = std::allocator <E>>
|
||||||
|
static size_t length (const std::basic_string <E> &str, bool remove_mid_blank = false)
|
||||||
|
{
|
||||||
|
return GetNormalizeStringLength <E, TR, AL> (str, remove_mid_blank);
|
||||||
|
}
|
||||||
|
template <typename E, typename TR = std::char_traits <E>, typename AL = std::allocator <E>>
|
||||||
|
static bool empty (const std::basic_string <E> &str)
|
||||||
|
{
|
||||||
|
return IsNormalizeStringEmpty <E, TR, AL> (str);
|
||||||
|
}
|
||||||
|
template <typename E, typename TR = std::char_traits <E>, typename AL = std::allocator <E>>
|
||||||
|
static std::basic_nstring <E, TR, AL> to_nstring (std::basic_string <E> &str) { return std::basic_nstring <E> (str); }
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef basic_nstring <char> nstring;
|
||||||
|
typedef basic_nstring <wchar_t> wnstring;
|
||||||
|
}
|
||||||
4
pkgread/packages.config
Normal file
4
pkgread/packages.config
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="SQLite" version="3.12.2" targetFramework="native" />
|
||||||
|
</packages>
|
||||||
833
pkgread/pkgread.cpp
Normal file
833
pkgread/pkgread.cpp
Normal file
@@ -0,0 +1,833 @@
|
|||||||
|
// pkgread.cpp : 定义 DLL 应用程序的导出函数。
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "readobj.h"
|
||||||
|
#include "pkgread.h"
|
||||||
|
#include "localeex.h"
|
||||||
|
|
||||||
|
#define ToHandleRead(_cpp_ptr_) reinterpret_cast <HPKGREAD> (_cpp_ptr_)
|
||||||
|
#define ToPtrPackage(_cpp_ptr_) reinterpret_cast <package *> (_cpp_ptr_)
|
||||||
|
HPKGREAD CreatePackageReader () { return ToHandleRead (new package ()); }
|
||||||
|
BOOL LoadPackageFromFile (_In_ HPKGREAD hReader, _In_ LPCWSTR lpFilePath)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return false;
|
||||||
|
return ptr->create (lpFilePath);
|
||||||
|
}
|
||||||
|
void DestroyPackageReader (_In_ HPKGREAD hReader)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return;
|
||||||
|
return delete ptr;
|
||||||
|
}
|
||||||
|
WORD GetPackageType (_In_ HPKGREAD hReader)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return PKGTYPE_UNKNOWN;
|
||||||
|
switch (ptr->type ())
|
||||||
|
{
|
||||||
|
case PackageType::unknown: return PKGTYPE_UNKNOWN;
|
||||||
|
case PackageType::single: return PKGTYPE_APPX;
|
||||||
|
case PackageType::bundle: return PKGTYPE_BUNDLE;
|
||||||
|
}
|
||||||
|
return PKGTYPE_UNKNOWN;
|
||||||
|
}
|
||||||
|
BOOL IsPackageValid (_In_ HPKGREAD hReader)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return false;
|
||||||
|
return ptr->valid ();
|
||||||
|
}
|
||||||
|
WORD GetPackageRole (_In_ HPKGREAD hReader)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return PKGROLE_UNKNOWN;
|
||||||
|
switch (ptr->type ())
|
||||||
|
{
|
||||||
|
case PackageType::unknown: return PKGROLE_UNKNOWN;
|
||||||
|
case PackageType::bundle: return PKGROLE_APPLICATION;
|
||||||
|
case PackageType::single: {
|
||||||
|
auto ar = ptr->appx_reader ();
|
||||||
|
switch (ar.package_role ())
|
||||||
|
{
|
||||||
|
case PackageRole::unknown: return PKGROLE_UNKNOWN;
|
||||||
|
case PackageRole::application: return PKGROLE_APPLICATION;
|
||||||
|
case PackageRole::framework: return PKGROLE_FRAMEWORK;
|
||||||
|
case PackageRole::resource: return PKGROLE_RESOURCE;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
return PKGROLE_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Identity
|
||||||
|
VERSION VersionClassToStruct (const version &v)
|
||||||
|
{
|
||||||
|
VERSION sv;
|
||||||
|
sv.major = v.major;
|
||||||
|
sv.minor = v.minor;
|
||||||
|
sv.build = v.build;
|
||||||
|
sv.revision = v.revision;
|
||||||
|
return sv;
|
||||||
|
}
|
||||||
|
LPWSTR GetPackageIdentityStringValue (_In_ HPKGREAD hReader, _In_ DWORD dwName)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return nullptr;
|
||||||
|
switch (ptr->type ())
|
||||||
|
{
|
||||||
|
case PackageType::single: {
|
||||||
|
auto reader = ptr->appx_reader ();
|
||||||
|
auto id = reader.identity ();
|
||||||
|
switch (LOWORD (dwName))
|
||||||
|
{
|
||||||
|
case PKG_IDENTITY_NAME: return _wcsdup (id.name ().c_str ());
|
||||||
|
case PKG_IDENTITY_PUBLISHER: return _wcsdup (id.publisher ().c_str ());
|
||||||
|
case PKG_IDENTITY_PACKAGEFAMILYNAME: return _wcsdup (id.package_family_name ().c_str ());
|
||||||
|
case PKG_IDENTITY_PACKAGEFULLNAME: return _wcsdup (id.package_full_name ().c_str ());
|
||||||
|
case PKG_IDENTITY_RESOURCEID: return _wcsdup (id.resource_id ().c_str ());
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case PackageType::bundle: {
|
||||||
|
auto reader = ptr->bundle_reader ();
|
||||||
|
auto id = reader.identity ();
|
||||||
|
if (HIWORD (dwName) == PKGTYPE_BUNDLE)
|
||||||
|
{
|
||||||
|
CComPtr <IAppxPackageReader> apkg;
|
||||||
|
HRESULT hr = reader.random_application_package (&apkg);
|
||||||
|
if (SUCCEEDED (hr))
|
||||||
|
{
|
||||||
|
appxreader aread (apkg.p);
|
||||||
|
auto aid = aread.identity ();
|
||||||
|
switch (LOWORD (dwName))
|
||||||
|
{
|
||||||
|
case PKG_IDENTITY_NAME: return _wcsdup (aid.name ().c_str ());
|
||||||
|
case PKG_IDENTITY_PUBLISHER: return _wcsdup (aid.publisher ().c_str ());
|
||||||
|
case PKG_IDENTITY_PACKAGEFAMILYNAME: return _wcsdup (aid.package_family_name ().c_str ());
|
||||||
|
case PKG_IDENTITY_PACKAGEFULLNAME: return _wcsdup (aid.package_full_name ().c_str ());
|
||||||
|
case PKG_IDENTITY_RESOURCEID: return _wcsdup (aid.resource_id ().c_str ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (LOWORD (dwName))
|
||||||
|
{
|
||||||
|
case PKG_IDENTITY_NAME: return _wcsdup (id.name ().c_str ());
|
||||||
|
case PKG_IDENTITY_PUBLISHER: return _wcsdup (id.publisher ().c_str ());
|
||||||
|
case PKG_IDENTITY_PACKAGEFAMILYNAME: return _wcsdup (id.package_family_name ().c_str ());
|
||||||
|
case PKG_IDENTITY_PACKAGEFULLNAME: return _wcsdup (id.package_full_name ().c_str ());
|
||||||
|
case PKG_IDENTITY_RESOURCEID: return _wcsdup (id.resource_id ().c_str ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
BOOL GetPackageIdentityVersion (_In_ HPKGREAD hReader, _Out_ VERSION *pVersion, _In_ BOOL bGetSubPkgVer)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return FALSE;
|
||||||
|
if (!pVersion) return FALSE;
|
||||||
|
switch (ptr->type ())
|
||||||
|
{
|
||||||
|
case PackageType::single: {
|
||||||
|
auto reader = ptr->appx_reader ();
|
||||||
|
auto id = reader.identity ();
|
||||||
|
auto ver = id.version ();
|
||||||
|
*pVersion = VersionClassToStruct (ver);
|
||||||
|
return !ver.empty ();
|
||||||
|
} break;
|
||||||
|
case PackageType::bundle: {
|
||||||
|
auto reader = ptr->bundle_reader ();
|
||||||
|
auto id = reader.identity ();
|
||||||
|
if (bGetSubPkgVer)
|
||||||
|
{
|
||||||
|
CComPtr <IAppxPackageReader> apkg;
|
||||||
|
HRESULT hr = reader.random_application_package (&apkg);
|
||||||
|
if (SUCCEEDED (hr))
|
||||||
|
{
|
||||||
|
appxreader aread (apkg.p);
|
||||||
|
auto aid = aread.identity ();
|
||||||
|
auto ver = aid.version ();
|
||||||
|
*pVersion = VersionClassToStruct (ver);
|
||||||
|
return !ver.empty ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ver = id.version ();
|
||||||
|
*pVersion = VersionClassToStruct (ver);
|
||||||
|
return !ver.empty ();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
BOOL GetPackageIdentityArchitecture (_In_ HPKGREAD hReader, _Out_ DWORD *pdwArchi)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return FALSE;
|
||||||
|
if (!pdwArchi) return FALSE;
|
||||||
|
switch (ptr->type ())
|
||||||
|
{
|
||||||
|
case PackageType::single: {
|
||||||
|
auto reader = ptr->appx_reader ();
|
||||||
|
auto id = reader.identity ();
|
||||||
|
auto archi = id.architecture ();
|
||||||
|
DWORD ret = 0;
|
||||||
|
switch (archi)
|
||||||
|
{
|
||||||
|
case APPX_PACKAGE_ARCHITECTURE::APPX_PACKAGE_ARCHITECTURE_X86:
|
||||||
|
ret = PKG_ARCHITECTURE_X86; break;
|
||||||
|
case APPX_PACKAGE_ARCHITECTURE::APPX_PACKAGE_ARCHITECTURE_ARM:
|
||||||
|
ret = PKG_ARCHITECTURE_ARM; break;
|
||||||
|
case APPX_PACKAGE_ARCHITECTURE::APPX_PACKAGE_ARCHITECTURE_X64:
|
||||||
|
ret = PKG_ARCHITECTURE_X64; break;
|
||||||
|
case APPX_PACKAGE_ARCHITECTURE::APPX_PACKAGE_ARCHITECTURE_NEUTRAL:
|
||||||
|
ret = PKG_ARCHITECTURE_NEUTRAL; break;
|
||||||
|
case (APPX_PACKAGE_ARCHITECTURE)12: // ARM64
|
||||||
|
ret = PKG_ARCHITECTURE_ARM64; break;
|
||||||
|
}
|
||||||
|
*pdwArchi = ret;
|
||||||
|
return ret != PKG_ARCHITECTURE_UNKNOWN;
|
||||||
|
} break;
|
||||||
|
case PackageType::bundle: {
|
||||||
|
auto reader = ptr->bundle_reader ();
|
||||||
|
DWORD ret = 0;
|
||||||
|
size_t size = reader.application_packages ([&ret] (IAppxPackageReader *p) {
|
||||||
|
appxreader aread (p);
|
||||||
|
auto id = aread.identity ();
|
||||||
|
auto archi = id.architecture ();
|
||||||
|
switch (archi)
|
||||||
|
{
|
||||||
|
case APPX_PACKAGE_ARCHITECTURE::APPX_PACKAGE_ARCHITECTURE_X86:
|
||||||
|
ret |= PKG_ARCHITECTURE_X86; break;
|
||||||
|
case APPX_PACKAGE_ARCHITECTURE::APPX_PACKAGE_ARCHITECTURE_ARM:
|
||||||
|
ret |= PKG_ARCHITECTURE_ARM; break;
|
||||||
|
case APPX_PACKAGE_ARCHITECTURE::APPX_PACKAGE_ARCHITECTURE_X64:
|
||||||
|
ret |= PKG_ARCHITECTURE_X64; break;
|
||||||
|
case APPX_PACKAGE_ARCHITECTURE::APPX_PACKAGE_ARCHITECTURE_NEUTRAL:
|
||||||
|
ret |= PKG_ARCHITECTURE_NEUTRAL; break;
|
||||||
|
case (APPX_PACKAGE_ARCHITECTURE)12: // ARM64
|
||||||
|
ret |= PKG_ARCHITECTURE_ARM64; break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
*pdwArchi = ret;
|
||||||
|
return ret != PKG_ARCHITECTURE_UNKNOWN;
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
LPWSTR GetPackagePropertiesStringValue (_In_ HPKGREAD hReader, _In_ LPCWSTR lpName)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return nullptr;
|
||||||
|
switch (ptr->type ())
|
||||||
|
{
|
||||||
|
case PackageType::single: {
|
||||||
|
auto reader = ptr->appx_reader ();
|
||||||
|
auto prop = reader.properties ();
|
||||||
|
return _wcsdup (prop.string_value (lpName ? lpName : L"").c_str ());
|
||||||
|
} break;
|
||||||
|
case PackageType::bundle: {
|
||||||
|
auto reader = ptr->bundle_reader ();
|
||||||
|
CComPtr <IAppxPackageReader> apppkg;
|
||||||
|
if (SUCCEEDED (reader.random_application_package (&apppkg)))
|
||||||
|
{
|
||||||
|
appxreader apkg (apppkg.p);
|
||||||
|
auto prop = apkg.properties ();
|
||||||
|
return _wcsdup (prop.string_value (lpName ? lpName : L"").c_str ());
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
HRESULT GetPackagePropertiesBoolValue (_In_ HPKGREAD hReader, _In_ LPCWSTR lpName, _Outptr_ BOOL *pRet)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return E_INVALIDARG;
|
||||||
|
if (!pRet) return E_INVALIDARG;
|
||||||
|
*pRet = FALSE;
|
||||||
|
switch (ptr->type ())
|
||||||
|
{
|
||||||
|
case PackageType::single: {
|
||||||
|
auto reader = ptr->appx_reader ();
|
||||||
|
CComPtr <IAppxManifestReader> m;
|
||||||
|
HRESULT hr = reader.manifest (&m);
|
||||||
|
if (FAILED (hr)) return hr;
|
||||||
|
CComPtr <IAppxManifestProperties> p;
|
||||||
|
hr = m->GetProperties (&p);
|
||||||
|
if (FAILED (hr)) return hr;
|
||||||
|
return p->GetBoolValue (lpName, pRet);
|
||||||
|
} break;
|
||||||
|
case PackageType::bundle: {
|
||||||
|
auto reader = ptr->bundle_reader ();
|
||||||
|
CComPtr <IAppxPackageReader> apppkg;
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
if (SUCCEEDED (hr = reader.random_application_package (&apppkg)))
|
||||||
|
{
|
||||||
|
appxreader apkg (apppkg.p);
|
||||||
|
CComPtr <IAppxManifestReader> m;
|
||||||
|
hr = apkg.manifest (&m);
|
||||||
|
if (FAILED (hr)) return hr;
|
||||||
|
CComPtr <IAppxManifestProperties> p;
|
||||||
|
hr = m->GetProperties (&p);
|
||||||
|
if (FAILED (hr)) return hr;
|
||||||
|
return p->GetBoolValue (lpName, pRet);
|
||||||
|
}
|
||||||
|
else return hr;
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Applications
|
||||||
|
BOOL AddPackageApplicationItemGetName (_In_ LPCWSTR lpName)
|
||||||
|
{
|
||||||
|
if (std::wnstring (lpName ? lpName : L"").empty ()) return FALSE;
|
||||||
|
return PushApplicationAttributeItem (lpName);
|
||||||
|
}
|
||||||
|
BOOL RemovePackageApplicationItemGetName (_In_ LPCWSTR lpName)
|
||||||
|
{
|
||||||
|
if (std::wnstring (lpName ? lpName : L"").empty ()) return FALSE;
|
||||||
|
return RemoveApplicationAttributeItem (lpName);
|
||||||
|
}
|
||||||
|
HLIST_PVOID GetAllApplicationItemsName ()
|
||||||
|
{
|
||||||
|
size_t len = sizeof (LIST_PVOID) + sizeof (LPCWSTR) * appitems.size ();
|
||||||
|
HLIST_PVOID hList = (HLIST_PVOID)malloc (len);
|
||||||
|
ZeroMemory (hList, len);
|
||||||
|
hList->dwSize = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (auto &it : appitems)
|
||||||
|
{
|
||||||
|
((LPCWSTR *)hList->alpVoid) [hList->dwSize ++] = (LPCWSTR)it.c_str ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception &e) {}
|
||||||
|
return hList;
|
||||||
|
}
|
||||||
|
void DestroyApplicationItemsName (_In_ HLIST_PVOID hList)
|
||||||
|
{
|
||||||
|
if (!hList) return;
|
||||||
|
free (hList);
|
||||||
|
}
|
||||||
|
#define ToHandleAppEnumerator(_cpp_ptr_) reinterpret_cast <HAPPENUMERATOR> (_cpp_ptr_)
|
||||||
|
typedef std::vector <app_info> app_enumerator;
|
||||||
|
#define ToPtrAppxApps(_cpp_ptr_) reinterpret_cast <app_enumerator *> (_cpp_ptr_)
|
||||||
|
HAPPENUMERATOR GetPackageApplications (_In_ HPKGREAD hReader)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return nullptr;
|
||||||
|
switch (ptr->type ())
|
||||||
|
{
|
||||||
|
case PackageType::single: {
|
||||||
|
auto reader = ptr->appx_reader ();
|
||||||
|
auto app = reader.applications ();
|
||||||
|
auto appvec = new app_enumerator ();
|
||||||
|
app.applications (*appvec);
|
||||||
|
return ToHandleAppEnumerator (appvec);
|
||||||
|
} break;
|
||||||
|
case PackageType::bundle: {
|
||||||
|
auto br = ptr->bundle_reader ();
|
||||||
|
CComPtr <IAppxPackageReader> pr;
|
||||||
|
HRESULT hr = br.random_application_package (&pr);
|
||||||
|
if (SUCCEEDED (hr))
|
||||||
|
{
|
||||||
|
appxreader reader (pr.p);
|
||||||
|
auto app = reader.applications ();
|
||||||
|
auto appvec = new app_enumerator ();
|
||||||
|
app.applications (*appvec);
|
||||||
|
return ToHandleAppEnumerator (appvec);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
HLIST_PVOID ApplicationsToMap (_In_ HAPPENUMERATOR hEnumerator)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrAppxApps (hEnumerator);
|
||||||
|
if (!ptr || ptr->empty ()) return nullptr;
|
||||||
|
size_t count = ptr->size ();
|
||||||
|
size_t len = sizeof (LIST_PVOID) + sizeof (LPVOID) * count;
|
||||||
|
auto list = (HLIST_PVOID)malloc (len);
|
||||||
|
ZeroMemory (list, len);
|
||||||
|
if (!list) return nullptr;
|
||||||
|
list->dwSize = 0;
|
||||||
|
bool outer_throw = false;
|
||||||
|
raii list_guard ([&] () {
|
||||||
|
if (outer_throw)
|
||||||
|
{
|
||||||
|
for (DWORD i = 0; i < list->dwSize; ++i)
|
||||||
|
{
|
||||||
|
auto map = (HLIST_PVOID)list->alpVoid [i];
|
||||||
|
if (map)
|
||||||
|
{
|
||||||
|
for (DWORD j = 0; j < map->dwSize; ++j)
|
||||||
|
{
|
||||||
|
auto pair = (HPAIR_PVOID)map->alpVoid [j];
|
||||||
|
if (pair)
|
||||||
|
{
|
||||||
|
free (pair);
|
||||||
|
map->alpVoid [j] = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free (map);
|
||||||
|
list->alpVoid [i] = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free (list);
|
||||||
|
list = nullptr;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (auto &app : *ptr)
|
||||||
|
{
|
||||||
|
size_t map_size = app.size ();
|
||||||
|
size_t mlen = sizeof (LIST_PVOID) + sizeof (LPVOID) * map_size;
|
||||||
|
auto map = (HLIST_PVOID)malloc (mlen);
|
||||||
|
ZeroMemory (map, mlen);
|
||||||
|
if (!map)
|
||||||
|
{
|
||||||
|
outer_throw = true;
|
||||||
|
throw std::bad_alloc ();
|
||||||
|
}
|
||||||
|
map->dwSize = 0;
|
||||||
|
bool inner_throw = false;
|
||||||
|
raii map_guard ([&] () {
|
||||||
|
if (inner_throw)
|
||||||
|
{
|
||||||
|
for (DWORD j = 0; j < map->dwSize; ++j)
|
||||||
|
{
|
||||||
|
auto pair = (HPAIR_PVOID)map->alpVoid [j];
|
||||||
|
if (pair)
|
||||||
|
{
|
||||||
|
free (pair);
|
||||||
|
map->alpVoid [j] = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free (map);
|
||||||
|
map = nullptr;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (auto &kv : app)
|
||||||
|
{
|
||||||
|
auto pair = (HPAIR_PVOID)malloc (sizeof (PAIR_PVOID));
|
||||||
|
ZeroMemory (pair, sizeof (PAIR_PVOID));
|
||||||
|
if (!pair)
|
||||||
|
{
|
||||||
|
inner_throw = true;
|
||||||
|
throw std::bad_alloc ();
|
||||||
|
}
|
||||||
|
pair->lpKey = (LPVOID)kv.first.c_str ();
|
||||||
|
pair->lpValue = (LPVOID)kv.second.c_str ();
|
||||||
|
map->alpVoid [map->dwSize++] = pair;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception &)
|
||||||
|
{
|
||||||
|
inner_throw = true;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
list->alpVoid [list->dwSize ++] = map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception &) { outer_throw = true; }
|
||||||
|
if (outer_throw) return nullptr;
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
void DestroyApplicationsMap (_In_ HLIST_PVOID hEnumerator)
|
||||||
|
{
|
||||||
|
if (!hEnumerator) return;
|
||||||
|
HLIST_PVOID list = hEnumerator;
|
||||||
|
for (DWORD i = 0; i < list->dwSize; ++ i)
|
||||||
|
{
|
||||||
|
HLIST_PVOID map = (HLIST_PVOID)list->alpVoid [i];
|
||||||
|
if (!map) continue;
|
||||||
|
for (DWORD j = 0; j < map->dwSize; ++ j)
|
||||||
|
{
|
||||||
|
HPAIR_PVOID pair = (HPAIR_PVOID)map->alpVoid [j];
|
||||||
|
if (pair)
|
||||||
|
{
|
||||||
|
free (pair);
|
||||||
|
map->alpVoid [j] = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free (map);
|
||||||
|
list->alpVoid [i] = nullptr;
|
||||||
|
}
|
||||||
|
free (list);
|
||||||
|
}
|
||||||
|
void DestroyPackageApplications (_In_ HAPPENUMERATOR hEnumerator)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrAppxApps (hEnumerator);
|
||||||
|
if (ptr) delete ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resources
|
||||||
|
HLIST_PVOID GetResourcesLanguages (_In_ HPKGREAD hReader)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return nullptr;
|
||||||
|
std::vector <std::wnstring> langs;
|
||||||
|
switch (ptr->type ())
|
||||||
|
{
|
||||||
|
case PackageType::single:
|
||||||
|
{
|
||||||
|
auto reader = ptr->appx_reader ();
|
||||||
|
auto res = reader.resources ();
|
||||||
|
res.languages (langs);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case PackageType::bundle:
|
||||||
|
{
|
||||||
|
auto br = ptr->bundle_reader ();
|
||||||
|
auto res = br.package_id_items ();
|
||||||
|
res.enumerate ([&langs] (IAppxBundleManifestPackageInfo *inf) {
|
||||||
|
auto item = appx_info::appx_iditem (inf);
|
||||||
|
std::vector <std::wnstring> l;
|
||||||
|
auto qr = item.qualified_resources ();
|
||||||
|
qr.languages (l);
|
||||||
|
for (auto &it : l) push_unique <std::wnstring> (langs, it);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: return nullptr;
|
||||||
|
}
|
||||||
|
if (langs.empty ()) return nullptr;
|
||||||
|
size_t count = langs.size ();
|
||||||
|
size_t bytes = sizeof (LIST_PVOID) + sizeof (LPWSTR) * (count - 1);
|
||||||
|
auto list = (HLIST_PVOID)malloc (bytes);
|
||||||
|
ZeroMemory (list, bytes);
|
||||||
|
if (!list) return nullptr;
|
||||||
|
list->dwSize = 0;
|
||||||
|
for (auto &it : langs) list->alpVoid [list->dwSize ++] = _wcsdup (it.c_str ());
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
HLIST_LCID GetResourcesLanguagesToLcid (_In_ HPKGREAD hReader)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return nullptr;
|
||||||
|
std::vector <std::wnstring> langs;
|
||||||
|
switch (ptr->type ())
|
||||||
|
{
|
||||||
|
case PackageType::single:
|
||||||
|
{
|
||||||
|
auto reader = ptr->appx_reader ();
|
||||||
|
auto res = reader.resources ();
|
||||||
|
res.languages (langs);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case PackageType::bundle:
|
||||||
|
{
|
||||||
|
auto br = ptr->bundle_reader ();
|
||||||
|
auto res = br.package_id_items ();
|
||||||
|
res.enumerate ([&langs] (IAppxBundleManifestPackageInfo *inf) {
|
||||||
|
auto item = appx_info::appx_iditem (inf);
|
||||||
|
std::vector <std::wnstring> l;
|
||||||
|
auto qr = item.qualified_resources ();
|
||||||
|
qr.languages (l);
|
||||||
|
for (auto &it : l) push_unique <std::wnstring> (langs, it);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: return nullptr;
|
||||||
|
}
|
||||||
|
if (langs.empty ()) return nullptr;
|
||||||
|
size_t len = sizeof (LIST_LCID) + sizeof (LCID) * langs.size ();
|
||||||
|
HLIST_LCID hList = (HLIST_LCID)malloc (len);
|
||||||
|
ZeroMemory (hList, len);
|
||||||
|
hList->dwSize = 0;
|
||||||
|
for (auto &it : langs)
|
||||||
|
{
|
||||||
|
LCID lcid = LocaleCodeToLcid (it);
|
||||||
|
if (lcid)
|
||||||
|
{
|
||||||
|
hList->aLcid [hList->dwSize ++] = lcid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hList;
|
||||||
|
}
|
||||||
|
HLIST_UINT32 GetResourcesScales (_In_ HPKGREAD hReader)
|
||||||
|
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return nullptr;
|
||||||
|
std::vector <UINT32> scales;
|
||||||
|
switch (ptr->type ())
|
||||||
|
{
|
||||||
|
case PackageType::single:
|
||||||
|
{
|
||||||
|
auto reader = ptr->appx_reader ();
|
||||||
|
auto res = reader.resources ();
|
||||||
|
res.scales (scales);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case PackageType::bundle:
|
||||||
|
{
|
||||||
|
auto br = ptr->bundle_reader ();
|
||||||
|
auto res = br.package_id_items ();
|
||||||
|
res.enumerate ([&scales] (IAppxBundleManifestPackageInfo *inf) {
|
||||||
|
auto item = appx_info::appx_iditem (inf);
|
||||||
|
std::vector <UINT32> s;
|
||||||
|
auto qr = item.qualified_resources ();
|
||||||
|
qr.scales (s);
|
||||||
|
for (auto &it : s) push_unique (scales, it);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: return nullptr;
|
||||||
|
}
|
||||||
|
if (scales.empty ()) return nullptr;
|
||||||
|
size_t len = sizeof (LIST_UINT32) + sizeof (UINT32) * scales.size ();
|
||||||
|
HLIST_UINT32 hList = (HLIST_UINT32)malloc (len);
|
||||||
|
ZeroMemory (hList, len);
|
||||||
|
hList->dwSize = 0;
|
||||||
|
for (auto &it : scales)
|
||||||
|
{
|
||||||
|
if (!it) continue;
|
||||||
|
hList->aUI32 [hList->dwSize ++] = it;
|
||||||
|
}
|
||||||
|
return hList;
|
||||||
|
}
|
||||||
|
DWORD GetResourcesDxFeatureLevels (_In_ HPKGREAD hReader)
|
||||||
|
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return 0;
|
||||||
|
DWORD dwFlags = 0;
|
||||||
|
switch (ptr->type ())
|
||||||
|
{
|
||||||
|
case PackageType::single:
|
||||||
|
{
|
||||||
|
auto reader = ptr->appx_reader ();
|
||||||
|
auto res = reader.resources ();
|
||||||
|
std::vector <DX_FEATURE_LEVEL> dxlevels;
|
||||||
|
res.dx_feature_level (dxlevels);
|
||||||
|
for (auto &it : dxlevels)
|
||||||
|
{
|
||||||
|
switch (it)
|
||||||
|
{
|
||||||
|
case DX_FEATURE_LEVEL::DX_FEATURE_LEVEL_9:
|
||||||
|
dwFlags |= PKG_RESOURCES_DXFEATURE_LEVEL9; break;
|
||||||
|
case DX_FEATURE_LEVEL::DX_FEATURE_LEVEL_10:
|
||||||
|
dwFlags |= PKG_RESOURCES_DXFEATURE_LEVEL10; break;
|
||||||
|
case DX_FEATURE_LEVEL::DX_FEATURE_LEVEL_11:
|
||||||
|
dwFlags |= PKG_RESOURCES_DXFEATURE_LEVEL11; break;
|
||||||
|
case (DX_FEATURE_LEVEL)4:
|
||||||
|
dwFlags |= PKG_RESOURCES_DXFEATURE_LEVEL12; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case PackageType::bundle:
|
||||||
|
{
|
||||||
|
auto br = ptr->bundle_reader ();
|
||||||
|
auto res = br.package_id_items ();
|
||||||
|
res.enumerate ([&dwFlags] (IAppxBundleManifestPackageInfo *inf) {
|
||||||
|
auto item = appx_info::appx_iditem (inf);
|
||||||
|
std::vector <DX_FEATURE_LEVEL> dxlevels;
|
||||||
|
auto qr = item.qualified_resources ();
|
||||||
|
qr.dx_feature_level (dxlevels);
|
||||||
|
for (auto &it : dxlevels)
|
||||||
|
{
|
||||||
|
switch (it)
|
||||||
|
{
|
||||||
|
case DX_FEATURE_LEVEL::DX_FEATURE_LEVEL_9:
|
||||||
|
dwFlags |= PKG_RESOURCES_DXFEATURE_LEVEL9; break;
|
||||||
|
case DX_FEATURE_LEVEL::DX_FEATURE_LEVEL_10:
|
||||||
|
dwFlags |= PKG_RESOURCES_DXFEATURE_LEVEL10; break;
|
||||||
|
case DX_FEATURE_LEVEL::DX_FEATURE_LEVEL_11:
|
||||||
|
dwFlags |= PKG_RESOURCES_DXFEATURE_LEVEL11; break;
|
||||||
|
case (DX_FEATURE_LEVEL)4:
|
||||||
|
dwFlags |= PKG_RESOURCES_DXFEATURE_LEVEL12; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: return 0;
|
||||||
|
}
|
||||||
|
return dwFlags;
|
||||||
|
}
|
||||||
|
void DestroyResourcesLanguagesList (_In_ HLIST_PVOID hList)
|
||||||
|
{
|
||||||
|
if (!hList) return;
|
||||||
|
for (DWORD i = 0; i < hList->dwSize; i++)
|
||||||
|
{
|
||||||
|
if (hList->alpVoid [i])
|
||||||
|
{
|
||||||
|
free (hList->alpVoid [i]);
|
||||||
|
hList->alpVoid [i] = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free (hList);
|
||||||
|
}
|
||||||
|
void DestroyResourcesLanguagesLcidList (_In_ HLIST_LCID hList)
|
||||||
|
{
|
||||||
|
if (!hList) return;
|
||||||
|
free (hList);
|
||||||
|
}
|
||||||
|
void DestroyUInt32List (_In_ HLIST_UINT32 hList)
|
||||||
|
{
|
||||||
|
if (!hList) return;
|
||||||
|
free (hList);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dependencies
|
||||||
|
HLIST_DEPINFO GetDependencesInfoList (_In_ HPKGREAD hReader)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return nullptr;
|
||||||
|
std::vector <dep_info> vec;
|
||||||
|
switch (ptr->type ())
|
||||||
|
{
|
||||||
|
case PackageType::single: {
|
||||||
|
auto reader = ptr->appx_reader ();
|
||||||
|
auto deps = reader.dependencies ();
|
||||||
|
deps.dependencies (vec);
|
||||||
|
} break;
|
||||||
|
case PackageType::bundle: {
|
||||||
|
auto br = ptr->bundle_reader ();
|
||||||
|
CComPtr <IAppxPackageReader> pr;
|
||||||
|
HRESULT hr = br.random_application_package (&pr);
|
||||||
|
if (FAILED (hr)) return nullptr;
|
||||||
|
appxreader reader (pr.p);
|
||||||
|
auto deps = reader.dependencies ();
|
||||||
|
deps.dependencies (vec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size_t len = sizeof (LIST_DEPINFO) + sizeof (DEPENDENCY_INFO) * vec.size ();
|
||||||
|
HLIST_DEPINFO hList = (HLIST_DEPINFO)malloc (len);
|
||||||
|
ZeroMemory (hList, len);
|
||||||
|
hList->dwSize = 0;
|
||||||
|
for (auto &it : vec)
|
||||||
|
{
|
||||||
|
auto &dep = hList->aDepInfo [hList->dwSize ++];
|
||||||
|
dep.lpName = _wcsdup (it.name.c_str ());
|
||||||
|
dep.lpPublisher = _wcsdup (it.publisher.c_str ());
|
||||||
|
dep.verMin = VersionClassToStruct (it.minversion);
|
||||||
|
}
|
||||||
|
return hList;
|
||||||
|
}
|
||||||
|
void DestroyDependencesInfoList (_In_ HLIST_DEPINFO hList)
|
||||||
|
{
|
||||||
|
if (!hList) return;
|
||||||
|
for (DWORD i = 0; i < hList->dwSize; i ++)
|
||||||
|
{
|
||||||
|
auto &dep = hList->aDepInfo [i];
|
||||||
|
if (dep.lpName) { free (dep.lpName); dep.lpName = nullptr; }
|
||||||
|
if (dep.lpPublisher) { free (dep.lpPublisher); dep.lpPublisher = nullptr; }
|
||||||
|
}
|
||||||
|
free (hList);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Capabilities
|
||||||
|
HLIST_PVOID GetCapabilitiesList (_In_ HPKGREAD hReader)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return nullptr;
|
||||||
|
std::vector <std::wnstring> caps;
|
||||||
|
switch (ptr->type ())
|
||||||
|
{
|
||||||
|
case PackageType::single: {
|
||||||
|
auto reader = ptr->appx_reader ();
|
||||||
|
auto cap = reader.capabilities ();
|
||||||
|
std::vector <std::wstring> vec;
|
||||||
|
cap.capabilities_names (vec);
|
||||||
|
for (auto &it : vec)
|
||||||
|
{
|
||||||
|
auto cname = std::wnstring (it.c_str ());
|
||||||
|
if (cname.empty ()) continue;
|
||||||
|
push_unique (caps, cname);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case PackageType::bundle: {
|
||||||
|
auto br = ptr->bundle_reader ();
|
||||||
|
CComPtr <IAppxPackageReader> ar;
|
||||||
|
if (FAILED (br.random_application_package (&ar))) return nullptr;
|
||||||
|
appxreader reader (ar.p);
|
||||||
|
auto cap = reader.capabilities ();
|
||||||
|
std::vector <std::wstring> vec;
|
||||||
|
cap.capabilities_names (vec);
|
||||||
|
for (auto &it : vec)
|
||||||
|
{
|
||||||
|
auto cname = std::wnstring (it.c_str ());
|
||||||
|
if (cname.empty ()) continue;
|
||||||
|
push_unique (caps, cname);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
size_t len = sizeof (LIST_PVOID) * sizeof (LPWSTR) * caps.size ();
|
||||||
|
HLIST_PVOID hList = (HLIST_PVOID)malloc (len);
|
||||||
|
ZeroMemory (hList, len);
|
||||||
|
hList->dwSize = 0;
|
||||||
|
for (auto &it : caps)
|
||||||
|
{
|
||||||
|
hList->alpVoid [hList->dwSize ++] = (LPVOID)_wcsdup (it.c_str ());
|
||||||
|
}
|
||||||
|
return hList;
|
||||||
|
}
|
||||||
|
HLIST_PVOID GetDeviceCapabilitiesList (_In_ HPKGREAD hReader)
|
||||||
|
{
|
||||||
|
auto ptr = ToPtrPackage (hReader);
|
||||||
|
if (!ptr) return nullptr;
|
||||||
|
std::vector <std::wnstring> caps;
|
||||||
|
switch (ptr->type ())
|
||||||
|
{
|
||||||
|
case PackageType::single: {
|
||||||
|
auto reader = ptr->appx_reader ();
|
||||||
|
auto cap = reader.capabilities ();
|
||||||
|
std::vector <std::wstring> vec;
|
||||||
|
cap.device_capabilities (vec);
|
||||||
|
for (auto &it : vec)
|
||||||
|
{
|
||||||
|
auto cname = std::wnstring (it.c_str ());
|
||||||
|
if (cname.empty ()) continue;
|
||||||
|
push_unique (caps, cname);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case PackageType::bundle: {
|
||||||
|
auto br = ptr->bundle_reader ();
|
||||||
|
CComPtr <IAppxPackageReader> ar;
|
||||||
|
if (FAILED (br.random_application_package (&ar))) return nullptr;
|
||||||
|
appxreader reader (ar.p);
|
||||||
|
auto cap = reader.capabilities ();
|
||||||
|
std::vector <std::wstring> vec;
|
||||||
|
cap.device_capabilities (vec);
|
||||||
|
for (auto &it : vec)
|
||||||
|
{
|
||||||
|
auto cname = std::wnstring (it.c_str ());
|
||||||
|
if (cname.empty ()) continue;
|
||||||
|
push_unique (caps, cname);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
size_t len = sizeof (LIST_PVOID) * sizeof (LPWSTR) * caps.size ();
|
||||||
|
HLIST_PVOID hList = (HLIST_PVOID)malloc (len);
|
||||||
|
ZeroMemory (hList, len);
|
||||||
|
hList->dwSize = 0;
|
||||||
|
for (auto &it : caps)
|
||||||
|
{
|
||||||
|
hList->alpVoid [hList->dwSize ++] = (LPVOID)_wcsdup (it.c_str ());
|
||||||
|
}
|
||||||
|
return hList;
|
||||||
|
}
|
||||||
|
void DestroyWStringList (_In_ HLIST_PVOID hList)
|
||||||
|
{
|
||||||
|
if (!hList) return;
|
||||||
|
for (size_t cnt = 0; cnt < hList->dwSize; cnt ++)
|
||||||
|
{
|
||||||
|
free (hList->alpVoid [cnt]);
|
||||||
|
hList->alpVoid [cnt] = nullptr;
|
||||||
|
}
|
||||||
|
free (hList);
|
||||||
|
}
|
||||||
293
pkgread/pkgread.h
Normal file
293
pkgread/pkgread.h
Normal file
@@ -0,0 +1,293 @@
|
|||||||
|
// 下列 ifdef 块是创建使从 DLL 导出更简单的
|
||||||
|
// 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 PKGREAD_EXPORTS
|
||||||
|
// 符号编译的。在使用此 DLL 的
|
||||||
|
// 任何其他项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
|
||||||
|
// PKGREAD_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
|
||||||
|
// 符号视为是被导出的。
|
||||||
|
#ifndef _APPX_PACKAGE_READER_H_
|
||||||
|
#define _APPX_PACKAGE_READER_H_
|
||||||
|
#ifdef PKGREAD_EXPORTS
|
||||||
|
#define PKGREAD_API __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define PKGREAD_API __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define _DEFAULT_INIT_VALUE_(_init_value_) = _init_value_
|
||||||
|
#ifdef PKGREAD_EXPORTS
|
||||||
|
#define _DEFAULT_INIT_VALUE_FORFUNC_(_init_value_) = _init_value_
|
||||||
|
#else
|
||||||
|
#define _DEFAULT_INIT_VALUE_FORFUNC_(_init_value_)
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define _DEFAULT_INIT_VALUE_(_init_value_)
|
||||||
|
#define _DEFAULT_INIT_VALUE_FORFUNC_(_init_value_)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _TYPE_STRUCT_VERSION_
|
||||||
|
#define _TYPE_STRUCT_VERSION_
|
||||||
|
typedef struct _VERSION
|
||||||
|
{
|
||||||
|
#if defined (__cplusplus) && defined (PKGREAD_EXPORTS)
|
||||||
|
_VERSION (UINT16 major = 0, UINT16 minor = 0, UINT16 build = 0, UINT16 revision = 0):
|
||||||
|
major (major), minor (minor), build (build), revision (revision) {}
|
||||||
|
#endif
|
||||||
|
UINT16 major _DEFAULT_INIT_VALUE_ (0),
|
||||||
|
minor _DEFAULT_INIT_VALUE_ (0),
|
||||||
|
build _DEFAULT_INIT_VALUE_ (0),
|
||||||
|
revision _DEFAULT_INIT_VALUE_ (0);
|
||||||
|
} VERSION;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _TYPE_STRUCT_LIST_PVOID_
|
||||||
|
#define _TYPE_STRUCT_LIST_PVOID_
|
||||||
|
typedef struct _LIST_PVOID
|
||||||
|
{
|
||||||
|
DWORD dwSize _DEFAULT_INIT_VALUE_ (0);
|
||||||
|
LPVOID alpVoid [1] _DEFAULT_INIT_VALUE_ ({NULL});
|
||||||
|
} LIST_PVOID, *HLIST_PVOID;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _TYPE_STRUCT_PAIR_PVOID_
|
||||||
|
#define _TYPE_STRUCT_PAIR_PVOID_
|
||||||
|
typedef struct _PAIR_PVOID_
|
||||||
|
{
|
||||||
|
LPVOID lpKey _DEFAULT_INIT_VALUE_ (NULL);
|
||||||
|
LPVOID lpValue _DEFAULT_INIT_VALUE_ (NULL);
|
||||||
|
} PAIR_PVOID, *HPAIR_PVOID;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TEMPLATE_STRUCT(_typename_) typedef struct _typename_##__ _typename_
|
||||||
|
TEMPLATE_STRUCT (PKGREADER);
|
||||||
|
typedef PKGREADER *HPKGREAD;
|
||||||
|
TEMPLATE_STRUCT (APPENUMERATOR);
|
||||||
|
typedef APPENUMERATOR *HAPPENUMERATOR;
|
||||||
|
|
||||||
|
#define PKGTYPE_UNKNOWN 0
|
||||||
|
#define PKGTYPE_APPX 1
|
||||||
|
#define PKGTYPE_BUNDLE 2
|
||||||
|
#define PKGROLE_UNKNOWN 0
|
||||||
|
#define PKGROLE_APPLICATION 1
|
||||||
|
#define PKGROLE_FRAMEWORK 2
|
||||||
|
#define PKGROLE_RESOURCE 3
|
||||||
|
// 创建包读取器
|
||||||
|
PKGREAD_API HPKGREAD CreatePackageReader ();
|
||||||
|
// 通过包读取器打开包
|
||||||
|
PKGREAD_API BOOL LoadPackageFromFile (_In_ HPKGREAD hReader, _In_ LPCWSTR lpFilePath);
|
||||||
|
// 销毁包读取器(必须)
|
||||||
|
PKGREAD_API void DestroyPackageReader (_In_ HPKGREAD hReader);
|
||||||
|
// 获取包的类型:Appx 包还是 AppxBundle 包。返回 PKGTYPE_* 宏
|
||||||
|
PKGREAD_API WORD GetPackageType (_In_ HPKGREAD hReader);
|
||||||
|
// 返回包是否有效。无效的包会返回假。
|
||||||
|
PKGREAD_API BOOL IsPackageValid (_In_ HPKGREAD hReader);
|
||||||
|
// 获取包的类型:是应用包、框架包还是资源包。
|
||||||
|
// 对于 AppxBundle 包永远返回是资源包(因为框架包无法打包成 AppxBundle,资源包必须与应用包一同打包进 AppxBundle)。
|
||||||
|
// 返回 PKGROLE_* 宏。
|
||||||
|
PKGREAD_API WORD GetPackageRole (_In_ HPKGREAD hReader);
|
||||||
|
|
||||||
|
// Identity
|
||||||
|
// 对于 AppxBundle 包来说,AppxBundle 包与储存的 Appx 的包的身份信息并不一致(不一致在版本号和处理器架构上)
|
||||||
|
#define PKG_IDENTITY_BUNDLE_GETAPPXINFO ((PKGTYPE_BUNDLE && 0xFFFF) << 16)
|
||||||
|
#define PKG_IDENTITY_NAME 0
|
||||||
|
#define PKG_IDENTITY_PUBLISHER 1
|
||||||
|
#define PKG_IDENTITY_PACKAGEFAMILYNAME 2
|
||||||
|
#define PKG_IDENTITY_PACKAGEFULLNAME 3
|
||||||
|
#define PKG_IDENTITY_RESOURCEID 4
|
||||||
|
#define PKG_ARCHITECTURE_UNKNOWN 0x0
|
||||||
|
#define PKG_ARCHITECTURE_X86 0x1
|
||||||
|
#define PKG_ARCHITECTURE_X64 0x2
|
||||||
|
#define PKG_ARCHITECTURE_ARM 0x4
|
||||||
|
#define PKG_ARCHITECTURE_ARM64 0x8
|
||||||
|
#define PKG_ARCHITECTURE_NEUTRAL 0xF
|
||||||
|
// 获取身份信息能获取文本值的项。支持 PKG_IDENTITY_* 前缀的宏 NAME, PUBLISHER, PACKAGEFAMILYNAME, PACKAGEFULLNAME, RESOURCEID。
|
||||||
|
// 当与 PKG_IDENTITY_BUNDLE_GETAPPXINFO 通过位或结合时,则获取 AppxBundle 中某一个应用包。
|
||||||
|
PKGREAD_API LPWSTR GetPackageIdentityStringValue (_In_ HPKGREAD hReader, _In_ DWORD dwName);
|
||||||
|
// 获取身份信息。当 bGetSubPkgVer 为真,且打开的包为 AppxBundle 包,返回 AppxBundle 包中的某个应用包的版本号。
|
||||||
|
PKGREAD_API BOOL GetPackageIdentityVersion (_In_ HPKGREAD hReader, _Out_ VERSION *pVersion, _In_ BOOL bGetSubPkgVer _DEFAULT_INIT_VALUE_FORFUNC_ (0));
|
||||||
|
// 对于 AppxBundle 包,当传入的值有 PKG_IDENTITY_BUNDLE_GETAPPXINFO,则返回一个按位值,如 0b0011,则意味着支持 x86 和 x64
|
||||||
|
PKGREAD_API BOOL GetPackageIdentityArchitecture (_In_ HPKGREAD hReader, _Out_ DWORD *pdwArchi);
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
// 获取字符串值
|
||||||
|
#define PKG_PROPERTIES_DISPLAYNAME L"DisplayName"
|
||||||
|
#define PKG_PROPERTIES_DESCRIPTION L"Description"
|
||||||
|
#define PKG_PROPERTIES_LOGO L"Logo"
|
||||||
|
#define PKG_PROPERTIES_PUBLISHER L"PublisherDisplayName"
|
||||||
|
// 获取逻辑型值
|
||||||
|
#define PKG_PROPERTIES_FRAMEWORD L"Framework"
|
||||||
|
#define PKG_PROPERTIES_IS_RESOURCE L"ResourcePackage"
|
||||||
|
// 传入参数参考:https://learn.microsoft.com/en-us/windows/win32/api/appxpackaging/nf-appxpackaging-iappxmanifestproperties-getstringvalue
|
||||||
|
// 可以使用宏 PKG_PROPERTIES_* 前缀的 DISPLAYNAME, DESCRIPTION, LOGO, PUBLISHER
|
||||||
|
PKGREAD_API LPWSTR GetPackagePropertiesStringValue (_In_ HPKGREAD hReader, _In_ LPCWSTR lpName);
|
||||||
|
// 传入参数参考:https://learn.microsoft.com/zh-cn/windows/win32/api/appxpackaging/nf-appxpackaging-iappxmanifestproperties-getboolvalue
|
||||||
|
// 可以使用宏 PKG_PROPERTIES_* 前缀的 FRAMEWORD, IS_RESOURCE (Windows 8.1 支持)
|
||||||
|
PKGREAD_API HRESULT GetPackagePropertiesBoolValue (_In_ HPKGREAD hReader, _In_ LPCWSTR lpName, _Outptr_ BOOL *pRet);
|
||||||
|
// Applications
|
||||||
|
// 注意:由于读取 Application 在官方 API 中是枚举类型,只能枚举一次。
|
||||||
|
// 所以请预先安排好需要的信息,并在枚举时进行缓存。
|
||||||
|
// 添加和删除的请参考这些:https://learn.microsoft.com/en-us/windows/win32/api/appxpackaging/nf-appxpackaging-iappxmanifestapplication-getstringvalue
|
||||||
|
// DLL 本身支持:Id, DisplayName, BackgroundColor, ForegroundText, ShortName, Square44x44Logo
|
||||||
|
PKGREAD_API BOOL AddPackageApplicationItemGetName (_In_ LPCWSTR lpName);
|
||||||
|
// 移除不需要的信息项名。
|
||||||
|
PKGREAD_API BOOL RemovePackageApplicationItemGetName (_In_ LPCWSTR lpName);
|
||||||
|
// 获取现在有的信息项名。读取时将指针数组的成员转换为 LPCWSTR 读取,且不能修改。
|
||||||
|
// 注意:返回的 HLIST_PVOID 要经过 DestroyApplicationItemsName 销毁。
|
||||||
|
PKGREAD_API HLIST_PVOID GetAllApplicationItemsName ();
|
||||||
|
// 通过 GetAllApplicationItemsName 获取的 HLIST_PVOID 由 DestroyApplicationItemsName 销毁。
|
||||||
|
PKGREAD_API void DestroyApplicationItemsName (_In_ HLIST_PVOID hList);
|
||||||
|
// 获取到 Application 信息枚举器。在自己缓存完信息前不要销毁,直到再也不需要后才销毁。
|
||||||
|
// 通过 GetPackageApplications 获取的 HAPPENUMERATOR 由 DestroyApplicationsMap 销毁
|
||||||
|
PKGREAD_API HAPPENUMERATOR GetPackageApplications (_In_ HPKGREAD hReader);
|
||||||
|
// 从 Application 枚举器转换成 HLIST_PVOID { HLIST_PVOID {HPAIR_PVOID} } (类似于多个映射组成的数组)。
|
||||||
|
// 读取最深层的指针成员转换为 LPCWSTR 读取。其 LPCWSTR 周期随着 HAPPENUMERATOR 的周期而决定。
|
||||||
|
PKGREAD_API HLIST_PVOID ApplicationsToMap (_In_ HAPPENUMERATOR hEnumerator);
|
||||||
|
// 通过 ApplicationsToMap 获取的 HLIST_PVOID 由 DestroyApplicationsMap 销毁
|
||||||
|
PKGREAD_API void DestroyApplicationsMap (_In_ HLIST_PVOID hEnumerator);
|
||||||
|
// 通过 GetPackageApplications 获取的 HAPPENUMERATOR 由 DestroyApplicationsMap 销毁
|
||||||
|
PKGREAD_API void DestroyPackageApplications (_In_ HAPPENUMERATOR hEnumerator);
|
||||||
|
|
||||||
|
// Resources
|
||||||
|
#ifndef _TYPE_STRUCT_LIST_LCID_
|
||||||
|
#define _TYPE_STRUCT_LIST_LCID_
|
||||||
|
typedef struct _LIST_LCID
|
||||||
|
{
|
||||||
|
DWORD dwSize _DEFAULT_INIT_VALUE_ (0);
|
||||||
|
LCID aLcid [1] _DEFAULT_INIT_VALUE_ ({0});
|
||||||
|
} LIST_LCID, *HLIST_LCID;
|
||||||
|
#endif
|
||||||
|
#ifndef _TYPE_STRUCT_LIST_UINT32_
|
||||||
|
#define _TYPE_STRUCT_LIST_UINT32_
|
||||||
|
typedef struct _LIST_UINT32
|
||||||
|
{
|
||||||
|
DWORD dwSize _DEFAULT_INIT_VALUE_ (0);
|
||||||
|
LCID aUI32 [1] _DEFAULT_INIT_VALUE_ ({0});
|
||||||
|
} LIST_UINT32, *HLIST_UINT32;
|
||||||
|
#endif
|
||||||
|
// 返回区域代码 (Locale Code) 数组。以 LPWSTR 读取。注:一定要通过 DestroyResourcesLanguagesList 释放
|
||||||
|
PKGREAD_API HLIST_PVOID GetResourcesLanguages (_In_ HPKGREAD hReader);
|
||||||
|
// 返回将区域代码转换成 LCID(如 en-US 为 1033,zh-CN 为 2052) 后的数组。以 UINT32 读取。
|
||||||
|
// 注:一定要通过 DestroyResourcesLanguagesLcidList 释放
|
||||||
|
PKGREAD_API HLIST_LCID GetResourcesLanguagesToLcid (_In_ HPKGREAD hReader);
|
||||||
|
// 返回 DPI 支持(如 100,125) 的数组。
|
||||||
|
// 注:一定要通过 DestroyResourcesScalesList 宏(或 DestroyUInt32List 函数)释放
|
||||||
|
PKGREAD_API HLIST_UINT32 GetResourcesScales (_In_ HPKGREAD hReader);
|
||||||
|
#define PKG_RESOURCES_DXFEATURE_LEVEL9 0x1
|
||||||
|
#define PKG_RESOURCES_DXFEATURE_LEVEL10 0x2
|
||||||
|
#define PKG_RESOURCES_DXFEATURE_LEVEL11 0x4
|
||||||
|
#define PKG_RESOURCES_DXFEATURE_LEVEL12 0x8
|
||||||
|
#define PKG_RESOURCES_DXFEATURE_UNSPECIFIED 0
|
||||||
|
// 返回一个 DWORD 值。通过按位与来获取支持的 DirectX 功能支持。如果等于 0 则意味着都不支持。该值不必释放。
|
||||||
|
PKGREAD_API DWORD GetResourcesDxFeatureLevels (_In_ HPKGREAD hReader);
|
||||||
|
// 销毁 GetResourcesLanguages 获取的数组
|
||||||
|
PKGREAD_API void DestroyResourcesLanguagesList (_In_ HLIST_PVOID hList);
|
||||||
|
// 销毁 GetResourcesLanguagesToLcid 获取的数组
|
||||||
|
PKGREAD_API void DestroyResourcesLanguagesLcidList (_In_ HLIST_LCID hList);
|
||||||
|
PKGREAD_API void DestroyUInt32List (_In_ HLIST_UINT32 hList);
|
||||||
|
// 销毁 GetResourcesScales 获取的数组
|
||||||
|
#define DestroyResourcesScalesList DestroyUInt32List
|
||||||
|
|
||||||
|
// Dependencies
|
||||||
|
#ifndef _TYPE_STRUCT_DEPENDENCY_
|
||||||
|
#define _TYPE_STRUCT_DEPENDENCY_
|
||||||
|
typedef struct _DEPENDENCY_INFO
|
||||||
|
{
|
||||||
|
VERSION verMin;
|
||||||
|
LPWSTR lpName _DEFAULT_INIT_VALUE_ (NULL);
|
||||||
|
LPWSTR lpPublisher _DEFAULT_INIT_VALUE_ (NULL);
|
||||||
|
} DEPENDENCY_INFO;
|
||||||
|
#endif
|
||||||
|
#ifndef _TYPE_STRUCT_DEPENDENCY_LIST_
|
||||||
|
#define _TYPE_STRUCT_DEPENDENCY_LIST_
|
||||||
|
typedef struct _LIST_DEPINFO
|
||||||
|
{
|
||||||
|
DWORD dwSize _DEFAULT_INIT_VALUE_ (0);
|
||||||
|
DEPENDENCY_INFO aDepInfo [1];
|
||||||
|
} LIST_DEPINFO, *HLIST_DEPINFO;
|
||||||
|
#endif
|
||||||
|
// 获取依赖项信息数组,返回 HLIST_DEPINFO。必须由 DestroyDependencesInfoList 销毁
|
||||||
|
PKGREAD_API HLIST_DEPINFO GetDependencesInfoList (_In_ HPKGREAD hReader);
|
||||||
|
// 通过 GetDependencesInfoList 返回的指针由此销毁
|
||||||
|
PKGREAD_API void DestroyDependencesInfoList (_In_ HLIST_DEPINFO hList);
|
||||||
|
|
||||||
|
// Capabilities
|
||||||
|
PKGREAD_API HLIST_PVOID GetCapabilitiesList (_In_ HPKGREAD hReader);
|
||||||
|
PKGREAD_API HLIST_PVOID GetDeviceCapabilitiesList (_In_ HPKGREAD hReader);
|
||||||
|
PKGREAD_API void DestroyWStringList (_In_ HLIST_PVOID hList);
|
||||||
|
#define DestroyCapabilitiesList DestroyWStringList
|
||||||
|
#define DestroyDeviceCapabilitiesList DestroyWStringList
|
||||||
|
|
||||||
|
#if defined (__cplusplus) && defined (PKGREAD_EXPORTS)
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <string>
|
||||||
|
#include <functional>
|
||||||
|
class package_info
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
HPKGREAD hReader = nullptr;
|
||||||
|
std::wstring filepath = L"";
|
||||||
|
struct deconstr
|
||||||
|
{
|
||||||
|
std::function <void ()> endtask = nullptr;
|
||||||
|
deconstr (std::function <void ()> pf): endtask (pf) {}
|
||||||
|
~deconstr () { if (endtask) endtask (); }
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
class identity
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
HPKGREAD &hReader;
|
||||||
|
public:
|
||||||
|
identity (HPKGREAD hReader): hReader (hReader) {}
|
||||||
|
std::wstring string_value (DWORD dwName) const
|
||||||
|
{
|
||||||
|
LPWSTR lpstr = nullptr;
|
||||||
|
deconstr rel ([&lpstr] () {
|
||||||
|
if (lpstr) free (lpstr);
|
||||||
|
lpstr = nullptr;
|
||||||
|
});
|
||||||
|
lpstr = GetPackageIdentityStringValue (hReader, dwName);
|
||||||
|
return lpstr;
|
||||||
|
}
|
||||||
|
VERSION version (bool read_subpkg_ver = false) const
|
||||||
|
{
|
||||||
|
VERSION ver;
|
||||||
|
GetPackageIdentityVersion (hReader, &ver, read_subpkg_ver);
|
||||||
|
return ver;
|
||||||
|
}
|
||||||
|
DWORD architecture () const
|
||||||
|
{
|
||||||
|
DWORD dw = 0;
|
||||||
|
GetPackageIdentityArchitecture (hReader, &dw);
|
||||||
|
return dw;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
package_info (): hReader (CreatePackageReader ()) {}
|
||||||
|
~package_info () { DestroyPackageReader (hReader); hReader = nullptr; }
|
||||||
|
std::wstring file () const { return filepath; }
|
||||||
|
bool file (const std::wstring &path)
|
||||||
|
{
|
||||||
|
return LoadPackageFromFile (hReader, (filepath = path).c_str ());
|
||||||
|
}
|
||||||
|
WORD package_type () const { return GetPackageType (hReader); }
|
||||||
|
bool valid () const { return hReader && IsPackageValid (hReader); }
|
||||||
|
WORD package_role () const { return GetPackageRole (hReader); }
|
||||||
|
identity get_identity () const { return identity (hReader); }
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _DEFAULT_INIT_VALUE_
|
||||||
|
#undef _DEFAULT_INIT_VALUE_
|
||||||
|
#endif
|
||||||
|
#ifdef _DEFAULT_INIT_VALUE_FORFUNC_
|
||||||
|
#undef _DEFAULT_INIT_VALUE_FORFUNC_
|
||||||
|
#endif
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
190
pkgread/pkgread.vcxproj
Normal file
190
pkgread/pkgread.vcxproj
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
<?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>{A7753282-AA16-43D9-8ACA-7065239DD702}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>pkgread</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;PKGREAD_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;PKGREAD_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;PKGREAD_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;PKGREAD_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="dynarr.h" />
|
||||||
|
<ClInclude Include="localeex.h" />
|
||||||
|
<ClInclude Include="norstr.h" />
|
||||||
|
<ClInclude Include="pkgread.h" />
|
||||||
|
<ClInclude Include="raii.h" />
|
||||||
|
<ClInclude Include="readobj.h" />
|
||||||
|
<ClInclude Include="resource.h" />
|
||||||
|
<ClInclude Include="stdafx.h" />
|
||||||
|
<ClInclude Include="stringres.h" />
|
||||||
|
<ClInclude Include="syncutil.h" />
|
||||||
|
<ClInclude Include="targetver.h" />
|
||||||
|
<ClInclude Include="version.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="pkgread.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>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
72
pkgread/pkgread.vcxproj.filters
Normal file
72
pkgread/pkgread.vcxproj.filters
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<?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="pkgread.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="readobj.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="version.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="resource.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="stringres.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="dynarr.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="norstr.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="raii.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="syncutil.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="localeex.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="pkgread.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="dllmain.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
8
pkgread/raii.h
Normal file
8
pkgread/raii.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <functional>
|
||||||
|
struct raii
|
||||||
|
{
|
||||||
|
std::function <void ()> endtask = nullptr;
|
||||||
|
raii (std::function <void ()> pFunc = nullptr): endtask (pFunc) {}
|
||||||
|
~raii () { if (endtask) endtask (); }
|
||||||
|
};
|
||||||
1157
pkgread/readobj.h
Normal file
1157
pkgread/readobj.h
Normal file
File diff suppressed because it is too large
Load Diff
14
pkgread/resource.h
Normal file
14
pkgread/resource.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Visual C++ generated include file.
|
||||||
|
// Used by pkgread.rc
|
||||||
|
|
||||||
|
// 新对象的下一组默认值
|
||||||
|
//
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||||
|
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||||
|
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||||
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
8
pkgread/stdafx.cpp
Normal file
8
pkgread/stdafx.cpp
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// stdafx.cpp : 只包括标准包含文件的源文件
|
||||||
|
// pkgread.pch 将作为预编译头
|
||||||
|
// stdafx.obj 将包含预编译类型信息
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
// TODO: 在 STDAFX.H 中引用任何所需的附加头文件,
|
||||||
|
//而不是在此文件中引用
|
||||||
26
pkgread/stdafx.h
Normal file
26
pkgread/stdafx.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// stdafx.h : 标准系统包含文件的包含文件,
|
||||||
|
// 或是经常使用但不常更改的
|
||||||
|
// 特定于项目的包含文件
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "targetver.h"
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN // 从 Windows 头中排除极少使用的资料
|
||||||
|
// Windows 头文件:
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: 在此处引用程序需要的其他头文件
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <Shlwapi.h>
|
||||||
|
#include <AppxPackaging.h>
|
||||||
|
#include <strsafe.h>
|
||||||
|
#include <sstream>
|
||||||
|
#include <atlbase.h>
|
||||||
|
#include <functional>
|
||||||
|
#include <utility>
|
||||||
124
pkgread/stringres.h
Normal file
124
pkgread/stringres.h
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
#include "version.h"
|
||||||
|
#include "dynarr.h"
|
||||||
|
#include "norstr.h"
|
||||||
|
#include "syncutil.h"
|
||||||
|
static const std::pair <UINT64, LPCWSTR> captable [] = {
|
||||||
|
{APPX_CAPABILITY_INTERNET_CLIENT, L"internetClient"},
|
||||||
|
{APPX_CAPABILITY_INTERNET_CLIENT_SERVER, L"internetClientServer"},
|
||||||
|
{APPX_CAPABILITY_PRIVATE_NETWORK_CLIENT_SERVER, L"privateNetworkClientServer"},
|
||||||
|
{APPX_CAPABILITY_DOCUMENTS_LIBRARY, L"documentsLibrary"},
|
||||||
|
{APPX_CAPABILITY_PICTURES_LIBRARY, L"picturesLibrary"},
|
||||||
|
{APPX_CAPABILITY_VIDEOS_LIBRARY, L"videosLibrary"},
|
||||||
|
{APPX_CAPABILITY_MUSIC_LIBRARY, L"musicLibrary"},
|
||||||
|
{APPX_CAPABILITY_ENTERPRISE_AUTHENTICATION, L"enterpriseAuthentication"},
|
||||||
|
{APPX_CAPABILITY_SHARED_USER_CERTIFICATES, L"sharedUserCertificates"},
|
||||||
|
{APPX_CAPABILITY_REMOVABLE_STORAGE, L"removableStorage"},
|
||||||
|
{0x00000400, L"appointments"}, // APPX_CAPABILITY_APPOINTMENTS
|
||||||
|
{0x00000800, L"contacts"}, // APPX_CAPABILITY_CONTACTS
|
||||||
|
{0x00001000, L"phoneCall"},
|
||||||
|
{0x00002000, L"blockedChatMessages"},
|
||||||
|
{0x00004000, L"objects3D"},
|
||||||
|
{0x00008000, L"allJoyn"},
|
||||||
|
{0x00010000, L"codeGeneration"},
|
||||||
|
{0x00020000, L"remoteSystem"},
|
||||||
|
{0x00040000, L"userAccountInformation"},
|
||||||
|
{0x00080000, L"extendedExecution"},
|
||||||
|
{0x00100000, L"location"},
|
||||||
|
{0x00200000, L"microphone"},
|
||||||
|
{0x00400000, L"proximity"},
|
||||||
|
{0x00800000, L"webcam"},
|
||||||
|
{0x01000000, L"spatialPerception"},
|
||||||
|
{0x02000000, L"appointmentsSystem"},
|
||||||
|
{0x04000000, L"contactsSystem"},
|
||||||
|
{0x08000000, L"phoneCallSystem"},
|
||||||
|
{0x10000000, L"smsSend"},
|
||||||
|
{0x20000000, L"userDataTasks"},
|
||||||
|
{0x40000000, L"userDataTasksSystem"},
|
||||||
|
{0x80000000, L"userDataAccounts"}
|
||||||
|
};
|
||||||
|
void CapabilitiesFlagsToNames (APPX_CAPABILITIES caps, std::vector<std::wstring> &output)
|
||||||
|
{
|
||||||
|
output.clear ();
|
||||||
|
output.reserve (16);
|
||||||
|
UINT64 packageCap = (UINT64)caps;
|
||||||
|
for (auto &entry : captable)
|
||||||
|
{
|
||||||
|
if (packageCap & entry.first)
|
||||||
|
{
|
||||||
|
push_unique (output, std::wstring (entry.second));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const std::pair <version, LPCWSTR> vertable [] = {
|
||||||
|
{version (10, 0, 25299, 0), L"Windows 11 Version 25H2"},
|
||||||
|
{version (10, 0, 24699, 0), L"Windows 11 Version 24H2"},
|
||||||
|
{version (10, 0, 24000, 0), L"Windows 11 Version 23H2"},
|
||||||
|
{version (10, 0, 22621, 0), L"Windows 11 Version 22H2"},
|
||||||
|
{version (10, 0, 22159, 0), L"Windows 11 Initial Release (Version 21H2)"},
|
||||||
|
{version (10, 0, 19645, 0), L"Windows 10 Insider Preview (Build 19645)"},
|
||||||
|
{version (10, 0, 19541, 0), L"Windows 10 Insider Preview (Build 19541)"},
|
||||||
|
{version (10, 0, 19045, 0), L"Windows 10 Version 22H2"},
|
||||||
|
{version (10, 0, 19044, 0), L"Windows 10 Version 21H2 (November 2021 Update)"},
|
||||||
|
{version (10, 0, 19043, 0), L"Windows 10 Version 21H2 (May 2021 Update)"},
|
||||||
|
{version (10, 0, 19042, 0), L"Windows 10 Version 20H2"},
|
||||||
|
{version (10, 0, 18362, 0), L"Windows 10 May 2019 Update"},
|
||||||
|
{version (10, 0, 17763, 0), L"Windows 10 October 2018 Update"},
|
||||||
|
{version (10, 0, 17134, 0), L"Windows 10 April 2018 Update"},
|
||||||
|
{version (10, 0, 16299, 0), L"Windows 10 Fall Creators Update"},
|
||||||
|
{version (10, 0, 15063, 0), L"Windows 10 Creators Update"},
|
||||||
|
{version (10, 0, 14393, 0), L"Windows 10 Anniversary Update"},
|
||||||
|
{version (10, 0, 10240, 0), L"Windows 10"},
|
||||||
|
{version (10, 0, 0, 0), L"Windows 10"},
|
||||||
|
{version (6, 4, 9807, 0), L"Windows 10 Technical Preview"},
|
||||||
|
{version (6, 3, 1, 0), L"Windows Phone 8.1"},
|
||||||
|
{version (6, 3, 0, 0), L"Windows 8.1"},
|
||||||
|
{version (6, 2, 1, 0), L"Windows 8"},
|
||||||
|
{version (6, 2, 0, 0), L"Windows 8 Develop Preview"}
|
||||||
|
};
|
||||||
|
std::wstring GetPrerequistOSVersionDescription (const version &ver)
|
||||||
|
{
|
||||||
|
for (const auto &v : vertable)
|
||||||
|
{
|
||||||
|
if (ver >= v.first) return std::wstring (v.second);
|
||||||
|
}
|
||||||
|
return L"Unknown Windows Version";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector <std::wstring> appitems =
|
||||||
|
{
|
||||||
|
L"Id",
|
||||||
|
L"DisplayName",
|
||||||
|
L"BackgroundColor",
|
||||||
|
L"ForegroundText",
|
||||||
|
L"ShortName",
|
||||||
|
L"Square44x44Logo"
|
||||||
|
};
|
||||||
|
std::vector <std::wstring> &GetApplicationAttributeItems () { return appitems; }
|
||||||
|
static CriticalSection g_appcs;
|
||||||
|
bool PushApplicationAttributeItem (const std::wstring &lpstr)
|
||||||
|
{
|
||||||
|
CreateScopedLock (g_appcs);
|
||||||
|
size_t len1 = appitems.size ();
|
||||||
|
push_unique <std::wstring> (appitems, lpstr, [] (const std::wstring &v1, const std::wstring &v2) -> bool {
|
||||||
|
return std::wnstring (v1) == std::wnstring (v2);
|
||||||
|
});
|
||||||
|
return appitems.size () > len1;
|
||||||
|
}
|
||||||
|
bool RemoveApplicationAttributeItem (const std::wstring &lpstr)
|
||||||
|
{
|
||||||
|
CreateScopedLock (g_appcs);
|
||||||
|
auto it = std::find_if (appitems.begin (), appitems.end (), [&] (const std::wstring &v) {
|
||||||
|
return std::wnstring (v) == std::wnstring (lpstr);
|
||||||
|
});
|
||||||
|
if (it != appitems.end ())
|
||||||
|
{
|
||||||
|
size_t len1 = appitems.size ();
|
||||||
|
appitems.erase (it);
|
||||||
|
return appitems.size () < len1;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
124
pkgread/syncutil.h
Normal file
124
pkgread/syncutil.h
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
#pragma once
|
||||||
|
#pragma once
|
||||||
|
#include <Windows.h>
|
||||||
|
class CriticalSection
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
CRITICAL_SECTION m_csection;
|
||||||
|
public:
|
||||||
|
CriticalSection (DWORD spinCount = 4000) { InitializeCriticalSectionAndSpinCount (&m_csection, spinCount); }
|
||||||
|
CriticalSection (const CriticalSection &) = delete;
|
||||||
|
CriticalSection &operator = (const CriticalSection &) = delete;
|
||||||
|
~CriticalSection () { DeleteCriticalSection (&m_csection); }
|
||||||
|
void Lock () { EnterCriticalSection (&m_csection); }
|
||||||
|
void Unlock () { LeaveCriticalSection (&m_csection); }
|
||||||
|
bool TryLock () { return TryEnterCriticalSection (&m_csection) != 0; }
|
||||||
|
class ScopedLock
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit ScopedLock (CriticalSection &cs): m_cs (cs) { m_cs.Lock (); }
|
||||||
|
~ScopedLock () { m_cs.Unlock (); }
|
||||||
|
ScopedLock (const ScopedLock &) = delete;
|
||||||
|
ScopedLock &operator = (const ScopedLock &) = delete;
|
||||||
|
private:
|
||||||
|
CriticalSection& m_cs;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#define CreateScopedLock(_obj_cs_) CriticalSection::ScopedLock _obj_cs_ (_obj_cs_)
|
||||||
|
|
||||||
|
#ifdef __cplusplus_cli
|
||||||
|
ref struct TaskStructEvent
|
||||||
|
{
|
||||||
|
typedef array <Object ^> args;
|
||||||
|
typedef void (*eventfunc) (... args ^args);
|
||||||
|
eventfunc post;
|
||||||
|
args ^postargs;
|
||||||
|
public:
|
||||||
|
TaskStructEvent (
|
||||||
|
eventfunc prefunc,
|
||||||
|
args ^preargs,
|
||||||
|
eventfunc postfunc,
|
||||||
|
args ^postargs
|
||||||
|
): post (postfunc), postargs (postargs)
|
||||||
|
{
|
||||||
|
if (prefunc == nullptr) {
|
||||||
|
#pragma message("警告:预处理函数指针为空,可能跳过初始化操作")
|
||||||
|
}
|
||||||
|
if (prefunc)
|
||||||
|
{
|
||||||
|
if (preargs)
|
||||||
|
{
|
||||||
|
#pragma region 参数验证示例
|
||||||
|
/*
|
||||||
|
实际项目中应添加具体类型检查,例如:
|
||||||
|
ValidateArgsType<Button^>(preargs);
|
||||||
|
*/
|
||||||
|
#pragma endregion
|
||||||
|
prefunc (preargs);
|
||||||
|
}
|
||||||
|
else prefunc (gcnew args {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
~TaskStructEvent ()
|
||||||
|
{
|
||||||
|
if (post == nullptr)
|
||||||
|
{
|
||||||
|
#pragma message("警告:后处理函数指针为空,资源可能无法正确释放")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (postargs) { post (postargs); }
|
||||||
|
else { post (gcnew args {}); }
|
||||||
|
}
|
||||||
|
catch (Exception ^e)
|
||||||
|
{
|
||||||
|
#pragma message("注意:后处理中的异常需手动处理")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#define CreateStructEvent(_varname_taskname_, _func_construct_, _args_construct_, _func_destruct_, _args_destruct_) \
|
||||||
|
TaskStructEvent _varname_taskname_ ( \
|
||||||
|
_func_construct_, \
|
||||||
|
_args_construct_, \
|
||||||
|
_func_destruct_, \
|
||||||
|
_args_destruct_ \
|
||||||
|
)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#include <functional>
|
||||||
|
#include <utility>
|
||||||
|
template <typename PreCallback, typename PostCallback> class ScopedEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ScopedEvent (PreCallback &&pre, PostCallback &&post)
|
||||||
|
: m_post (std::forward <PostCallback> (post))
|
||||||
|
{
|
||||||
|
static_assert (
|
||||||
|
std::is_constructible <std::function <void ()>, PreCallback>::value,
|
||||||
|
"预处理回调必须可转换为 void () 类型"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (pre) { pre (); }
|
||||||
|
}
|
||||||
|
~ScopedEvent () noexcept
|
||||||
|
{
|
||||||
|
if (m_post) { m_post (); }
|
||||||
|
}
|
||||||
|
ScopedEvent (const ScopedEvent &) = delete;
|
||||||
|
ScopedEvent &operator = (const ScopedEvent &) = delete;
|
||||||
|
ScopedEvent (ScopedEvent &&) = default;
|
||||||
|
ScopedEvent &operator =(ScopedEvent &&) = default;
|
||||||
|
private:
|
||||||
|
PostCallback m_post;
|
||||||
|
};
|
||||||
|
template <typename PreFunc, typename PostFunc> auto make_scoped_event (PreFunc &&pre, PostFunc &&post)
|
||||||
|
{
|
||||||
|
return ScopedEvent <PreFunc, PostFunc> (
|
||||||
|
std::forward <PreFunc> (pre),
|
||||||
|
std::forward <PostFunc> (post)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
8
pkgread/targetver.h
Normal file
8
pkgread/targetver.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
|
||||||
|
|
||||||
|
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并将
|
||||||
|
// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
|
||||||
|
|
||||||
|
#include <SDKDDKVer.h>
|
||||||
124
pkgread/version.h
Normal file
124
pkgread/version.h
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <cstdint>
|
||||||
|
typedef uint64_t UINT64;
|
||||||
|
typedef int64_t INT64;
|
||||||
|
typedef uint16_t UINT16;
|
||||||
|
typedef struct version
|
||||||
|
{
|
||||||
|
UINT16 major = 0, minor = 0, build = 0, revision = 0;
|
||||||
|
version (UINT64 value):
|
||||||
|
major ((value >> 0x30) & 0xFFFF), minor ((value >> 0x20) & 0xFFFF),
|
||||||
|
build ((value >> 0x10) & 0xFFFF), revision ((value) & 0xFFFF) {}
|
||||||
|
version (UINT16 major, UINT16 minor, UINT16 build, UINT16 revision):
|
||||||
|
major (major), minor (minor), build (build), revision (revision) {}
|
||||||
|
version (const std::wstring &verstr) { this->interpret (verstr); }
|
||||||
|
version (const std::string &verstr) { this->interpret (verstr); }
|
||||||
|
version () {}
|
||||||
|
version (const version &other): major (other.major), minor (other.minor), build (other.build), revision (other.revision) {}
|
||||||
|
version (version &&other) noexcept: major (other.major), minor (other.minor), build (other.build), revision (other.revision) {}
|
||||||
|
version &operator = (const version &other)
|
||||||
|
{
|
||||||
|
if (this != &other)
|
||||||
|
{
|
||||||
|
major = other.major;
|
||||||
|
minor = other.minor;
|
||||||
|
build = other.build;
|
||||||
|
revision = other.revision;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
version &operator = (version &&other) noexcept
|
||||||
|
{
|
||||||
|
if (this != &other)
|
||||||
|
{
|
||||||
|
major = other.major;
|
||||||
|
minor = other.minor;
|
||||||
|
build = other.build;
|
||||||
|
revision = other.revision;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
version &operator = (UINT64 value) { this->data (value); return *this; }
|
||||||
|
UINT64 data () const { return (((UINT64)major) << 48) | (((UINT64)minor) << 32) | (((UINT64)build) << 16) | ((UINT64)revision); }
|
||||||
|
UINT64 data (UINT64 value)
|
||||||
|
{
|
||||||
|
major = (value >> 48) & 0xFFFF;
|
||||||
|
minor = (value >> 32) & 0xFFFF;
|
||||||
|
build = (value >> 16) & 0xFFFF;
|
||||||
|
revision = value & 0xFFFF;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
std::wstring stringifyw () const
|
||||||
|
{
|
||||||
|
std::wstringstream ss;
|
||||||
|
ss << major << L'.' << minor << L'.' << build << L'.' << revision;
|
||||||
|
return ss.str ();
|
||||||
|
}
|
||||||
|
std::string stringify () const
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << major << '.' << minor << '.' << build << '.' << revision;
|
||||||
|
return ss.str ();
|
||||||
|
}
|
||||||
|
version &interpret (const std::wstring &verstr)
|
||||||
|
{
|
||||||
|
auto result = split (verstr);
|
||||||
|
if (result.size () > 0) this->major = _wtoi (result [0].c_str ());
|
||||||
|
if (result.size () > 1) this->minor = _wtoi (result [1].c_str ());
|
||||||
|
if (result.size () > 2) this->build = _wtoi (result [2].c_str ());
|
||||||
|
if (result.size () > 3) this->revision = _wtoi (result [3].c_str ());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
version &interpret (const std::string &verstr)
|
||||||
|
{
|
||||||
|
auto result = split (verstr);
|
||||||
|
if (result.size () > 0) this->major = atoi (result [0].c_str ());
|
||||||
|
if (result.size () > 1) this->minor = atoi (result [1].c_str ());
|
||||||
|
if (result.size () > 2) this->build = atoi (result [2].c_str ());
|
||||||
|
if (result.size () > 3) this->revision = atoi (result [3].c_str ());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
bool empty () const { return *(UINT64 *)this == 0; }
|
||||||
|
friend bool operator == (const version &l, const version &r) { return *(UINT64 *)&l == *(UINT64 *)&r; }
|
||||||
|
friend bool operator == (const version &l, const UINT64 &r) { return l.data () == r; }
|
||||||
|
friend bool operator == (const UINT64 &r, const version &l) { return l.data () == r; }
|
||||||
|
friend bool operator < (const version &l, const version &r) { return l.data () < r.data (); }
|
||||||
|
friend bool operator > (const version &l, const version &r) { return l.data () > r.data (); }
|
||||||
|
friend bool operator <= (const version &l, const version &r) { return l.data () <= r.data (); }
|
||||||
|
friend bool operator >= (const version &l, const version &r) { return l.data () >= r.data (); }
|
||||||
|
friend bool operator != (const version &l, const version &r) { return *(UINT64 *)&l != *(UINT64 *)&r; }
|
||||||
|
explicit operator bool () const { return !this->empty (); }
|
||||||
|
bool operator ! () { return this->empty (); }
|
||||||
|
friend std::ostream &operator << (std::ostream &o, const version &v) { return o << v.major << '.' << v.minor << '.' << v.build << '.' << v.revision; }
|
||||||
|
friend std::wostream &operator << (std::wostream &o, const version &v) { return o << v.major << '.' << v.minor << '.' << v.build << '.' << v.revision; }
|
||||||
|
bool equals (const version &r) const { return *this == r; }
|
||||||
|
INT64 compare (const version &r) const { return this->data () - r.data (); }
|
||||||
|
static version parse (const std::wstring &value) { return version (value); }
|
||||||
|
static version parse (const std::string &value) { return version (value); }
|
||||||
|
static std::wstring stringifyw (const version &v) { return v.stringifyw (); }
|
||||||
|
static std::string stringify (const version &v) { return v.stringify (); }
|
||||||
|
static bool equals (const version &l, const version &r) { return l == r; }
|
||||||
|
static INT64 compare (const version &l, const version &r) { return l.data () - r.data (); }
|
||||||
|
static version decode (UINT64 value) { return version (value); }
|
||||||
|
static UINT64 encode (const version &v) { return v.data (); }
|
||||||
|
protected:
|
||||||
|
template <typename StringType> std::vector <StringType> split (const StringType &str, typename StringType::value_type delimiter1 = '.', typename StringType::value_type delimiter2 = ',')
|
||||||
|
{
|
||||||
|
std::vector <StringType> result;
|
||||||
|
std::basic_stringstream<typename StringType::value_type> ss (str);
|
||||||
|
StringType segment;
|
||||||
|
while (std::getline (ss, segment, delimiter1))
|
||||||
|
{
|
||||||
|
size_t pos = 0;
|
||||||
|
while ((pos = segment.find (delimiter2)) != StringType::npos)
|
||||||
|
{
|
||||||
|
result.push_back (segment.substr (0, pos));
|
||||||
|
segment.erase (0, pos + 1);
|
||||||
|
}
|
||||||
|
if (!segment.empty ()) result.push_back (segment);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
} Version;
|
||||||
30
prireader/ReadMe.txt
Normal file
30
prireader/ReadMe.txt
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
========================================================================
|
||||||
|
动态链接库:prireader 项目概述
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
应用程序向导已为您创建了此 prireader DLL。
|
||||||
|
|
||||||
|
本文件概要介绍组成 prireader 应用程序的每个文件的内容。
|
||||||
|
|
||||||
|
|
||||||
|
prireader.vcxproj
|
||||||
|
这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
|
||||||
|
|
||||||
|
prireader.vcxproj.filters
|
||||||
|
这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
|
||||||
|
|
||||||
|
prireader.cpp
|
||||||
|
这是主 DLL 源文件。
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
其他标准文件:
|
||||||
|
|
||||||
|
StdAfx.h, StdAfx.cpp
|
||||||
|
这些文件用于生成名为 prireader.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
其他注释:
|
||||||
|
|
||||||
|
应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
19
prireader/dllmain.cpp
Normal file
19
prireader/dllmain.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
1
prireader/priread.h
Normal file
1
prireader/priread.h
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#pragma once
|
||||||
22
prireader/prireader.cpp
Normal file
22
prireader/prireader.cpp
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
// prireader.cpp : 定义 DLL 应用程序的导出函数。
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "prireader.h"
|
||||||
|
|
||||||
|
|
||||||
|
// 这是导出变量的一个示例
|
||||||
|
PRIREADER_API int nprireader=0;
|
||||||
|
|
||||||
|
// 这是导出函数的一个示例。
|
||||||
|
PRIREADER_API int fnprireader(void)
|
||||||
|
{
|
||||||
|
return 42;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 这是已导出类的构造函数。
|
||||||
|
// 有关类定义的信息,请参阅 prireader.h
|
||||||
|
Cprireader::Cprireader()
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
22
prireader/prireader.h
Normal file
22
prireader/prireader.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
// 下列 ifdef 块是创建使从 DLL 导出更简单的
|
||||||
|
// 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 PRIREADER_EXPORTS
|
||||||
|
// 符号编译的。在使用此 DLL 的
|
||||||
|
// 任何其他项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
|
||||||
|
// PRIREADER_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
|
||||||
|
// 符号视为是被导出的。
|
||||||
|
#ifdef PRIREADER_EXPORTS
|
||||||
|
#define PRIREADER_API __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define PRIREADER_API __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 此类是从 prireader.dll 导出的
|
||||||
|
class PRIREADER_API Cprireader {
|
||||||
|
public:
|
||||||
|
Cprireader(void);
|
||||||
|
// TODO: 在此添加您的方法。
|
||||||
|
};
|
||||||
|
|
||||||
|
extern PRIREADER_API int nprireader;
|
||||||
|
|
||||||
|
PRIREADER_API int fnprireader(void);
|
||||||
180
prireader/prireader.vcxproj
Normal file
180
prireader/prireader.vcxproj
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
<?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>{D8CFAA98-0A77-4C5B-A61B-11EF44206712}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>prireader</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>v120</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;PRIREADER_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;PRIREADER_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;PRIREADER_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;PRIREADER_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="priread.h" />
|
||||||
|
<ClInclude Include="prireader.h" />
|
||||||
|
<ClInclude Include="resource.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="prireader.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>
|
||||||
48
prireader/prireader.vcxproj.filters
Normal file
48
prireader/prireader.vcxproj.filters
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?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="prireader.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="resource.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="priread.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="prireader.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="dllmain.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
14
prireader/resource.h
Normal file
14
prireader/resource.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Visual C++ generated include file.
|
||||||
|
// Used by prireader.rc
|
||||||
|
|
||||||
|
// 新对象的下一组默认值
|
||||||
|
//
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||||
|
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||||
|
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||||
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
8
prireader/stdafx.cpp
Normal file
8
prireader/stdafx.cpp
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// stdafx.cpp : 只包括标准包含文件的源文件
|
||||||
|
// prireader.pch 将作为预编译头
|
||||||
|
// stdafx.obj 将包含预编译类型信息
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
// TODO: 在 STDAFX.H 中引用任何所需的附加头文件,
|
||||||
|
//而不是在此文件中引用
|
||||||
21
prireader/stdafx.h
Normal file
21
prireader/stdafx.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// 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 <winres.h>
|
||||||
8
prireader/targetver.h
Normal file
8
prireader/targetver.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
|
||||||
|
|
||||||
|
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并将
|
||||||
|
// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
|
||||||
|
|
||||||
|
#include <SDKDDKVer.h>
|
||||||
Reference in New Issue
Block a user