投稿日 | : 2006/04/14(Fri) 17:00 |
投稿者 | : morimori |
Eメール | : |
URL | : |
タイトル | : Re^3: VC++で作成したDLLにユーザ定義型の配列を指定したい |
Blue様、K.J.K様
ご返答ありがとうございます。
> ついでにここも参考にしてください。(↓は結構詳しく解説したつもりです)
> hhttp://c-chat.net/modules/newbb/viewtopic.php?topic_id=309&forum=2&noreadjump=1Blue様の参考
ページなどを見ており、そう簡単にはいかないのだなと
思いました。
いろいろ試してはいるのですが、なかなかうまくいっていないというのが現状です。
現状のソースを提示しますのでご教授いただければと思います。
[VB側]
Private Type ReceiveInfo
cReceiveData(100) 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 j As Integer
Dim cBuf As String
Dim tReceiveData(20) As ReceiveInfo
dllReceive tReceiveData()
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
[VC側]
extern "C" int WINAPI EXPORT dllReadFindUid(char *pcIpAddress, LPSAFEARRAY *ppsa)
{
long i;
SAFEARRAY *psa = *ppsa;
ReceiveInfo tReceiveInfo;
AFX_MANAGE_STATE(AfxGetStaticModuleState());
SafeArrayLock( psa );
g_iReceiveCnt = 1;
for(i=0;i<g_iReceiveCnt;i++){
SafeArrayGetElement(psa, &i, &tReceiveInfo);
strcpy(tReceiveInfo.cReceiveData, g_cReceiveData[i]);
strcpy(g_cReceiveData[i], "");
SafeArrayPutElement(psa, &i, &tReceiveInfo);
}
g_iReceiveCnt = 0;
SafeArrayUnlock( psa );
return 0;
}