海康的SDK 不出图像,不抱错,搞过的能否指点下.
void __fastcall TForm2::Button6Click(TObject *Sender)
{
LONG lUserID = -1;
NET_DVR_DEVICEINFO_V30 struDeviceInfo;
memset(&struDeviceInfo, 0, sizeof(NET_DVR_DEVICEINFO_V30));
char *sDVRIP;
WORD wDVRPort;
char *sUserName;
char *sPassword;
long int Erri;
BOOL bMsgBox;
//
AnsiString str1,str2,str3;
char * data1;
str1=Edit1->Text;
data1=str1.c_str();
sDVRIP=Edit1->Text.t_str();
wDVRPort=Edit2->Text.Trim().ToInt();
str2=Edit3->Text.Trim();
sUserName=str2.c_str();
str3=Edit4->Text.Trim();
sPassword=str3.c_str();
if(NET_DVR_Init())
{
Memo1->Lines->Add("SDK初始化成功");
}
else
{
Memo1->Lines->Add("SDK初始化失败");
}
//lUserID = NET_DVR_Login_V30(g_struDeviceInfo[iDeviceIndex].chDeviceIP, (WORD)g_struDeviceInfo[iDeviceIndex].lDevicePort,\
//g_struDeviceInfo[iDeviceIndex].chLoginUserName, g_struDeviceInfo[iDeviceIndex].chLoginPwd, &struDeviceInfo);
//设置连接时间与重连时间
NET_DVR_SetConnectTime(2000, 1);
NET_DVR_SetReconnect(10000, true);
//---------------------------------------
// 注册设备
lUserID=NET_DVR_Login_V30(data1, wDVRPort,sUserName, sPassword, &struDeviceInfo);
if (lUserID < 0)
{
Erri=NET_DVR_GetLastError();
if (Erri == NET_DVR_PASSWORD_ERROR)
{
Memo1->Lines->Add("用户名密码错误!user name or password error!");
}
else
{
Memo1->Lines->Add( "由于网络原因或DVR忙, 注册失败!net error or dvr is busy!"+IntToStr(int(Erri)));
}
// NET_DVR_Cleanup();
//return;
//return FALSE;
}
else
{
Memo1->Lines->Add( "注册成功!"+IntToStr(int(Erri)));
}
// plVedioWin->Handle ;
//设置异常消息回调函数
NET_DVR_SetExceptionCallBack_V30(0, NULL,g_ExceptionCallBack, NULL);
//---------------------------------------
//启动预览并设置回调数据流
LONG lRealPlayHandle;
// HWND hWnd = GetConsoleWindow(); //获取窗口句柄
HWND hWnd=plVedioWin->Handle;
NET_DVR_CLIENTINFO ClientInfo = {0};
ClientInfo.hPlayWnd = hWnd; //需要SDK解码时句柄设为有效值,仅取流不解码时可设为空
ClientInfo.lChannel = 1; //预览通道号
ClientInfo.lLinkMode = 0; //最高位(31)为0表示主码流,为1表示子码流0~30位表示连接方式:0-TCP方式;1-UDP方式;2-多播方式;3-RTP方式;
ClientInfo.sMultiCastIP = NULL; //多播地址,需要多播预览时配置
BOOL bPreviewBlock = false; //请求码流过程是否阻塞,0:否,1:是
lRealPlayHandle = NET_DVR_RealPlay_V30(lUserID, &ClientInfo, NULL, NULL, 0);
if (lRealPlayHandle < 0)
{
Memo1->Lines->Add("NET_DVR_RealPlay_V30 error\n");
NET_DVR_Logout(lUserID);
NET_DVR_Cleanup();
//return;
}
Memo1->Lines->Add( "h回放!"+IntToStr(int(lRealPlayHandle)));
}
[解决办法]
这个SDK不止某个DLL吧,可能有些还要注册才行。
[解决办法]
GetConsoleWindow