引入WINAPI,异常“尝试读取或写入受保护的内存。这通常指示其他内存已损坏”
引入WINAPI,错误“尝试读取或写入受保护的内存。这通常指示其他内存已损坏”做的是软件二次开发,提供的DLL文
引入WINAPI,错误“尝试读取或写入受保护的内存。这通常指示其他内存已损坏”
做的是软件二次开发,提供的DLL文件本来是供C++二次开发用的,但我使用的编程软件是vb.net
dll文件函数手册(供C++使用的):
BOOL WINAPI VCASetVidCapDateTimeOSD( DWORD dwCard, BOOL bEnableOSD, POINT& ptTopLeft);
vb.net使用该DLL文件:
先将以上代码转为vb.net代码
Declare Function VCASetVidCapDateTimeOSD Lib "Sa7134Capture.dll" _
(ByVal dwCard As Long, ByVal bEnableOSD As Long, ByRef ptTopLeft As Point) As Boolean
调用函数:
Public OsdTimepoint As Point
OsdTimepoint.X = 10
OsdTimepoint.Y = 20
VCASetVidCapDateTimeOSD(0, 1, OsdTimepoint)
当执行到VCASetVidCapDateTimeOSD(0, 1, OsdTimepoint)就会出现错误“尝试读取或写入受保护的内存。这通常指示其他内存已损坏”。是不是ByRef和ByVal的问题,我将所有的ByVal换成ByRef的话,则VCASetVidCapDateTimeOSD的返回值为False,说明执行失败。
求大神指教啊!!! winapi
[解决办法]vb.net中long应该不能用了吧~~
[解决办法]structure mPoint
public x as integer
public y as integer
end Structure
Declare Function VCASetVidCapDateTimeOSD Lib "Sa7134Capture.dll" _
(ByVal dwCard As integer, ByVal bEnableOSD As bool, byval ptTopLeft As mPoint) As Boolean
Declare Function VCASetVidCapDateTimeOSD Lib "Sa7134Capture.dll" _
(ByVal dwCard As integer, ByVal bEnableOSD As bool, byref ptTopLeft As mPoint) As Boolean
都不行的话,尝试指定参数调用方法。