回答編集履歴
3
問題なし
test
CHANGED
@@ -62,7 +62,7 @@
|
|
62
62
|
|
63
63
|
|
64
64
|
|
65
|
-
解放どうなってんのかちょっと心配だが
|
65
|
+
~~解放どうなってんのかちょっと心配だが~~
|
66
66
|
|
67
67
|
|
68
68
|
|
2
追記
test
CHANGED
@@ -63,3 +63,41 @@
|
|
63
63
|
|
64
64
|
|
65
65
|
解放どうなってんのかちょっと心配だが
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
---
|
70
|
+
|
71
|
+
**追記** 返り値もできた
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
```c++
|
76
|
+
|
77
|
+
LPSAFEARRAY GetVs_return() {
|
78
|
+
|
79
|
+
CComSafeArray<BSTR> result;
|
80
|
+
|
81
|
+
std::vector <std::string> arry = { "hoge1","hoge2","hoge3" };
|
82
|
+
|
83
|
+
for (const auto& s : arry)
|
84
|
+
|
85
|
+
result.Add(A2BSTR(s.data()));
|
86
|
+
|
87
|
+
result.Add(A2BSTR("hoge4"));
|
88
|
+
|
89
|
+
return result.Detach();
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
```
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
```c#
|
98
|
+
|
99
|
+
[return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)]
|
100
|
+
|
101
|
+
internal static extern string[] GetVs_return();
|
102
|
+
|
103
|
+
```
|
1
修正
test
CHANGED
@@ -42,7 +42,7 @@
|
|
42
42
|
|
43
43
|
[DllImport("mytest.dll")]
|
44
44
|
|
45
|
-
static extern void GetVs([MarshalAs(UnmanagedType.SafeArray, afeArraySubType=VarEnum.VT_BSTR)] out string[] strings);
|
45
|
+
static extern void GetVs([MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_BSTR)] out string[] strings);
|
46
46
|
|
47
47
|
}
|
48
48
|
|