| 分類:[.NET 全般]
再度お世話になります。
@VB.netからVC++6.0のへの構造体配列参照渡し http://bbs.wankuma.com/index.cgi?mode=al2&namber=75306
AVB.net⇒VC++6.0のVoid型に構造体配列参照渡 http://bbs.wankuma.com/index.cgi?mode=al2&namber=75559
にて質問した内容に近いのですが、またはまってしまったのでお知恵を拝借出来れば助かります。
なお、AのVoid型に〜の時に同様の対応を行おうと致しましたが、あの時は結局VC側にてvoid型を 受け取る構造体の型に変更し解決致しましたので、今回求めている解決法は未解決のままです。
現状と致しましては、@の時のようにSafeArrayに対して構造体配列を受け渡ししたいのですが、 前回と異なり数値だけではなく文字列変数が混ざっています。
VC側はSafeArrayで受け取った後、同じような構造体にキャストして使用しているようですが、 その際の文字列変数はBSTRで宣言してあり、数値変数はintでした。
マーシャリングも色々と追加してみたのですが、どうにもうまくいかないので、お手数ですが お教え頂けないでしょうか。
例によってVCへの変更、及びラッパー用DLL等の作成は最終手段とし、極力VB2013のみで 完結したく考えております。
以上、宜しくお願い致します。
## VC++6.0 ###########
Test1_API int __stdcall Test1(LPSAFEARRAY *Data1, LPSAFEARRAY *Data2)
## VB6.0 #############
-- 宣言部 ----
Declare Function Test1 Lib "Test.DLL" (ByRef oType1() As Any, ByRef oType1() As Any) As Long
Public Type Type1 Str1 As String Str2 As String Lng1 As Long End Type
Public Type Type2 Str3 As String Lng2 As Long Lng3 As Long End Type
Public oType1(0 To 9) As Type1 Public oType2(0 To 9) As Type2
-- 処理 ----
Dim iRet As Long iRet = Test1(oType1(), oType2())
## VB2013 #############
-- 宣言部 ----
Declare Function Test1 Lib "Test.DLL" (<MarshalAs(UnmanagedType.SafeArray, SafeArraySubType:=VarEnum.VT_RECORD)> ByVal oStructure() As Structure1 <MarshalAs(UnmanagedType.SafeArray, SafeArraySubType:=VarEnum.VT_RECORD)> ByVal oStructure() As Structure2) As Integer
<ComVisible(True), Guid("91e3f2e5-341a-49bc-9f48-8637526c2833")> Public Structure Structure1 <MarshalAs(UnmanagedType.BStr)> Dim Str1 As String <MarshalAs(UnmanagedType.BStr)> Dim Str2 As String Dim Int1 As Integer End Structure
<ComVisible(True), Guid("e6b3817c-4342-4335-985f-5b8a0df41881")> Public Structure Structure2 <MarshalAs(UnmanagedType.BStr)> Dim Str3 As String Dim Int2 As Integer Dim Int3 As Integer End Structure
Public oStructure1(9) As Structure1 Public oStructure2(9) As Structure2
-- 処理 ----
Dim iRet As Integer = -1 iRet = Test1(oStructure1, oStructure2)
|