Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Call a URL from the VFP 9 app?
Message
De
14/01/2021 15:31:43
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01677841
Message ID:
01677844
Vues:
65
>>>Hi,
>>>
>>>How would you write a code to call a URL from the VFP application? As if a user clicked on this URL. Specifically, I want to create a small PRG to call a URL every 1 or 2 minutes? Basically a FOR loop and then call this URL?
>>>
>>>How would you do it?
>>>
>>>TIA
>>
>>If you just want to retrieve the contents of a URL then I suggest getting a quality comms library. I use Chilkat from https://www.chilkatsoft.com/ - they have a great, feature rich libary and great support. Excecllent help documentation complete with VFP examples that you can just copy/paste in to your own apps. Can try before buying too.
>
>No, I don't want to retrieve a content of a URL. Here is an example. Suppose I want to call the URL "www.msn.com" from a VFP 9 code. Here is a pseudo code:
>
>cUrl = "www.msn.com"
>for i = 1 to 100
>      *--  Call the cUrl as if a browser is opened and the cURL is entered. This is what I don't know how to do.
>      wait(20)
>next
>
To open a URL with the default browser you need to first find out the associated browser (exe) on the users machine which is used for URLs. To do that I use the ShellExecute () function in the Windows API. To declare that function in VFP:
  *
  *    ShellExecute    -    SHELL EXECUTE FUNCTION IN SHELL32
  *
  *                         Copied (and adapted) from the UniversalThread (FAQ#190, by Gérald Santerre)
  *                         According to the author, opens an HTML document or mail.
  *                         Actually helps to open *any* document with its default association.
  *
  * nShowWindow = ...
  *
  * 0 Hides the window and passes activation to another window.
  * 1 Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position (same as 9).
  * 2 Activates a window and displays it as an icon.
  * 3 Activates a window and displays it as a maximized window.
  * 4 Displays a window in its most recent size and position. The window that is currently active remains active.
  * 5 Activates a window and displays it in its current size and position.
  * 6 Minimizes the specified window and activates the top-level window in the system's list.
  * 7 Displays a window as an icon. The currently active window remains active.
  * 8 Displays a window in its current state. The window that is currently active remains active.
  * 9 Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position (same as 1).
  *

   DECLARE INTEGER ShellExecute IN SHELL32.DLL ;
    INTEGER nWinHandle , ;
    STRING cOperation  , ;
    STRING cFileName   , ;
    STRING cParameters , ;
    STRING cDirectory  , ;
    INTEGER nShowWindow
Then to call it you simple use:
SHELLEXECUTE( 0, "Open", "https://duckduckgo.com", "", "", 1 )  &&  Enter whatever URL as appropriate
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform