For the most part, it is possible to use the ActiveX control method, but this scenario applies only to IE browsers. In order to be compatible with different browsers, such as Firefox, we need to consider a more general approach. This method we can refer to "in many sites, will be in a page somewhere to a link to directly start QQ to chat." This method enables the Web system to invoke an EXE file on the client computer (provided that the required EXE application must be installed on the client). QQ solution is to use the OS to register a custom protocol, such as: Tencent://message/?uin=88888888&site=abc.com&menu=yes.
You can enter the address bar in the browser above address, you can pop up a QQ chat dialog box, which is to achieve the Web system and client-side EXE application communication.
Through the above methods, we can refer to this scheme to achieve the web system read to the client computer MAC address.
In order to achieve the above, we probably need the following steps:
1, first of all, we need to create a table in the database, such as: Logintempinfo, its fields are:
Loginid,macaddress two fields is OK.
2, create a windowsform application (used to receive the Web login ID, then get the local MAC address and update to the Logintempinfo table in the background). The main point to note is: In the class Program.cs in the main method main methods passed a parameter, string[] args.
Specifically as follows:
<summary>
///application's main entry point.
///</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 parameter is in order to receive the connection address in the Web, in this address we pass some parameters, to realize with the EXE parameter transmission.
3, we can add a connection address in the Window.onload method in the Web System login page login.aspx, such as: helloworld://hello_world/apara=abc001.
After the page is loaded, a unique loginID is automatically generated, and the loginID is inserted into the table Logintempinfo, at which point the MACAddress is empty.
And then automatically perform a connection: helloworld://hello_world/loginid=**** (WHERE * * * represents the unique login ID for this generation).
At this point, the local HelloWorld program is automatically invoked and the above: helloworld://hello_world/loginid=**** is passed into the EXE program.
Here, the Web program pauses for 2 seconds, uses the SetTimeout method to implement, 2 seconds later, and then removes the MAC address of the current login ID from the datasheet (completed in step Fourth).
4, local EXE program received the parameter: Unique login ID, call a method to obtain the current client computer MAC address, and the MAC address update to datasheet logintempinfo, corresponding to the current login ID.
5, through the above 5 steps, can realize the Web system obtains the client's MAC address to do the qualification verification.
Note that the client must register the registry information synchronously when installing the EXE program:
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 does a simple example to implement the communication between the Web system and the local EXE. (Note: The attachment is just a reference example)
Above, just the way I think of the comparison of common Web system calls to client MAC addresses. If there is a better way to do this, we welcome the discussion. Thank you.
Attachment Download Address: http://www.jb51.net/softs/200002.html