Web system uses EXE files to read hardware information such as MAC on client computers and is compatible with non IE browsers

  • 2021-01-02 21:48:43
  • OfStack

For the 1 general case, we probably use the ActiveX control method the most, but this scheme only works for the IE browser. In order to be compatible with different browsers, such as FireFox, we need to consider a more general approach. For this method, we can refer to "in many websites, there is a link somewhere on the page to launch QQ chat directly". This approach enables the Web system to invoke an exe file on the client computer (provided that the exe application to invoke must be installed on the client). The solution for QQ is to register a custom protocol in OS, such as: tencent://message/? uin=88888888 & Site=abc.com & Menu=yes.

You can enter the above address in the browser address bar, you can pop up 1 QQ chat dialog box, so that the Web system and the client's local exe application communication.

Through the above methods, we can refer to this scheme to achieve Web system to read the CLIENT computer Mac address, etc.

In order to achieve the above, we roughly need the following steps:

1. First, we need to create a table in the database, such as LoginTempInfo, whose fields are:

LoginID,MacAddress two fields will do.

2, set up an WindowsForm application (used to receive Web to login ID, then get the local Mac address, and Update to the background LoginTempInfo table). The main thing to note is that you pass one parameter, string[] args, into the main method main in class ES43en.cs.

The details are as follows:


 /// <summary>
  ///  The main entry point to the application. 
  /// </summary>
  [STAThread]
  static void Main(string[] args)
  {
   int argsLength = args.Length;
   MessageBox.Show(argsLength.ToString());
   Application.EnableVisualStyles();
   Application.SetCompatibleTextRenderingDefault(false);
   if (argsLength == 0)
   {
    Application.Run(new Form1());
   }
   else
   {
    MessageBox.Show(args[0]);
    Application.Run(new Form1(args[0]));
   }
  }

The above parameters are to receive the connection address in Web. In this address, we pass in 1 parameter to realize the passing of the parameters with exe.

3, we can add a connection address in the method window.onload in the login page Login.aspx of Web system, such as: helloworld://hello_world/Apara=abc001.

After the page is loaded, a unique LoginID is generated automatically, and the LoginID is inserted into table LoginTempInfo, at which time its MacAddress is empty.

A connection is then automatically executed: helloworld://hello_world/LoginID=**** (where **** * indicates the only one logged in to ID generated this time).

At this point, the local helloworld program is automatically called and the above: helloworld://hello_world/LoginID=**** is passed into the exe program.

Here, the Web program is paused for 2 seconds and implemented using the setTimeout method. After 2 seconds, the MAC address of the current login to ID is extracted from the data table (complete in step 4).

4, the local exe program receives the parameters: after only 1 login to ID, call 1 method to get the current client computer's MAC address, and put this MAC address Update into the data table LoginTempInfo, corresponding to the current login ID.

5. Through the above 5 steps, the Web system can obtain the CLIENT's MAC address for qualified verification.

In particular, when the client installs the exe program, the registry information under 1 must be registered synchronously:


Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\HelloWorld]
@="HelloWorld Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\HelloWorld\DefaultIcon]
@="E:\\HW_TEST\\HelloWorld.exe,1"
[HKEY_CLASSES_ROOT\HelloWorld\shell]
@=""
[HKEY_CLASSES_ROOT\HelloWorld\shell\open]
@=""
[HKEY_CLASSES_ROOT\HelloWorld\shell\open\command]
@="\"E:\\HW_TEST\\HelloWorld.exe\" \"%1\""

The attachment makes a simple example to realize the communication between Web system and local exe. (Note: The attachment is only a reference example)

Above, I just think of the more general Web system call client Mac address method. If you have a better way, please discuss it. thank you

Attachment to download address: https: / / www ofstack. com softs / 200002. html


Related articles: