To stop a connection Internet with AOL?

Just starting out? Need help? Post your questions and find answers here.
ADN
User
User
Posts: 17
Joined: Fri May 16, 2003 9:25 am
Location: France

To stop a connection Internet with AOL?

Post by ADN »

Hi all,
How to make for To stop a connection Internet with AOL?
:)

Thanks
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Post by TerryHough »

This thread may help you.

viewtopic.php?t=2813&highlight=ftp+client

Also, try using the search function of the board. There are other discussions of similar code.

Terry
ADN
User
User
Posts: 17
Joined: Fri May 16, 2003 9:25 am
Location: France

Post by ADN »

Hi,
Thanks, but how to know the ConnectionID ?

Code: Select all

InternetHangup_(ConnectionID,0)

TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Post by TerryHough »

[quote="ADN"]Hi,
Thanks, but how to know the ConnectionID ?

It is the "handle" or value returned from the InternetConnect_(,,,,,)
or InternetOpen_(,,) calls.

Code: Select all

hInternetSession.l = InternetOpen_("FTP", #INTERNET_OPEN_TYPE_DIRECT, "", "", 0)
.... snip .....
hInternetConnect = InternetConnect_(hInternetSession.l, IPAddress, #INTERNET_DEFAULT_FTP_PORT, UserName, Password, #INTERNET_SERVICE_FTP, 0, 0)
--- snip ---
; Disconnect the Internet session.
If hInternetSession
  If hInternetConnect
    InternetCloseHandle_(hInternetConnect)
    hInternetConnect = #FALSE
  Else
    TextGadget(13, 20, 230, 300, 20, "No network connection to close")
  EndIf
  InternetCloseHandle_(hInternetSession)
  hInternetSession = #FALSE
Else
  TextGadget(13, 20, 230, 400, 20, "No Internet access to close")
EndIf

If InternetAutodialHangup_(0)
Else
  MessageRequester("Failure warning!","You will have to disconnect your internet connection manually!"+Chr(10)+Chr(10)+"Sorry, my automated attempt has failed...",0)
EndIf
The above code is excerpted from my FTP File Exchange program
which is available on the resources site. See this thread for more
details
viewtopic.php?t=6205

While it shows a FTP connection made through the internet, the same
process applies to an HTTP connection. There are just different
parameters to pass to the API commands.

For all of this to work as expected, there must be an entry in your
DialUp Networking for your access to AOL. A standard AOL installation
may not create that entry, but you can easily add it yourself.

Good luck,
Terry
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

To stop an AOL Internet Connection...

Post by LJ »

Step 1: Open the AOL browser and run the code below.

Code: Select all

;-ini 
Structure info 
  handle.l 
  process.l 
  class$ 
  name$ 
EndStructure 
#PROCESS_ALL_ACCESS=$FFF 

NewList info.info() 
NewList AllHandle() 

Procedure.s GetClassName(handle) 
  class$=Space(1024) 
  GetClassName_(handle,@class$,Len(class$)) 
  ProcedureReturn Left(class$,Len(class$)) 
EndProcedure 
Procedure.s GetTitle(handle) 
  name$=Space(1024) 
  GetWindowText_(handle,@name$,Len(name$)) 
  ProcedureReturn Left(name$,Len(name$)) 
EndProcedure 
Procedure AddInfo(Handle) 
  process=0 
  GetWindowThreadProcessId_(handle,@process) 
  Class$=GetClassName(handle) 
  Name$=GetTitle(handle) 
  
  ResetList(info()) 
  quit=0 
  i=0 
  Repeat 
    If NextElement(info()) 
      If process < info()\process 
        quit=1 
      ElseIf process=info()\process 
        If class$ < info()\class$ 
          quit=1 
        ElseIf UCase(class$)=UCase(info()\class$) 
          If name$ < info()\name$ 
            quit=1 
          ElseIf UCase(name$)=UCase(info()\name$) 
            If handle < info()\handle 
              quit=1 
            ElseIf handle=info()\handle 
              quit=3 
            EndIf 
          EndIf 
        EndIf 
      EndIf 
    Else 
      quit=2 
    EndIf 
  Until quit 
  If quit<3 
    If quit=1 
      If PreviousElement(info())=0: ResetList(info()) :EndIf 
    EndIf 
    AddElement(info()) 
    info()\handle=handle 
    info()\process=process 
    info()\class$=class$ 
    info()\name$=name$ 
    If class$ = "IEFrame"
      postmessage_(info()\handle,#wm_close,0,0)
     EndIf
    
  EndIf 
EndProcedure 
Procedure TerminateProcess(processid) 
  process=OpenProcess_(#PROCESS_ALL_ACCESS,1,processid) 
  If process 
    terminateprocess_(process,0) 
    closehandle_(process) 
  EndIf 
EndProcedure 
Procedure RefreshList() 
  ClearGadgetItemList(0) 

  ClearList(allhandle()) 
  ClearList(info()) 
  handle=getwindow_(WindowID(),#GW_HWNDFIRST) 
  ClearList(allhandle()) 
  quit=0 
  Repeat 
    AddInfo(handle) 
    x=getwindow_(handle,#GW_CHILD) 
    If x 
      AddElement(allhandle()) 
      allhandle()=x 
    EndIf 
    x=getwindow_(handle,#GW_HWNDNEXT) 
    If x 
      handle=x 
    Else 
      If LastElement(allhandle()) 
        handle=allhandle() 
        DeleteElement(allhandle()) 
      Else 
        quit=1 
      EndIf 
    EndIf 
  Until quit 
  
  ResetList(info()) 
  
    
  While NextElement(info()) 
    If oldprocess<>info()\process 
      oldprocess=info()\process 
      a$=Hex(oldprocess) 
    Else 
      a$="              ''" 
    EndIf 
    AddGadgetItem(0,-1,a$+Chr(10)+info()\class$+Chr(10)+info()\name$+Chr(10)+Hex(info()\handle)) 

  Wend 
  
  SetGadgetState(0,0) 
EndProcedure 

If OpenWindow(0,0,400,512,320,#PB_Window_SystemMenu,"Tasks") 
  

  If CreateGadgetList(WindowID()) 
    ListIconGadget(0, 0,0,512,300, "Process",60) 
    AddGadgetColumn(0,1,"Class",220) 
    AddGadgetColumn(0,2,"Name",150) 
    AddGadgetColumn(0,3,"Handle",50) 
    ButtonGadget(1,   0,300, 128,20,"Send Quit") 
    ButtonGadget(2, 128,300, 128,20,"Send Close") 
    ButtonGadget(3, 256,300, 128,20,"Terminate Process") 
    ButtonGadget(4, 384,300, 128,20,"Refresh List") 
    
    RefreshList() 
    
    
    Repeat 
   
    
      event=WaitWindowEvent() 
      Select event 
        Case #pb_event_gadget 
          stat=GetGadgetState(0) 
          If stat>-1 
            SelectElement(info(),stat) 
            stat=1 
          Else 
            stat=0 
          EndIf 

          Select EventGadgetID() 
;             Case 0: 
;               If stat 
;                 Debug Hex(info()\process)+" | "+info()\class$+" | "+info()\name$+" | "+Hex(info()\handle) 
;               EndIf 
             Case 1;quit 
               If stat: postmessage_(info()\handle,#wm_quit,0,0):EndIf 
             Case 2;close 
               If stat: postmessage_(info()\handle,#wm_close,0,0):EndIf 
             Case 3;Terminate 
               If stat: TerminateProcess(info()\process) :EndIf 
             Case 4 
               RefreshList() 
          EndSelect 
      EndSelect 
          
    Until event=#pb_event_Closewindow 
  EndIf 
EndIf
Step 2: The program above will give you the Class and Name of the AOL Browswer window. For this example, I will use the Internet Explorer browser. I get the class of "IEFrame" for the Internet Explorer browser windows.

Step 3: Insert the class name you got in Step 2 (of the AOL browser) into the code below where you see "IEFrame" (remember, I'm doing this with Internet Explorer browser and not the AOL browser). That's it! To test, run the code below and the try and open the AOL browser, the program will automatically close it! Remember to also change/create the MYHTMLPAGE.htm to be a .html page in the same folder as the compiled code below.

Code: Select all


;-ini 
Structure info 
  handle.l 
  process.l 
  class$ 
  name$ 
EndStructure 
#PROCESS_ALL_ACCESS=$FFF 

NewList info.info() 
NewList AllHandle() 

Procedure.s GetClassName(handle) 
  class$=Space(1024) 
  GetClassName_(handle,@class$,Len(class$)) 
  ProcedureReturn Left(class$,Len(class$)) 
EndProcedure 
Procedure.s GetTitle(handle) 
  name$=Space(1024) 
  GetWindowText_(handle,@name$,Len(name$)) 
  ProcedureReturn Left(name$,Len(name$)) 
EndProcedure 
Procedure AddInfo(Handle) 
  process=0 
  GetWindowThreadProcessId_(handle,@process) 
  Class$=GetClassName(handle) 
  Name$=GetTitle(handle) 
  
  ResetList(info()) 
  quit=0 
  i=0 
  Repeat 
    If NextElement(info()) 
      If process < info()\process 
        quit=1 
      ElseIf process=info()\process 
        If class$ < info()\class$ 
          quit=1 
        ElseIf UCase(class$)=UCase(info()\class$) 
          If name$ < info()\name$ 
            quit=1 
          ElseIf UCase(name$)=UCase(info()\name$) 
            If handle < info()\handle 
              quit=1 
            ElseIf handle=info()\handle 
              quit=3 
            EndIf 
          EndIf 
        EndIf 
      EndIf 
    Else 
      quit=2 
    EndIf 
  Until quit 
  If quit<3 
    If quit=1 
      If PreviousElement(info())=0: ResetList(info()) :EndIf 
    EndIf 
    AddElement(info()) 
    info()\handle=handle 
    info()\process=process 
    info()\class$=class$ 
    info()\name$=name$ 
    If class$ = "IEFrame"
      postmessage_(info()\handle,#wm_close,0,0)
     EndIf
    
  EndIf 
EndProcedure 

Procedure RefreshList() 

  handle=getwindow_(WindowID(),#GW_HWNDFIRST) 

  quit=0 
  Repeat 
    AddInfo(handle) 
    x=getwindow_(handle,#GW_CHILD) 
    If x 
      AddElement(allhandle()) 
      allhandle()=x 
    EndIf 
    x=getwindow_(handle,#GW_HWNDNEXT) 
    If x 
      handle=x 
    Else 
      If LastElement(allhandle()) 
        handle=allhandle() 
        DeleteElement(allhandle()) 
      Else 
        quit=1 
      EndIf 
    EndIf 
  Until quit 
 
  ResetList(info()) 
  
    
  While NextElement(info()) 
    If oldprocess<>info()\process 
      oldprocess=info()\process 
      a$=Hex(oldprocess) 
    Else 
      a$="              ''" 
    EndIf 
 ;   AddGadgetItem(0,-1,a$+Chr(10)+info()\class$+Chr(10)+info()\name$+Chr(10)+Hex(info()\handle)) 

  Wend 
  
;  SetGadgetState(0,0) 
EndProcedure 
Procedure ResizeWebWindow()
  ResizeGadget(10, -1, -1, WindowWidth(), WindowHeight())
 
EndProcedure

OpenWindow(0, 0, 0, 797, 550, #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget, "ACE the CSET Single Subject Math")

  CreateGadgetList(WindowID(0))
    
;    Frame3DGadget(6, 0, 30, 0, 2, "", 2) ; Nice little separator
   
  appdir$=Space(255) : GetCurrentDirectory_(255,@appdir$) : If Right(appdir$,1)<>"\" : appdir$+"\" : EndIf 
  url$=appdir$+"MYLOCALHTMLPAGE.htm" 
 
 If WebGadget(10, 0, 0, 0, 0, url$) = 0 : MessageRequester("Error", "ATL.dll not found", 0) : End : EndIf
  
  ;AddKeyboardShortcut(0, #PB_Shortcut_Return, 0)
  ResizeWebWindow()
   

 RefreshList() 
  
  Repeat
  RefreshList()
    Event = WaitWindowEvent()
         
    Select Event
             
           
      Case #PB_Event_Gadget
      
        Select EventGadgetID()
       
            
        EndSelect      
          
    EndSelect
      
  Until Event = #PB_Event_CloseWindow
  
;EndIf
;EndIf
RefreshList()
End

Post Reply