VB6.0用掲示板の過去のログ(No.2)−VBレスキュー(花ちゃん)
[記事リスト] [新規投稿] [新着記事] [ワード検索] [管理用]

投稿日: 2006/04/14(Fri) 13:01
投稿者morimori
Eメール
URL
タイトルRe^2: VC++で作成したDLLにユーザ定義型の配列を指定したい

とも様、KJ.K様
ご返答ありがとうございます。

確かにDLL側はダブルポインタにしなければいけませんね。
初歩的なミスで申し訳ございません。

> extern "C" int WINAPI EXPORT dllReceive(SAFEARRAY ** ppsa)
「SAFEARRAY」の型にしなければいけないのですか?
ということは、その後に型変換する必要があるということでしょうか?

お手数ですが、ご教授いただけると助かります。
宜しくお願いします。


> もし、
>
> > [VB側]
> > Private Type ReceiveInfo
> >     lNumber As Long
> >     cReceiveData As String * 100
> > End Type
> >
> > Private Declare Function dllReceive Lib "dllWinSock.dll"  _
> > (ByRef tReceiveData() As ReceiveInfo) As Long
>
> ならば、C側では、
> extern "C" int WINAPI EXPORT dllReceive(SAFEARRAY ** ppsa)
> という形式である必要があります。
>
> C側では
> > typedef struct{
> >     int  iNumber;
> >     char cReceiveData[100];
> > } ReceiveInfo;
> >
> > extern "C" int WINAPI EXPORT dllReceive(ReceiveInfo *tReceiveInfo)
>
> なのだから、
>
> Private Type ReceiveInfo
>     lNumber As Long
>     cReceiveData(0& To 99&) As Byte
> End Type
>
> Private Declare Function dllReceive Lib "dllWinSock.dll"  _
> (ByRef tReceiveData As ReceiveInfo) As Long
>
> Private Sub Command3_Click()
>     Dim i As Integer
>     Dim tReceiveData(0& To 19&) As ReceiveInfo
>    
>     dllReceive tReceiveData(0&)
>
>     Text2.Text = ""
>     For i = 0 To UBound(tReceiveData)
>         If tReceiveData(i).cReceiveData <> "" Then
>             Text2.Text = Text2.Text & tReceiveData(i).cReceiveData & ", "
>         End If
>     Next i
>    
> End Sub
>
> とでもするのでは。


- 関連一覧ツリー (★ をクリックするとツリー全体を一括表示します)

- 返信フォーム (この記事に返信する場合は下記フォームから投稿して下さい)

- VBレスキュー(花ちゃん) - - Web Forum -