有一段vc程序做成了DLL.我想把里面处理完毕的结果返回到vb里面,(处理完的结果存储在结构体里)。我返回结构体指针,可是在vb里返回的值不对。代码如下,大家帮忙分析一下呀。 vc程序: #include <windows.h> #include<iostream.h> struct mfs { long int fset; int mcw[5]; } extern "C"_declspec(dllexport) struct mfs *_stdcall GetDataPoint(); int struct mfs *_stdcall GetDataPoint() { struct mfs mf; struct mfs *m; mf.mcw[0]=1; mf.mcw[1]=2; mf.mcw[2]=3; mf.mcw[3]=4; mf.mcw[4]=5; mf.fset =10; m=&mf; return (m ); } vb里面: Option Explicit Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Private Declare Function GetDataPoint Lib "MyDLL.dll" () As Long
Private Sub Command1_Click() Dim mf As mfs Dim mfPoint as long
mfPoint=GetDataPoint() CopyMemory mf, mfPoint, Len(mf) Text2.Text = mf.fset End Sub 其中的mfs定义在模块中: Type mfs mcw(5) As Long fset As Long End Type