VB6 ActiveX Controls in a C#/ASP.NET Based Website
We have a website that is based on C# and ASP.NET, I have a barcode scanner with a .dll file to control it that I can get to 开发者_高级运维work in VB6. Before I dig deeper in exactly how to do this I wanted a quick answer on if it is even possible to do what I want first.
Can I write an activex control in VB6 that will allow me to control the barcode scanner and implement that activex control in our .NET based website?
Just to be clear, not asking HOW to do it, just asking if it can be done. I haven't done any ActiveX programming before and haven't touched VB6 in a long time.
Thanks!
I believe it should be possible; but you will probably need to implement it with JavaScript and ActiveX objects. This will require that the user's browser is setup to allow your web site to interact with ActiveX objects. A simple example of this, is using a link to start a program (like remote desktop client):
<script type="text/javascript">
function runMstsc() {
var command="mstsc.exe /v:127.0.0.1 /w:1024 /h:768";
var scriptHost = new ActiveXObject("WScript.Shell");
scriptHost.run(File);
}
</script>
Assuming that your application is a valid ActiveX control, you should be able to minipulate it in a similar fashion to WScript.Shell.
ActiveX controls are client-side components installed on the user's machine. They are then hosted inside the browser. So yes, if the scanner is hooked up to a client machine you could access it via the ActiveX control. You would then have to use some assortment of AJAX/XML/JavaScript to send the data back to the server.
Most users are going to see fearsome security warnings because their browser distrusts your ActiveX control. If anything detects the control using a device driver, I think the security warnings will go nuclear.
Have you considered staying with a separate desktop application, communicating with the website via web services? You could use ClickOnce deployment so that the user doesn't have to run an install or login as administrator.
- It could be a C# application using the DLL via COM interop.
- Or it could be a VB6 application deployed via ClickOnce and using registry-free COM.
精彩评论