我在VC里写一个标准的DLL向VB提供一些绘图操作。
void __stdcall Gradient(COLORREF cr1,COLORREF cr2,UINT uSteps,crs)
~~~
我想通过参数crs向VB返回一个Byte数组,请问crs该用什么样的类型,在VB中我又该怎么声明呢?
void __stdcall Gradient(COLORREF cr1,COLORREF cr2,UINT uSteps,crs)
~~~
我想通过参数crs向VB返回一个Byte数组,请问crs该用什么样的类型,在VB中我又该怎么声明呢?
VB: Gradient(...,...,..., ref Crs as BYTE)
~~~表示指针
呵呵,肯定是用指针了。
void __stdcall test(BYTE* xx)
{
BYTE cr[10];
int i;
for(i=0;i<=10;i++)
cr[i]=i;
xx=&cr[0];}
Private Declare Sub test Lib "J:\Artemis\Program\Standard DLLs\Graphics\Debug\graphics.dll" (ByRef xx As Byte)
Private Sub Form_Load()
Dim i() As Byte
test i
End Sub
:(,ByRef 参数类型不符。
然后我换成:
Private Sub Form_Load()
Dim i(10) As Byte
test i(0)
End Sub
数组里面的元素根本没有被赋值。:(,该怎么做才好啊??
xx=&cr[0];
换成
memcpy(xx,&cr[0],sizeof(cr));
这样就好了。呵呵~~~~~~~~