C # Development notes of small software (SaveClassic) -- (2) Data design, IE right-click menu to call the exe Function

Source: Internet
Author: User

 

First of all, thank you for your attention from so many friends. If you have so many friends, you will certainly be able to cope with the difficulties. Thank you again. Although there are a lot of similar software, it doesn't matter if I want to get something of my own at the beginning of the article. It's good to make something similar. I can refer to other people's, thank you for your attention.

What should I start with when I want to develop this small software? I decided to start with database design and development. Based on the simple and practical principle, I chose a small Access database. Although there are many small databases such as MSDE 2000, Embedded Firebird, SQLite, etc., they are easy to use and run at a fast speed, but I still like Access. Maybe it is more intuitive and easier.

In the old saying, in line with the simple and practical principle, I decided to only have a level-1 classification, and then the existing webpage information. Therefore, there are two tables in the database. One is the classification table DiaryType, and the other is the detailed content table DiaryList. The data structures of these two tables are also very simple.

Field name

Field Type

Remarks

ID

Automatic ID

 

TypeName

Text

Log category name

Table 1. DiaryType Data Structure

Field name

Field Type

Remarks

ID

Automatic ID

 

TitleName

Text

Log title

FileUrl

Text

Log File Storage path

TypeID

TypeID

Log category ID

CreateTime

Date/time

Creation Time

Table 2. DiaryList Data Structure

This is a simple and practical solution. I still want to run the entire process, and other function extensions should be easy.

Right-click ie and choose Save log from the shortcut menu. This function seems simple, but I am not familiar with how to implement the ie Plug-in. Finally, through analysis and development methods of Xunlei, the following operation methods are obtained.

This method first adds some data to the Registry. The location in the registry is HKEY_CURRENT_USER \ Software \ Microsoft \ Internet Explorer \ MenuExt. Haha, let's look at all the IE right-click menus, as shown in. Imitate them. I also add one in it. Step 2, rename it "Save log", and change the default value to an HTML page path, for example, c: \ GetHtml.htm. The purpose of this operation is to add the desired option in the shortcut menu of IE, and click this option to call the HTML page. Why not call exe directly? It doesn't seem to work. ie can only call HTML pages and support the scripting language. So I decided to use Javascript to call the exe file to implement my idea. So far, we can call the HTML page. Note: When the software is released, the registry modification function should be completed during packaging. However, to facilitate debugging, We can manually add this function.

Figure 1 right-click IE and choose custom menu registry option

Figure 2. Add a new entry to the Registry

Haha, it's a step. Let's start writing HTML pages. I named this page gethtml.htm. Let's take a look at the task he wants to complete.

1. First, you need to obtain the selected content of the current webpage. If no selection is made, you need to obtain the content of the entire webpage and the webpage title for your convenience.

2. Call the exe file and pass the data obtained above.

Let's take a look at the entire HTML page code, which will be explained in detail after the source code.

<Script type = "text/javascript">

Var titleappsexternal.menuarguments.doc ument. title;

// Obtain the webpage title

Var webURL = external.menuArguments.doc ument. domain;

// Obtain the primary domain name of the webpage

Var Content into external.menuarguments.document.selection.createrange().html Text;

// Obtain the selected content on the webpage

If (Content = "") // if the webpage is blank, the entire page body is retrieved.

{

Content Disposition external.menuarguments.doc ument. body. innerHTML;

}

Var SaveHTML = escape (Title + "$" + webURL + "$" + Content );

// Encode the obtained content to prevent encoding errors during information transmission.

// Save the following data to the file

Var fso, f, s;

Fso = new ActiveXObject ("Scripting. FileSystemObject ");

F = fso. OpenTextFile ("I: \ tempHtml.txt", 2, true );

F. WriteLine (SaveHTML );

F. Close ();

// The following method is to open the exe file www.2cto.com

Var a = new ActiveXObject ("Wscript. shell ");

A. run ("I: \ SaveTxt.exe ");

</Script>

Okay, our code has been compiled. Although I still have a lot of trouble with this code, because I am not familiar with this piece of code and cannot find a suitable tutorial. Specifically, javascript calls the exe file data transmission method. I first considered that calling exe to pass parameters, but I felt that there was a problem when there was too much data. Secondly, I considered the clipboard, however, I think how to deal with the image information on the webpage (friends who share the following information in this regard. Js image to the clipboard, c # Get data processing); finally, it is easy to use files to transmit data. This is today.

 

From zhaoyang

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.