Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Vc++6.0 invokes KvTcpipClientOcx controls

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "Vc++6.0 how to call KvTcpipClientOcx control", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "Vc++6.0 how to call KvTcpipClientOcx control" bar!

First, v0.2 ideas

Because I don't know how the data type in aardio corresponds to the parameter type of function call in ocx, I feel that it is futile to continue to use aardio, and even the login function call is not successful. Kingview's help document says that KvRealDBClient.exe is based on Vc++, so I can only turn to Vc++.

But VS IDE is really too big, and memory consumption, so install VM, install XP, install Vc+6.0 to build the development environment, it took a day or two, fortunately, no problem, ready to stack.

Will not Vc++, will not MFC, temporary cramming, while Baidu while watching the code, tired lumbago.

Second, Vc++6.0 test code

I think the feasible solution is to use the windows timing task to call exe,exe every few minutes to get real-time data and send it to the serial port, and then automatically end and exit, regardless of whether the receiver receives it or not.

The login and value test codes are as follows:

BOOL CMingdadataDlg::OnInitDialog () {CDialog::OnInitDialog (); / /.... Omit the code automatically generated by the editor LPCTSTR server_ip_address = "127.0.0.1"; unsigned short server_port = 41190; LPCTSTR user_name = "admin"; LPCTSTR user_password = "77887788"; / /: SysFreeString (bstr); CString dataStr = "# #"; CTime curTime = CTime::GetCurrentTime () DataStr + = curTime.Format ("% Y%m%d%H%M"); / / MessageBox (dataStr); / / attempt to log in short ret = m_kvtcpipserver.Method_LoginServer (server_ip_address, server_port, user_name, user_password); CString strTmp; strTmp.Format ("% d", ret); MessageBox ("Login?:" + strTmp) Unsigned short station_id = 0; unsigned long variable_id = 22; BSTR variable_value_string =: SysAllocString (L ""); short v_type = 3; / / get its value ret = m_kvtcpipserver.Method_GetVariableValueByVariableId (station_id,variable_id, & v_type, & variable_value_string) according to id StrTmp.Format ("% d", ret); MessageBox ("get data value ok?:" + strTmp); strTmp.ReleaseBuffer (); dataStr.ReleaseBuffer (); return TRUE; / / return TRUE unless you set the focus to a control}

Greate! Compiled into release version for testing.

Test it. Test it.

Congratulations on the successful login test.

After the little excitement came the merciless whipping.

First of all, I want to complain about Kingview, but you can't mei gei (qian) home. The default values of some parameters in the document interface are not given, such as the server_port parameter of the login interface. It's also easy to find one. I guessed by logging in to KvRealDBClient.exe and using the netstat command. Several ports appear one by one. Finally, it is determined that the server_port parameter value of KvTcpipClientOcx login interface Method_LoginServer is 41190.

Although the login is successful, it is always unsuccessful to use the ID of a variable to check the value, and changing all possible parameters is also unsuccessful, always returning 2 (failed to access the local library or the remote library). KvRealDBClient.exe can call the result, but I can't get it in Vc++. I wonder if there are other implicit parameters.

Thank you for your reading, the above is the content of "Vc++6.0 how to call KvTcpipClientOcx control". After the study of this article, I believe you have a deeper understanding of how Vc++6.0 calls KvTcpipClientOcx control, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report