| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3136 人关注过本帖
标题:使用C#开发 调用电子秤com端口 将数据插入到ie的textbox中 控件ActiveX插件
只看楼主 加入收藏
HenryBerlin
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-8-11
收藏
 问题点数:0 回复次数:0 
使用C#开发 调用电子秤com端口 将数据插入到ie的textbox中 控件ActiveX插件
How to get started with developing Internet Explorer extensions?

http://
http://blog. C# ActiveX控件开发  
http://bbs.  ActiveX安全性
http://www.  有没有人会用API来编写串口通讯的
Connecting to a client pc's serial port from the Web Server
https://social.msdn.

description:
I have a web application that reads weight from the scale and display weight on the text box, I have works well on my laptop. However the serve doesn't see the scale after deploying the web site. The server is looking at the local com port not at the client's.
please help with the code to direct the serve to the client's com port not the local com port.

Yes I am referencing the serial port in the Web application and using a C# code like this:

using
SerialPort _serialPort;
//Change COM port number
            portNumber = COMDownList.Text;
            ///<summary>
            ///Create a com port, set it's variables and open it
            ///</summary>
            _serialPort = new SerialPort(portNumber, 9600, Parity.None, 8, StopBits.One);
            _serialPort.Handshake = Handshake.None;
           
            _serialPort.ReadTimeout = 500;
            _serialPort.WriteTimeout = 500;
            _serialPort.RtsEnable = true;
            _serialPort.Open();
            string data = _serialPort.ReadLine().Trim();
            string temp = data.Replace(" kg", "");
            Convert.ToDouble(temp);
            WeightTextBox.Text = temp.ToString();
            _serialPort.Close();


Sign in to vote
And the magic trick IS !!!
After one week and several hundred compile roundtrips ....
Drum roll ....
[SuppressUnmanagedCodeSecurityAttribute()]
put this in the namespace of the class that you are calling from the web page.
Then do a
SecurityPermission sx = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
               
sx.Assert();
you can then access the serial port on the client machine from the browser.
Typical code being ;
  serialPort1.PortName = "COM6";
                serialPort1.BaudRate = 2400;
                serialPort1.Parity =
                serialPort1.DataBits = 7;
                serialPort1.StopBits =
                serialPort1.Open();
                serialPort1.ReadExisting();
thanks to all who answered my various posts.
PatC


    accessing serial port from web page
  


How to use the AllowPartiallyTrustedCallers attribute to call an assembly that has a strong name from a Web page by using Visual C# .NET, Visual C# 2005 or later versions
https://support.  发布网站

Ahead in what areas
Unexpected delays or issues
Related Documents
USB Devices
https://developer.
http://www. POS SERIAL RS-232 DRIVERS -- BASIC INSTALLATION AND TEST KIT
SERIALPORT (RS-232 SERIAL COM PORT) IN C# .NET
http://blogs.  
 
Budget   http://www.

怎样让IE认为你的对象安全
    实现了这个接口,剩下的事情就很简单了。前面提到过如果按照正规的途径你需要确保你的代码没有访问系统的本地自然,然后按照文档要求,当该对象被不同的接口调用查询的时候,做不同的反馈。具体实现可以在MSDN的Sample中找到。
    当然我们可以写一个对象读写本地文件,但是支持IObjectSafety接口,并且始终声明自己是合法的,这样来欺骗浏览器,那么代码就很简单了,如下:
  // implement functions of IObjectSafety
  public void GetInterfacceSafyOptions(System.Int32 riid,out System.Int32 pdwSupportedOptions,out System.Int32 pdwEnabledOptions)
  {
   pdwSupportedOptions = CLsObjectSafety.INTERFACESAFE_FOR_UNTRUSTED_CALLER;
   pdwEnabledOptions = CLsObjectSafety.INTERFACESAFE_FOR_UNTRUSTED_DATA;
  }
  public void SetInterfaceSafetyOptions(System.Int32 riid,System.Int32 dwOptionsSetMask,System.Int32 dwEnabledOptions)
  {
  }

来源: http://blog.

How to display weight from weighing scale into a textbox via serial port RS-232 or usb converter?

http://  

How can a web page read from the user's serial port? [duplicate]

http://
搜索更多相关主题的帖子: Internet Explorer started 控件开发 电子秤 
2016-08-11 14:02
快速回复:使用C#开发 调用电子秤com端口 将数据插入到ie的textbox中 控件Active ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017910 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved