Passing parameters to activex controls using javascript

Source: Internet
Author: User

If you encounter problems at ordinary times, record them here. Make a record for yourself and refer to users who encounter similar problems.

When using javascript to call activex controls, I need to pass a string to the activex control. Now I have encountered a strange problem. Printing in javascript is correct, but it is not correct in activex control.

If you directly pay the char * type in the activex control, there is no problem. It is suspected that the parameter conversion is incorrect during data transfer. The conversion is indeed incorrect after verification. This involves a type of LPCTSTR.

Since I have been developing in linux, I am really not familiar with the LPCTSTR. Later I checked the definition and found that the comment in it was a 16-bit UNICODE character. It seems that the conversion is incorrect. What my program in activex control needs is char *

It is an 8-bit width. This is definitely not the case. Fortunately, many people have encountered similar problems on the Internet, but the answers are mixed. The verified items are provided here:

Let's assume that rtsp_URL is the type of LPCTSTR transmitted by javascript.
DWORD tmp_len = WideCharToMultiByte (CP_OEMCP, NULL, rtsp_URL,-1, NULL, 0, NULL, FALSE );
StreamURL = (char *) malloc (tmp_len );
WideCharToMultiByte (CP_OEMCP, NULL, rtsp_URL,-1, streamURL, tmp_len, NULL, FALSE );

StreamURL is of the char * type.


Author: huguohu2006

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.