前端之家收集整理的这篇文章主要介绍了
[VB.NET].net平台调用API问题,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
.net平台
调用API问题 在vb.net下,如何为API
函数使用的数据结构中的字符串分配指定的大小 __________________________________________________________________________ 和以往VB是一样的阿 __________________________________________________________________________ Dim s As New String( " ",10) __________________________________________________________________________ < MarshalAs( UnmanagedType.ByValTStr,SizeConst := 128 )> _ Public versionString As String __________________________________________________________________________ 不是固定大小,并且要求字符串的
内容可变 __________________________________________________________________________ ?? 没听明白 __________________________________________________________________________ versionString长度是可变的,在程序中分配大小,而且规定中说string类型的变量
内容好象是不能改变的 __________________________________________________________________________
调用dll 参数主要要符合dll的要求, 另外你的.net
调用dll需要封送,只是传给dll参数,在传之前变不变有什么关系, 贴出你的dll引出
函数的声明, __________________________________________________________________________ // Decode Frame,call it to decode a complete YUV Frame. // This is the main function of the Decoder SDK // The pFrameYuv must be allocated by the user,except if motion parser Flag is set to 0. DLL_API int SdkSsnDecDecodeStream(SdkDec_t *pSdkDec,FrameDec_t *pFrameYuv); 该
函数需要的回调
函数是 // GetPacket CallBack: The user shall define this function. // The Smartsight Decoder will call it when it request bytes. // RETURN: The number of bytes in the Packet or -1 to attemp a close of the decoder. typedef int (*pGETPACKET_CB)( void *pContext,// User Context unsigned char **ppBufAdr); // Output Var: Address of the packet to read __________________________________________________________________________ SdkDec_t *pSdkDec,FrameDec_t *pFrameYuv
自定义的结构?? __________________________________________________________________________ 需要自己定义,其中FrameDec_t中包含有三个*char类型的数据,在
调用该
函数之前要对其进行内存分配 __________________________________________________________________________ 数据类型要做一下调整,具体参照变量类型表 __________________________________________________________________________ 如何调整呢,结构如下 // Frame Structure to retrieve all the info about a frame,// before and after decompression // The user shall fill a part of this structure before giving it to the encoer typedef struct FrameDec_s { unsigned char *pY; // Pointer to the visible Y-Plane unsigned char *pU; // Pointer to the visible U-Plane unsigned char *pV; // Pointer to the visible V-Plane unsigned long FieldOverField; // 1 if the frame is store Field over Field // Useful for buffers with sizes > 288 only. unsigned long FrameType; // I,P or B unsigned long TimeRef; // Time reference (8 bits) unsigned long TimeIncre; // Vop Time Increment in tick units unsigned long YStride; // Y Stride of the allocated buffer unsigned long UVStride; // UV Stride of the allocated buffer unsigned long YBufHeight; // Y Height of the allocated buffer unsigned long BufferSize; // Size of the Y plane (As allocate by user),before compression unsigned long Height; // Height of the Frame,after de-compression,real Height unsigned long Width; // Width of the Frame,real Width unsigned long MeanQuant; // Mean Quantizer decoded void *pUserInfo; // Pointer to a user info,if
required } FrameDec_t; __________________________________________________________________________
代码太长,问题不明,不好直接回答建议可那看这片帮助 ms-help://MS.MSDNQTR.2003FEB.2052/cpguide/html/cpconmarshalingclassesstructuresunions.htm __________________________________________________________________________ 还是谢谢了,我的问题实在太多.. __________________________________________________________________________ 其实一句话概括,结构中的字符串如何分配内存 __________________________________________________________________________ unsigned char *pY; // Pointer to the visible Y-Plane unsigned char *pU; // Pointer to the visible U-Plane unsigned char *pV; // Pointer to 这三个参数可以试试stringbuilder __________________________________________________________________________ 字符串是结构的有效成员;但是,StringBuilder 缓冲区在结构中是无效的。 是什么意思 __________________________________________________________________________ lz与到这种事情还不如用C++.net写个dll然后让vb
调用算了,这样转来转去多头痛 __________________________________________________________________________ 说的没错,我真的被转晕了,平台
调用时又出现很多问题 总
提示错误“未将对象引用设置到对象的实例” __________________________________________________________________________
原文链接:https://www.f2er.com/vb/263912.html