Skip to content

Commit

Permalink
Simplify Initialization Process of RegFreeWinRT on C# (#694)
Browse files Browse the repository at this point in the history
Simplify Initialization Process of RegFreeWinRT on C#
  • Loading branch information
kythant committed Sep 23, 2020
1 parent f02b7df commit dc52d1c
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<file src="$winrtactx64debug$" target="runtimes\x64\debug\"/>
<file src="$winrtactx86release$" target="runtimes\x86\release\"/>
<file src="$winrtactx86debug$" target="runtimes\x86\debug\"/>
<file src="$mwinrtactx64release$" target="lib\netstandard2.0"/>
<file src="$winrtactlibx64release$" target="runtimes\x64\release\"/>
<file src="$winrtactlibx64debug$" target="runtimes\x64\debug\"/>
<file src="$winrtactlibx86release$" target="runtimes\x86\release\"/>
Expand Down
9 changes: 3 additions & 6 deletions src/UndockedRegFreeWinRT/Nuget/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ Initializing the detours on winrtact.dll
Initialization of the dll is taken care of automatically through ForceSymbolReferences.

- Managed
For Managed code, one will need to call DllImport on winrtact.dll and extern winrtact_Initialize().

[DllImport("winrtact.dll")]
static extern void winrtact_Initialize();

winrtact_Initialize() needs to be called on startup to initialize the detours and load the catalog.
For Managed code, one will have to initialize it manually by calling
Microsoft.Windows.UndockedRegFreeWinrt.Initialize();
This will initialize the detours and load the catalog.


Example application manifest:
Expand Down
9 changes: 3 additions & 6 deletions src/UndockedRegFreeWinRT/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ Initializing the detours on winrtact.dll
Initialization of the dll is taken care of automatically through ForceSymbolReferences.

- Managed
For Managed code, one will need to call DllImport on winrtact.dll and extern winrtact_Initialize().
```
[DllImport("winrtact.dll")]
static extern void winrtact_Initialize();
```
winrtact_Initialize() needs to be called on startup to initialize the detours and load the catalog.
For Managed code, one will have to initialize it manually by calling
Microsoft.Windows.UndockedRegFreeWinrt.Initialize();
This will initialize the detours and load the catalog.


Example application manifest:
Expand Down
32 changes: 18 additions & 14 deletions src/UndockedRegFreeWinRT/UndockedRegFreeWinRT.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestComponent", "TestCompon
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UndockedRegFreeWinRTManagedTest", "UndockedRegFreeWinRTManagedTest\UndockedRegFreeWinRTManagedTest.csproj", "{24CDEA0D-CDB4-447C-B7D9-F19510D35581}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mwinrtact", "mwinrtact\mwinrtact.csproj", "{61857961-CD9B-4948-AC31-26B0806FA7A3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -85,20 +87,6 @@ Global
{E63DC9F0-834C-42C8-9392-13B0531A9959}.Release|x64.Build.0 = Release|x64
{E63DC9F0-834C-42C8-9392-13B0531A9959}.Release|x86.ActiveCfg = Release|Win32
{E63DC9F0-834C-42C8-9392-13B0531A9959}.Release|x86.Build.0 = Release|Win32
{060AC72D-1D76-47B8-81CE-9DD4D5FB2A17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{060AC72D-1D76-47B8-81CE-9DD4D5FB2A17}.Debug|ARM.ActiveCfg = Debug|Any CPU
{060AC72D-1D76-47B8-81CE-9DD4D5FB2A17}.Debug|x64.ActiveCfg = Debug|x64
{060AC72D-1D76-47B8-81CE-9DD4D5FB2A17}.Debug|x64.Build.0 = Debug|x64
{060AC72D-1D76-47B8-81CE-9DD4D5FB2A17}.Debug|x86.ActiveCfg = Debug|x86
{060AC72D-1D76-47B8-81CE-9DD4D5FB2A17}.Debug|x86.Build.0 = Debug|x86
{060AC72D-1D76-47B8-81CE-9DD4D5FB2A17}.Release|Any CPU.ActiveCfg = Release|Any CPU
{060AC72D-1D76-47B8-81CE-9DD4D5FB2A17}.Release|Any CPU.Build.0 = Release|Any CPU
{060AC72D-1D76-47B8-81CE-9DD4D5FB2A17}.Release|ARM.ActiveCfg = Release|Any CPU
{060AC72D-1D76-47B8-81CE-9DD4D5FB2A17}.Release|ARM.Build.0 = Release|Any CPU
{060AC72D-1D76-47B8-81CE-9DD4D5FB2A17}.Release|x64.ActiveCfg = Release|Any CPU
{060AC72D-1D76-47B8-81CE-9DD4D5FB2A17}.Release|x64.Build.0 = Release|Any CPU
{060AC72D-1D76-47B8-81CE-9DD4D5FB2A17}.Release|x86.ActiveCfg = Release|Any CPU
{060AC72D-1D76-47B8-81CE-9DD4D5FB2A17}.Release|x86.Build.0 = Release|Any CPU
{24CDEA0D-CDB4-447C-B7D9-F19510D35581}.Debug|Any CPU.ActiveCfg = Debug|x86
{24CDEA0D-CDB4-447C-B7D9-F19510D35581}.Debug|ARM.ActiveCfg = Debug|x86
{24CDEA0D-CDB4-447C-B7D9-F19510D35581}.Debug|x64.ActiveCfg = Debug|x64
Expand All @@ -111,6 +99,22 @@ Global
{24CDEA0D-CDB4-447C-B7D9-F19510D35581}.Release|x64.Build.0 = Release|x64
{24CDEA0D-CDB4-447C-B7D9-F19510D35581}.Release|x86.ActiveCfg = Release|x86
{24CDEA0D-CDB4-447C-B7D9-F19510D35581}.Release|x86.Build.0 = Release|x86
{61857961-CD9B-4948-AC31-26B0806FA7A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{61857961-CD9B-4948-AC31-26B0806FA7A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61857961-CD9B-4948-AC31-26B0806FA7A3}.Debug|ARM.ActiveCfg = Debug|Any CPU
{61857961-CD9B-4948-AC31-26B0806FA7A3}.Debug|ARM.Build.0 = Debug|Any CPU
{61857961-CD9B-4948-AC31-26B0806FA7A3}.Debug|x64.ActiveCfg = Debug|Any CPU
{61857961-CD9B-4948-AC31-26B0806FA7A3}.Debug|x64.Build.0 = Debug|Any CPU
{61857961-CD9B-4948-AC31-26B0806FA7A3}.Debug|x86.ActiveCfg = Debug|Any CPU
{61857961-CD9B-4948-AC31-26B0806FA7A3}.Debug|x86.Build.0 = Debug|Any CPU
{61857961-CD9B-4948-AC31-26B0806FA7A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{61857961-CD9B-4948-AC31-26B0806FA7A3}.Release|Any CPU.Build.0 = Release|Any CPU
{61857961-CD9B-4948-AC31-26B0806FA7A3}.Release|ARM.ActiveCfg = Release|Any CPU
{61857961-CD9B-4948-AC31-26B0806FA7A3}.Release|ARM.Build.0 = Release|Any CPU
{61857961-CD9B-4948-AC31-26B0806FA7A3}.Release|x64.ActiveCfg = Release|Any CPU
{61857961-CD9B-4948-AC31-26B0806FA7A3}.Release|x64.Build.0 = Release|Any CPU
{61857961-CD9B-4948-AC31-26B0806FA7A3}.Release|x86.ActiveCfg = Release|Any CPU
{61857961-CD9B-4948-AC31-26B0806FA7A3}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using System;
using System.Runtime.InteropServices;
using TestComponent;
using Microsoft.Windows;

namespace UndockedRegFreeWinRTManagedTest
{
class Program
{
[DllImport("winrtact.dll", PreserveSig = false)]
static extern void winrtact_Initialize();

public static bool succeeded;

static void TestClassBoth(int expected)
Expand Down Expand Up @@ -52,8 +50,8 @@ static void TestClassSta(int expected)

static int Main(string[] args)
{
UndockedRegFreeWinrt.Initialize();
Console.WriteLine("Undocked RegFree WinRT Managed Test - Starting");
winrtact_Initialize();
System.Threading.Thread testThread;

succeeded = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\mwinrtact\mwinrtact.csproj" />
<ProjectReference Include="..\TestComponent\TestComponent.vcxproj" />
<ProjectReference Include="..\UndockedRegFreeWinRT\UndockedRegFreeWinRT.vcxproj" />
</ItemGroup>
Expand Down
15 changes: 15 additions & 0 deletions src/UndockedRegFreeWinRT/mwinrtact/mwinrtact.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Runtime.InteropServices;

namespace Microsoft.Windows
{
public static class UndockedRegFreeWinrt
{
[DllImport("winrtact.dll", PreserveSig=false)]
static extern void winrtact_Initialize();

public static void Initialize()
{
winrtact_Initialize();
}
}
}
7 changes: 7 additions & 0 deletions src/UndockedRegFreeWinRT/mwinrtact/mwinrtact.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

</Project>

0 comments on commit dc52d1c

Please sign in to comment.