VB web page program (VB + DoS)

Source: Internet
Author: User
Tags sub command

Originally thought to useIt is very easy to click a link in VB, but in actual operation,Bug! That isMemory leakage in IE kernel browsers. InVB: UseWhen the Web Control keeps clicking or refreshing a link, the memory will accumulate constantly. Even if you release all objects and close all pop-up pagesWhen the web control is not closed, the memory will accumulate to an astonishing level (becauseWeb controls useIE kernel)So I went online to seek a solution and found no giants. I got only one answer: Wait for Microsoft to solve the problem!

However, some people say they can restart the system after a period of execution.ProgramTo release the memory. I think this is the best solution within my capabilities!

How can I restart it ?? Imagine a user is using your program, but it suddenly disappears and cannot be accepted! Secondly, if your program is minimized, will it cause harassment to users during restart? How to keep the program quiet?

Based on the above problems, my solution is:Use two EXE filesPrograms, one as the main program, and one as the service program for clicking the web page (invisible), data interaction between them is achieved through the registry.

The advantage is that,Without knowing how to click, the user cannot feel the restart of the service program.;Second, you canGreatly reduce the pressure on the main program,If you have the main program click the webpage, the program will become very stuck. In this way, the main program is completely released, and its task is only to receive registry data.

What I need to explain is that my level is limited.VB forced the end of the service process was a bit stubborn, with the reminder of Cui Jackie ChanDOS ends, convenient (only process name is needed), fast, and convenient! I have to say,DOS efficiency is still very high! Consider it as appropriate!

Note: I only tried to give Mr. Mi a blog, but I found a common memory problem. I think it is necessary to share my methods and communicate with each other for reference.

 

Original method, reprinted with the source! Thank you!

INSTRUCTOR: Mi Xinjiang

 

Main program source code:

Option explicitprivate declare sub sleep lib "Kernel32" (byval dwmilliseconds as long) dim datstart as date 'record start time private sub command#click () savesetting "", "url ", "urlkey", text1.text "Storage target website savesetting" "," url "," outurlkey ", text4.text" Storage jumps out of the website savesetting "", "label", "labelkey", text3.text "Storage target row number savesetting" "," cmd "," primary key "," 1 "'storage command 1, it is better to directly close the service process by notifying the service program to execute! But I feel like using the registry is an idea! Shell app. path & "\ serve.exe" 'Run the service program end subprivate sub command2_click () savesetting "shuimi instructor blog", "cmd", "primary key", "0"' storage command 2, notify the service program to terminate the end subprivate sub command3_click () dim I as long 'input validity test if text1.text = "" Then msgbox "target URL is blank! "Exit subend ifif text2.text =" "Then msgbox" keyword is blank! "Exit subend ifwebbrowser1.navigate text1.text 'Open the target Web page webbrowser1.silent = true' to prevent unexpected alerts for control suspension' check whether the web page has been loaded if webbrowser1.busy then msgbox" is opening the web page! It may be that your network speed is slow! "Exit subend iflist1.cleardo while webbrowser1.readystate <> readystate_complete doeventsloop 'traverses the webpage for I = 1 to webbrowser1.document. all. length-1 If instr (1, webbrowser1.document. all (I ). outerhtml, text2.text)> 0 then' search for the keyword if ucase (webbrowser1.document. all (I ). tagname) = "A" then' starts with uppercase A. The description is a hyperlink. uppercase A list1.additem "no." & (list1.listcount + 1) & "the row number that appears is" & I 'added to the list. end if end ifnext' checks if the keyword is found. List1.listcount = 0 then msgbox "the keyword does not exist! Make sure the input is correct! "Else msgbox" please fill in the line number based on the actual situation. The software determines the character position based on the line number! "End ifend subprivate sub command4_click () 'asks the user to confirm whether it is the expected webpage msgbox." note that the program will click the desired link once. If the displayed webpage is correct, enter "webbrowser1.document. all (text3.text ). clickend subprivate sub form_load () datstart = time' record a start time savesetting "", "countall", "countallkey ", "0" 'initialization times 0' create a batch file in the current directory to kill the service process open app. path & "\ files. bat "for output as #1 print #1," taskkill/f/IM serve.exe/t "close # 1end subprivate sub form_unload (cancel as integer) deletesetting "" 'delete the registry key shell app. path & "\ files. bat "'Kill the residual service process and clear the memory end subprivate sub timer1_timer () label2.caption = getsetting (" "," countall "," countallkey ") 'Show Number of refresh times end subprivate sub timer2_timer () 'check time exceeds the specified time. If the time exceeds, restart the service process if datediff ("S", datstart, time)> 30 then datstart = time shell app. path & "\ files. bat "doevents sleep 1500 shell app. path & "\ serve.exe" End ifend sub

service program source code:

Option explicitdim lngnumber as long records the number of clicks. Private sub form_load () 'processes the webpage according to the main program. webbrowser1.navigate getsetting ("", "url ", "urlkey") webbrowser1.silent = truewhile webbrowser1.busy doeventswendend subprivate sub timer1_timer () on error resume next 'to keep the program quiet. webbrowser1.document. all (Val (getsetting ("", "label", "labelkey "))). click 'connect end subprivate sub timer2_timer () If webbr according to the parameters of the main program Owser1.locationurl = trim (getsetting ("", "url", "outurlkey ")) then unload me 'close and click the connection pop-up connection' to determine the main program running command if getsetting ("", "cmd", "cmdkey ") = "0" then timer1.enabled = falseelseif getsetting ("", "cmd", "cmdkey ") = "1" then if timer1.enabled = false then 'prevent unnecessary changes to the timer attribute, resulting in confusion timer1.enabled = true end ifend sub private sub webbrowser1_newwindow2 (ppdisp as object, cancel as boolea N) 'explain why the record has been flushed into this event, because only when this event is activated indicates that the webpage has been successfully clicked! This is more accurate than counting in timer! Lngnumber = Val (getsetting ("", "countall", "countallkey") + 1' get the last record of the record + 1, prevents Log service programs from being restarted and counting 0 savesetting "", "countall", "countallkey", STR (lngnumber) 'The number of clicks passed to the main process' prevents the webpage from jumping out of the program dim frmwb as form1set frmwb = new form1frmwb. webbrowser1.registerasbrowser = trueset ppdisp = frmwb. webbrowser1.object 'frmwb. visible = trueend sub

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.