-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhost-x64.cs
More file actions
75 lines (60 loc) · 2.2 KB
/
host-x64.cs
File metadata and controls
75 lines (60 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System.Runtime.InteropServices;
using System;
[ComImport]
[Guid("ACB8875E-1D4F-4982-97FE-3EE60DF4ED7C")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IFactoryClass
{
ILightComClass Create();
}
[ComImport]
[Guid("7BA9D65A-D575-460A-8D95-3C3BDAAA5779")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ILightComClass
{
void DoSomething([In, MarshalAs(UnmanagedType.LPWStr)] string name);
void DoSomething2([In, MarshalAs(UnmanagedType.LPStr)] string name);
}
class Program
{
[DllImport("shared-msvc17-mtr-x64.dll", EntryPoint = "CreateFactory", CallingConvention = CallingConvention.StdCall)]
extern static void CreateFactory(out IFactoryClass factory);
[DllImport("shared-msvc17-mtd-x64.dll", EntryPoint = "CreateFactory", CallingConvention = CallingConvention.StdCall)]
extern static void CreateFactoryd(out IFactoryClass factory);
[DllImport("shared-vs22-clang-x64.dll", EntryPoint = "CreateFactory", CallingConvention = CallingConvention.StdCall)]
extern static void CreateFactory_clang(out IFactoryClass factory);
[DllImport("shared-gcc-r-x64.dll", EntryPoint = "CreateFactory", CallingConvention = CallingConvention.StdCall)]
extern static void CreateFactory_gccr(out IFactoryClass factory);
[DllImport("shared-gcc-d-x64.dll", EntryPoint = "CreateFactory", CallingConvention = CallingConvention.StdCall)]
extern static void CreateFactory_gccd(out IFactoryClass factory);
static void Main(string[] args)
{
IFactoryClass factory;
switch((args.Length > 0)?args[0]:"msvc")
{
case "gccd":
CreateFactory_gccd(out factory);
break;
case "gcc":
case "gccr":
CreateFactory_gccr(out factory);
break;
case "clang":
CreateFactory_clang(out factory);
break;
case "msvcd":
CreateFactoryd(out factory);
break;
case "msvc":
default:
CreateFactory(out factory);
break;
}
if(factory != null)
{
ILightComClass light = factory.Create();
light.DoSomething("Hello");
light.DoSomething2(" World\n");
}
}
}