您的位置:首页 > 编程语言 > VB

[VB.NET].net平台调用API问题

2008-12-27 22:16 330 查看



<script type="text/javascript"><!--
google_ad_client = "pub-8333940862668978";
/* 728x90, 创建于 08-11-30 */
google_ad_slot = "4485230109";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

.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, after de-compression, 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调用算了,这样转来转去多头痛
__________________________________________________________________________
说的没错,我真的被转晕了,平台调用时又出现很多问题
总提示错误“未将对象引用设置到对象的实例”
__________________________________________________________________________
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息