Automatic Internet accessing data robot (reproduced)

zhaozj2021-02-17  80

In most cases, the online surfing is a pleasant thing. But if hundreds of thousands of hyperlinks are placed in front of you, and you have to click on these links, enter the corresponding web page, manually filter out the information you need per page, and finally enhance this information into the database , ...., what will you do? If you do this, you will not let you go crazy every day? "Automatic Internet Robot" may save you "bitter sea": You can drink coffee, listen to music, watch "robot" hard You work, that feels are not great! This paper combines examples to discuss technical details with VB to implement "Internet Robots" with VB. We know that collecting and downloading information is one of the most important purposes using the Internet, but some information resources are too large, and it is difficult to use manual approach or not. For example, you need to collect company directory of European imported mechanical equipment to send them to invite them to participate in the fair. It is not difficult to find this information online, but for the consideration of data security, almost all websites that provide similar information are available. Provides direct download data. To collect the data you want, the only way to use is a page to browse the information page for each company, take the data in which the data is useful and stored in the database. But when the total number of companies exceeds thousands, huge workload will make any people look! In fact, this vast work can be done by the program because these tasks are completely mechanical repetitive work. Moreover, the use of procedures is much more faster than manual. The technical details involved in this paper are common, that is, any "automatic Internet surf" task can be completed for the instance program.

Automatic dial-up Internet access, automatic processing from the middle, and automatically hang after the task is completed, these are one of the most basic functions of "Internet Robots". It can also bring you obvious economic return: If you let "Robot" to dial online to automatically surf the Internet in the evening to the morning fee, it can be called a typical "one stone three bird" - - You sleep, it works, save money! Details of this will be discussed in the third part of this article. This section provides several methods for achieving the above functions, and comparing the respective advantages and disadvantages of these methods.

The first and second parts of this paper discusses the automatic browsing technical details in two instances: automatically fill in data in the input area on the web page to complete the operation such as user login, etc., automatically update Checkbox, automatically select the drop-down list (ComboBox), automatically click on the button on the web page, accurately extract the useful data from the web page, extract them out and convert the data on the two-dimensional table (Table) on the web page and store it directly into the database or Excel's format, and techniques for controlling the browsing process.

The first part accurately extracts data from the web page

The instance of this section is: Download the basic information and financial data of all about 1100 stocks in Shanghai and Shenzhen. If manual operation, as shown in the figure above, you need to enter 1100 stock codes in the stock code area. Select "stock information" and "financial data interpretation" in the drop-down list (ComboBox), calculating about 2200 times operating! This kind of work is of course much more cost-effective by the program. Moreover, hand-extracted data (first selected, use Ctrl C copy) Extremely easy error (multiple choice or leaking), which is very eye-catching.

1. Automatically fill in the input area

To enable the program to automatically browse, you need to introduce some of the most basic functions, such as automatically fill in data, automatically click on the button in the input area. Although the method of transforming the URL address can sometimes complete the task, it is often too laborious, especially when the input area on the web is more.

In order to input data in the input area, you need to search first of the name of the object, and then place the value of the object to be filled. The search name is programmable and can be easily obtained with FrontPage.

2. Automatically choose in the pull-down list (ComboBox)

Similarly, first get the name of the drop-down list. Then, according to the total number of elements of the drop-down list (Length attribute), search for the value to be set in the list (the TEXT attribute of the element in the Options collection of the list), and then set the element to the selected element (element's SELECTED attribute). 3. Automatically click on the button

For the button, you can access it according to its name, or you can access it according to its value. The value of the button is the text displayed on the button. A button may have no name, but must have a value. The program of this example is the access button based on the value. The Click method of the execution button is equivalent to clicking the button.

The red arrow in Figure 2 is automatically filled with the input box for the program to automatically click on the button in ComboBox.

4. Accurate extraction data

It is meaningful to use only useful data storage. The web page must be studied to find the TAG zone (available text editor or frontPage) in the valid data, and then use the object's INNERTEXT attribute to get the final text. The data to be stored in this example is shown in the following figure, and the TAG used is "pre".

The following is the full code of the instance program:

'Program 1: From the web page, extract data' 'to run this program, add "Microsoft Internet Controls" in "Menu -> Enginee -> Part" and add "Menu -> Project -> Reference" Microsoft HTML Object Library " '' sake of brevity, only the download program basic information Option ExplicitPrivate nine stocks Const form_ID = 1Dim Code (9) As StringDim Current As LongPrivate Sub Form_Load () Form1.MousePointer = 11 'is the code for the stocks' order The program is simple, only nine code is used here. 'And in a real environment, you should read all stock code from the data file.

Code (0) = "600001": Code (1) = "600002": Code (2) = "600003" Code (3) = "600005": Code (4) = "600006": Code (5) = " 600007 "Code (6) =" 600008 ": code (7) =" 600009 ": code (8) =" 600010 "current = 0 Webbrowser1.navigate" www.stockstar.com.cn "'start URL End Subprivate SUB WebBrowser1_DocumentComplete (ByValpDisp As Object, URL As Variant) Dim i, k Text2 = WebBrowser1.LocationURL 'displays the current URL' determines whether the current page is completed all transferred to if Not (pDisp Is WebBrowser1.Object) Then Exit Sub On Error Resume Next Select Case Text2 case "http://www.stockstar.com.cn/home.htm" 'When entering the main page, do the following program for i = 0 to webbrowser1.document.forms (form_id) .length - 1' Find the code input box After filling into the stock code if WebBrowser1.document.form (i) .name = "code" then _ webbrowser1.document.forms (form_id) (i) .Value = code (current) 'in the drop-down list Select IF WebBrowser1.Document.Forms (Form_ID) (i) .Name = "Target" the fork = 0 to webbrowser1.document.forms (form_id) (i) .length - 1 if WebBrowser1.Document.forms (form_id) (Form_ID) i) .Options (k) .t EXT _ = "stock materials" THEN WebBrowser1.document.forms (form_id) (i) .Options (k) .selected = true exit for end if next k endiff 'click button if Webbrowser1.document.form (Form_ID) (i ) .Value = "query" THEN _WORM_ID) (i) .Click next case else 'When entering the data page for i = 0 to webbrowser1.document.all.length - 1 IF WebBrowser1 .Document.all (i) .tagname = "pre" then "precise extraction data text1 =

TEXT1 CODE (CURRENT) VBCRLF _WEBBROWSER1.Document.all (i) .innertext VBCRLF EXIT for end if Next 'data save open "c: /data2.txt" for append as # 1 print # 1, text1: Text1 = "": Close # 1 'Changes to a Stock Current = CURRENT 1 if current> = 9 TEN' After the Internet task is completed, the automatic hanging process should be called. Form1.MousePointer = 0: MsgBox "finished!": End End if 'rolls back to the main page, query the next stock WebBrowser1.goback End SelectenD Sub Part 2 imported two-dimensional table on the web page into the database

In the previous part, we discussed the ways to make the program automatically browse online and store the required data. Now, we will meet more challenges: extract the two-dimensional data existing on the form of table form, and store the "Microsoft Excel comma divider file" (ie .csv file) that can be directly imported into the database.

It is very difficult to extract the table data shown in the figure in the web page. If such a table has a few pages or even hundreds of sheets, manual extraction will be unimaginable, and it is very easy to make mistakes.

The instance of this section is to quickly and accurately convert to ".csv" files in the "204 pages of 54 pages, 20 pages, as shown above).

1. Automatically set Checkbox value

Since only registered users can access the financial score sheets described above, the instance program first demonstrates the function of automatic registration. The figure below shows the screen before registration and the automatically registered screen.

We have discussed the method of automatically filling in the input area and automatically click on the button in the previous part. For automatic setting checkbox values, the method is completely similar: First click on the name of the Checkbox, then set the check attribute of the object to true or false.

2. Import two-dimensional table on the web into the database

First define a IHTMLELEMENTCOLLECTION object to collect all TABLE on the web, then use the getElementsByTagname method to perform the collection work:

DIM Tables AsiHtmlelementCollection set tables = webbrowser1.document.getlementsBytagname ("Table")

There are often multiple tables on a web page. We use the HTMLTable object to handle each table:

DIM TABLE1 ASHTMLTABLE for Each Table1 in Tables Next

The INNERTEXT attribute of the HTMLTable object records all the information of the entire Table, including the field name. So we can determine which Table is what we need according to the field name.

In order to extract data one by one, we also need HTMLTableRow objects and HTMLTableCell objects:

DIM ROW ASHTMLTABLEROW, CELL AS HTMLTABLECELL for i = 1 to Table1.Rows.Length - 1 'progressive processing set row = Table1.Rows (i) j = 0 for Each Cell in row.cells' list-by-one (j) innertext is the current line and the unit data on the current column text1 = text1 trim (row.cells (j) .innerText) "," J = J 1 Next 'is over the line Commerges and plus the carriage return Text1 = left (Text1, Len (Text1) - 1) VBCRLF next to this, the two-dimensional table on the current web page has been converted to ".csv" format.

3. Page control skills when you automatically browse

From the previous example, we have clearly seen that the main body of the automatic browse program is the DocumentComplete event for the webbrowser control. Only after the current page has been fully transferred, we can start data processing on the current page, and then determine the next browsing direction based on which page is currently currently.

It should be noted that the occurrence of the DocumentComplete event does not necessarily mean that the current page has been all tuned. If there is no other subframe (frames) on the page, the DocumentComplete event has shown that the current page (ie, the main frame) has been completed; if there are multiple frames on the page, the DocumentComplete event occurs when each framework is completed; when all children After the framework is complete, the main frame finally produces a DocumentComplete event. In order to determine this last DocumentComplete event, it is necessary to compare whether the object (PDISP) when each event occurs is a webbrowser control object itself:

Private Sub WebBrowser1_DocumentComplete (Byvalpdisp As Object, _ URL As Variant) IF (PDISP IS Webbrowser1.Object) Then Debug.print "Document IS Finished Loading." End if End Sub

Below is the full code of the example program (running the program to get the full 1061 line ".csv" format data, representing 1061 listed companies' financial information. This file can be directly imported into the Access database or Excel.):

'Program 2: Import the two-dimensional table on the page to the "Menu -> Enginee"' and in the "Menu -> Project -> Quote" in Menu -> Enginee -> Parts. add "Microsoft HTML Object Library" 'Option ExplicitDim Page As LongPrivate Sub Form_Load () Form1.MousePointer = 11WebBrowser1.Navigate "www.stockstar.com.cn"' start URL End SubPrivate Sub WebBrowser1_DocumentComplete (ByVal pDisp As Object, URL As Variant) Dim Table1 As HTMLTable, Tables As IHTMLElementCollectionDim Row As HTMLTableRow, Cell As HTMLTableCellDim i, j, tmpText2 = WebBrowser1.LocationURL 'displays the current URL' determines whether the current page is completed all transferred to if Not (pDisp Is WebBrowser1.Object) Then Exit Subon Error Resume NextSelect Case Text2case "http://www.stockstar.com.cn/home.htm" 'When entering the main page, perform the following program' User registration login for i = 0 to webbrowser1.document.forms (0). LENGTH - 1 'After finding Checkbox, change its value to false to prevent username and password from being stored if WebBBrowser1.Document.forms (0) (i) .name = "checksavepw" " (i) .checked = falseif webbrowser1.document.forms (0) (i) .Name = "userid" the _WebBbrowser1.document.forms (0) (i) .value = "kompass_china" if WebBBRowser1.do CUMENT.FORMS (0) (i) .Name = "Passwd" the _WebbBrowser1.document.forms (0) (i) .Value = "kompass1" here is the name access button (in the previous example is the value access button ) If WebBrowser1.document.forms (0) (i) .Name = "Continue" Then _WebbBBrowser1.document.forms (0) (i) .ClickNextcase "http://my.stockstar.com/scripts/mystockstar.dll? Login "'When the user is logged in, the first page of the table is ready to open the table WebBrowser1.navigate" http://finance.stockstar.com/scripts/finance.dll? " _" Showstkdfpm & begin = 0 & ret = 1 & index = 2 & concode = 01 " Page = 1case else 'When entering the data page (

When the first page of the table is the last page, perform the following program set tables = webbrowser1.document.getlementsBytagname ("table") for each table1 in table, 2) = "name" TEN 'found required TABLE 'Convert form into ".csv" format for i = 1 to Table1.Rows.Length - 1SET ROW = Table1.Rows (i) j = 0for Each Cell in row.cellstext1 = text1 trim (row.cells (j) .innertext) "," J = J 1NEXTTEXT1 = Left (Text1, Len (Text1) - 1) VBCRLFNEXT 'Data Storage Open "C: /Data.csv" for append as # 1print # 1, Left (Text1, LEN (Text1) - 2): Text1 = "": Close # 1exit forends ifnext 'Ready to open Next Page = Page 1TMP = "http://finance.stockstar.com/scripts/finance.dll?showstkdfpm&ret=" _TRIM (STR (PAGE) "& INDEX = 2 & concode = 01" if Page <= 54 THEN 'Judging whether to browse the end WebBrowser1.navigate TMPELSE' Internet task is completed, the automatic hanging process should be called. Form1.MousePointer = 0msGBox "finished !!": Endend IFEND SELECTEND SUB The following segment is given below the data file stored in the above program:

1, Le Kay film, 600135, material, 81.493, 18.445, 23.165, 8.850, 20.717, 10.3152, Songhua Wire, 600037, Communication Entertainment, 80.553, 13.009, 22.256, 12.141, 20.304, 12.8443, foreign transportation, 600270, warehouse transportation , 80.326, 17.331, 23.005, 8.829, 19.900, 11.2614, Oriental Niobium, 0962, Non-ferrous metals, 80.312, 15.160, 22.483, 11.648, 21.290, 9.7305, Shuanghui Development, 0895, Food, 79.772, 15.428, 20.673, 11.508, 20.235 , 11.9306, Sichuan Meifeng, 0731, Fertilizer, 79.361, 15.795, 23.235, 11.323, 16.921, 12.088 ... ... 1059, Tire rubber, 600623, car, 7.167, 8.265, 10.973, -34.411, 14.120, 8.2191060, PT Ji light industry, 0546, daily light industry, -11.895, 5.740, -49.149, 7.99, 14.136, 9.3791061, Airborne International, 600685, Mechanical Instrument, -57.452, 9.824, -1.528, -89.648 , 14.366, 9.533

The third part is automatically dialing, automatically hang up, and automatic processing

A excellent "Automatic Internet Robot" program should be able to start dialing on time in accordance with the established time, and then hang up immediately after the task is completed. And only these are not enough, it should also track the dialing operation after issuing dial-up instructions, how is the Internet speed, whether you need to reside after the interrogation, the automatic browsing process appears, and the final hangup Whether the operation is really successful, and so on.

Therefore, the "Robot" program should check online status to ensure that the browsing is always online, and must not be online after browsing. At the same time, I have to check the progress. When the browsing speed is too slow, try hang up and re-dial. This section discusses several methods for realizing the three functions of "automatic dialing", "check online status", and "automatic hanging", comparing the advantages and disadvantages of the methods, and summarizes the use suggestions. The sample programs of this section integrate these three functions of the three functions to facilitate the contrast (see below).

Automatic dialing

Method 1A: Using RNAUI.dll

RNAUI.dll is Microsoft's "Dial-Up Network User Interface" assembly, usually in the "/ windows / system" directory. Where the RNADial program is used to start dialing. This program can be executed in the command line ("Start" -> "Run" to type):

Rundll32.exe rnaui.dll, RNADial

The "RNADial" and "" are case sensitive.

However, since the above command only starts the dial-up window, the dial is not started, so it should be re-used during the program.

Send the button to simulate "Enter":

RET = shell ("Rundll32.exe Rnaui.dll, RNADial" Connection Name, 1) SendKeys "{Enter}", TRUE

Method 1B: Using Wininet.dll

Wininet.dll is Microsoft's Internet expansion function set, generally in the / windows / system directory. The InternetAutodial, InternetAutodialhangup and InternetGetConnectedState three functions can complete tasks such as automatic dialing, automatic hanging and judging online status. InternetAutodial is defined as:

Private Declare Function InternetAutodial Lib "Wininet.dll" _ (Byvaldwflags As Long) As Long AS Long

If the value of the first parameter (dwflags) is 2, the function can be automatically dial without user intervention. But use this function there is a premise: "Internet Properties" -> "Connect" must be set to "Always call the default connection" (see the figure below).

See the figure below with the InternetAutodial function to automatically dial. As can be seen from the figure, the method can repeat multiple times. The specific retries are defined in the "Settings" -> "Advanced" -> "Advanced" "->" Advanced "->" Advanced ":

Method 1C: Using RAS

Ras is a collection of Microsoft's Remote Access Service API. The API function rasdial can complete the dialing task. However, since this function is slightly complicated and is not commonly used, it is not adopted in the sample program.

Automatic dialing method Summary: The RNAUI method is the easiest, and because it is not necessarily to use the default connection, it is also the most flexible. But this flexibility has brought weaknesses, that is, if no connection name is provided, this method does not automatically call the default connection. In addition, this method has two largest shortcomings: one is only dial once, if there is a case or no response, etc., it will not be automatically retryed when the situation is or otherwise, and the second is that the calling program does not easily get the return value of the dialing. In contrast, although the Wininet method can only call the default connection (using the first connection without default), it can be tried more times, and the InternetAutodial function waits for dialing success or all pilot ends to return to the call. Dialing is the value of success, so the Wininet method is most suitable in the "Automatic Internet Robot" environment. 2. Check online

Method 2A: Wininet method

If the InternetGetConnectedState function returns true, it is an online status. The maximum disadvantage of this method is that if the current connection is not established with the Wininet method, the return value may not be accurate.

Method 2B: Find window law

After the dial-up connection is successful, the window shown below must exist (regardless of it minimizes the rightmost end of the taskbar, or the state shown below):

Find the window with the FindWindow API function means current online. In addition, another use of the search window method is to find the "Reconnect" window: When the line is dropped, the operating system often asks you to reconnect, find the window and issue an analog "Enter" button to implement redirects.

The disadvantage of the search window method is that the window title is required because the window is required, so even if the default connection must know the default connection name in advance.

Method 2C: RAS method

First use the RaseNumConnections function to return the entire RAS collection, and then determine the status of the first RAS connection with the RasgetConnectStatus function. The biggest advantage of the RAS method is that the RAS method can make correct judgment on the online state regardless of whether the current connection is established with Wininet.

Method 2D: Registration

Online, the "/ hkey_local_machine / system / currentcontrolset / service / system / current" / service / system / current "/ system / reproteability" of the registry is not zero; when the line is not online, there is no "Remote Connection" key value (when this When the secondary system is started, it will be successfully successfully successful), or it is zero (indicating that the dialing is successful, but it has been broken).

Checking online status Summary: Due to the limitations of Wininet methods, we should generally avoid use; lookup window method is reliable, just to know the connection name; so we recommend using the RAS method and registry.

3. Automatically hang up

Method 3A: Wininet method

Use the InternetAutodialHangup function. Similarly, if the current connection is not established with a Wininet method, the return value may not be accurate (ie, can not be successfully hanging).

Method 3B: Window Find Act

Find the window shown in Figure 9, then use the ShowWindow API function to make it a current window, and finally simulate

C button operation (can be seen from Figure Jiu,

C is a shortcut to "disconnect" button).

Method 3C: RAS method

Perform a hose with the Rashangup function. Regardless of the connection established, the RAS method can reliably complete the task.

Automatic hanging method summary: In contrast, window lookup methods and RAS methods are reliable.

4. Summary of this section

In summary, for "automatic dial", "check online status", and "automatic hang", we recommend "1A-2C-3C" combination. Of course, each method can be used in combination (such as 2D, 3B, etc.) to ensure that there is no loss. At the time of specific programming: Dialing judgment results, if you do not succeed, you should re-dial; the task is fixed during the process, and the line should be processed after the drop is turned off; the last hanging operation should be checked back to check the online state, Make sure the hangs are successful.

Below is the full code of the example program. The global definition in the source code has been classified according to Wininet, RAS, registry, etc., and each specific method is arranged in order to make it available. The implementation of the program has been given (Fig. 6).

"Procedure 3: automatic dialing, automatic hang up and handled automatically disconnect only 'Global Option Explicit' defined about wininet Private Const INTERNET_AUTODIAL_FORCE_UNATTENDED = 2Private Const INTERNET_CONNECTION_MODEM = 1Private Declare Function InternetAutodial Lib" wininet.dll "_ (ByVal dwFlags As Long, ByVal dwReserved As Long) As LongPrivate Declare Function InternetAutodialHangup Lib _ "wininet.dll" (ByVal dwReserved As Long) As LongPrivate Declare Function InternetGetConnectedState Lib _ "wininet.dll" (ByRef lpdwFlags As Long, ByVal _dwReserved As Long) As Long 'relevant "window to find" global definition of Private Declare Function FindWindow Lib "user32" _Alias ​​"FindWindowA" (ByVal lpClassName As String, _ByVal lpWindowName As String) As LongPrivate Declare Function ShowWindow Lib "user32" _ (ByVal hwnd As Long, ByVal nCmdShow As Long ) As LongPrivate Const SW_SHOW = 5 'on RAS globally defined Private Const RASCS_DONE = & H2000 & Private Const RAS_MaxEntryName = 256Private Const RAS_MaxDeviceType = 16Private Const RAS_MaxDeviceName = 128Private Type RASCONNdwSize As LonghRasConn As LongszEntryNam e (RAS_MaxEntryName) As ByteszDeviceType (RAS_MaxDeviceType) As ByteszDeviceName (RAS_MaxDeviceName) As ByteEnd TypePrivate Type RASCONNSTATUSdwSize As LongRasConnState As LongdwError As LongszDeviceType (RAS_MaxDeviceType) As ByteszDeviceName (RAS_MaxDeviceName) As ByteEnd TypePrivate Ras_Buf (255) As RASCONNPrivate Ras_Status As RASCONNSTATUSPrivate lpcb As LongPrivate lpcConnections As LongPrivate Declare Function RasEnumConnections Lib _ "rasapi32.dll" Alias ​​"RasEnumConnectionsA" (lprasconn _As Any, lpcb As Long, lpcConnections As Long) As LongPrivate Declare Function RasGetConnectStatus Lib _ "rasapi32.dll"

Alias ​​"RasGetConnectStatusA" (ByVal _hRasConn As Long, lpRASCONNSTATUS As Any) As LongPrivate Declare Function RasHangUp Lib "rasapi32.dll" _Alias ​​"RasHangUpA" (ByVal hRasConn As Long) As Long 'Private For global definition "registry" in Const HKEY_LOCAL_MACHINE = & H80000002Private Declare Function RegOpenKey Lib "advapi32.dll" Alias ​​_ "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As _String, phkResult As Long) As LongPrivate Declare Function RegQueryValueEx Lib "advapi32.dll" _Alias ​​"RegQueryValueExA" (ByVal hKey As Long , ByVal _lpValueName As String, ByVal lpReserved As Long, lpType _As Long, lpData As Any, lpcbData As Long) As LongPrivate Declare Function RegCloseKey Lib "advapi32.dll" _ (ByVal hKey As Long) As LongDim ret As Long 'Private automatic dialing Sub wininet dial test _Click () If InternetAutodial (INTERNET_AUTODIAL_FORCE_UNATTENDED, 0) _Then MsgBox "connected (WinInet France)" End SubPrivate Sub rnaui dial test _Click () ret = Shell ( "rundll32.exe rnaui.dll, RnaDial" TEXT1, 1): DoeventssendKeys "{enter}", true: doeventsend sub 'Checks whether to disconnect Priv TE SUB WININET Method_click () 'Wininet method Checks if IF InternetGetConnectedState (Internet_Connection_Modem, 0) ThenMSGBOX "online. "Elsemsgbox" is currently not connected. "END IFEND SUBPRIVATE SUB Find Window Method _Click () 'Find window method Check if it is broken RET = FINDWINDOW (" # 32770 "," reconnect ") if Ret <> 0 thencall showwindow (RET, SW_SHOW) SendKeys {Enter } ", True: exit subnd iFret = findwindow (" # 32770 "," connected to the95963 ") IF RET <> 0 thenmsgbox" online. "Elsemsgbox" is currently not connected.

"END IFEND SUBPRIVATE SUB RAS Method _Click () 'RAS method Checks whether it is broken RAS_BUF (0) .dwsize = le (Ras_buf (0)) 1LPCB = 256 * ras_buf (0) .dwsizeret = RaseNumConnections (ras_buf (0) , LPCB, LPCCONNECTIONS IF RET THENMSGBOX "error! ": EXIT SUBEND IFRAS_STATUS.DWSIZE = LEN (RAS_STATUS) 2 Ret = rasgetconnectStatus (ras_buf (0) .hrasconn, ras_status) if Ret = 0 and ras_status.rasconnstate = ras_done thenmsgbox online. "Elsemsgbox" is currently not connected. "End IfEnd SubPrivate Sub registry method _Click () 'registry method checks whether disconnection Dim SubKey As String, ValueName As StringDim Data As Long, Result As LongSubKey =" System / CurrentControlSet / Services / RemoteAccess "ret = RegOpenKey (HKEY_LOCAL_MACHINE , SubKey, Result) If ret = 0 & ThenValueName = "Remote Connection" ret = RegQueryValueEx (Result, ValueName, 0 &, 0 &, ByVal Data, 0 &) ret = RegQueryValueEx (Result, ValueName, 0 &, 0 &, Data, Len (Data) ) IF RET = 0 & AND Data <> 0 Tenmsgbox "Online! "Elsemsgbox" is currently not connected.

转载请注明原文地址:https://www.9cbs.com/read-31388.html

New Post(0)