Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to retrieve the number of print jobs queued for the printer
Scanning the hierarchy of child windows down from the main VFP window
Downloading files from the FTP server using InternetReadFile
How to view icons stored in executable files (Icon Viewer)
Retrieving local computer and user names
Disconnecting USB Mass Storage Device programmatically
Displaying hypertext links with the SysLink control (VFP9, Comctl32.dll)
Enumerating ports that are available for printing on a specified server
How to enable the SE_SHUTDOWN_NAME privilege for the application
Converting image file to .ICO file
Enumerating global and local group accounts on a server (WinNT/XP/2K)
How to retrieve adapter information for the local computer (including MAC address)
Obtaining some properties for the Windows desktop using the GetWindowPlacement function
Retrieving the command line for the VFP session
Retrieving the name of the primary domain controller (PDC) and join status information (NT/2000/XP)
The SQLGetProp() creates a bridge between Visual FoxPro and the ODBC API
Using the RestartDialog function -- restarting Windows
Obtaining information about all user accounts on a server (WinNT only)
Round FoxPro form
Enumerating Volumes and Volume Mounting Points (NTFS)
How to find the application associated with a file name
Obtaining physical parameters for a drive: sectors, clusters, cylinders...
Obtaining Shell32.dll version
Retrieving the interface–to–IP address mapping table
Accessing examples contained in this reference through Web Services

User rating: 7/10 (3 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Versions:
click to open
Before you begin:
Get WSDL and description of exposed functions in this article.
Use at least VFP8 to test this example.



See also:
  • ApiViewer for Visual FoxPro

  •  
    PUBLIC objForm
    objForm = CreateObject("Tform")
    IF VARTYPE(objForm)="O"
        objForm.Visible = .T.
    ENDIF
    * end of main
     
    DEFINE CLASS Tform As Form
    #DEFINE ccBaseAddr "http://www.news2news.com/vfp/"
    #DEFINE ccWSDL  "http://www.news2news.com/cgi-bin/w32/services/ws.php?wsdl"
    #DEFINE ccUsrname "guest"
    #DEFINE ccPwd ""
        Caption=" VFP code samples on " + ccBaseAddr
        Width=760
        Height=500
        MaxButton=.F.
        MinButton=.F.
        Autocenter=.T.
        ShowTips=.T.
        csList="cs" + SUBSTR(SYS(2015),3,10)
        ws=0
     
        ADD OBJECT pframe As Tframe WITH Left=6, Top=5, Width=748, Height=440
        ADD OBJECT lblUrl As Label WITH Left=12, Top=460, Autosize=.T.,;
            ForeColor=Rgb(0,0,192), FontUnderline=.T.,;
            TooltipText="Click to open"
     
    PROCEDURE Init
        LOCAL ex As Exception, lError
        lError=.F.
        TRY
            THIS.ws = CREATEOBJECT("mssoap.soapclient")
            THIS.ws.mssoapinit(ccWSDL)
        CATCH TO ex
            THIS.ws_error(ex, "Could not initialize SOAP Client.")
            lError=.T.
        ENDTRY
     
        IF m.lError
            RETURN .F.
        ENDIF
     
        DECLARE INTEGER ShellExecute IN shell32;
            INTEGER, STRING, STRING, STRING, STRING, INTEGER
        THIS.pframe.Resize
        THIS.PopulateList
     
    PROTECTED PROCEDURE ws_error(ex, cCaption)
        = MESSAGEBOX(TRANSFORM(ex.ErrorNo) + ". " +;
            ex.Message + "     " + CHR(13) + CHR(13) +;
            "detail: " + TRANSFORM(THIS.ws.detail) + "     " + CHR(13)+CHR(13) +;
            "faultfactor: " + TRANSFORM(THIS.ws.faultactor) + "     " + CHR(13) +;
            "faultcode: " + TRANSFORM(THIS.ws.faultcode) + "     " + CHR(13) +;
            "faultstring: " + TRANSFORM(THIS.ws.faultstring) + "     ",;
            48, m.cCaption)
     
    PROCEDURE Destroy
        THIS.ws=Null
        THIS.pframe.pgList.lst.RowsourceType = 0
        IF USED(THIS.csList)
            USE IN (THIS.csList)
        ENDIF
     
    PROCEDURE pframe.pgList.lst.InteractiveChange
        ThisForm.lblUrl.Caption = ThisForm.GetUrl()
     
    PROCEDURE lblUrl.MouseDown
    LPARAMETERS nButton, nShift, nXCoord, nYCoord
        = ShellExecute(0, "open", ThisForm.GetUrl(), "", "", 3)
     
    PROCEDURE pframe.pgExample.Activate
        ThisForm.DisplayExample
     
    PROCEDURE pframe.pglist.lst.DblClick
        ThisForm.pframe.ActivePage = 2
     
    FUNCTION GetUrl
    RETURN ccBaseAddr + "?example=" + ALLT(THIS.pframe.pgList.lst.Value)
     
    PROCEDURE PopulateList
        LOCAL cResult, ex As Exception
        TRY
            WAIT WINDOW NOWAIT "Retrieving list of examples..."
            cResult = THIS.ws.GetListOfExamples()
            XMLTOCURSOR(m.cResult, THIS.csList, 0)
        CATCH TO ex
            cResult=""
            THIS.ws_error(ex, "SOAP error")
        FINALLY
            WAIT CLEAR
        ENDTRY
        IF USED(THIS.csList)
            WITH THIS.pframe.pgList.lst
                .RowsourceType = 2
                .Rowsource = THIS.csList
                .ColumnWidths="60,700"
                IF .listCount > 0
                    .listIndex = 1
                ENDIF
                .InteractiveChange
            ENDWITH
        ENDIF
     
    PROCEDURE DisplayExample
        LOCAL nId, cResult, ex As Exception
        nId = VAL(ThisForm.pframe.pgList.lst.Value)
        TRY
            WAIT WINDOW NOWAIT "Retrieving requested example..."
            cResult = THIS.ws.GetExample(nId, ccUsrname, ccPwd)
            XMLTOCURSOR(m.cResult, "csExample", 0)
        CATCH TO ex
            cResult=""
            THIS.ws_error(ex, "SOAP error")
        FINALLY
            WAIT CLEAR
        ENDTRY
        IF USED("csExample")
            WITH ThisForm.pframe.pgExample.txtSource
                .Value = csExample.body
                .Refresh
            ENDWITH
            USE IN csExample
        ENDIF
    ENDDEFINE
     
    DEFINE CLASS Tframe As PageFrame
        ADD OBJECT pgList As TpageList WITH Caption="List of examples"
        ADD OBJECT pgExample As TpageExample WITH Caption="Source Code"
     
    PROCEDURE Resize
        WITH THIS.pgList
            .lst.Width = THIS.Width - 14
            .lst.Height = THIS.height - .lst.Top - 50
        ENDWITH
        WITH THIS.pgExample
            .txtSource.Width = THIS.Width - 14
            .txtSource.Height = THIS.height - .txtSource.Top - 50
        ENDWITH
    ENDDEFINE
     
    DEFINE CLASS TpageList As Page  && Page object
        ADD OBJECT lst As ListBox WITH Left=5, Top=5, FontName="Arial",;
            FontSize=10, ColumnCount=2, BoundColumn=1
    ENDDEFINE
     
    DEFINE CLASS TpageExample As Page  && Page object
        ADD OBJECT txtSource As EditBox WITH Left=5, Top=5,;
            FontName="Courier New", FontSize=9, ForeColor = RGB(0,96,128)
    ENDDEFINE
     
     
     

    User rating: 7/10 (3 votes)
    Rate this code sample:
    • ~
    4021 bytes  
    Created: 2004-09-17 08:30:10  
    Modified: 2010-09-11 14:56:53  
    Visits in 7 days: 70  
    Listed functions:
    ShellExecute
    Printer friendly API declarations
    My comment:
    C# version of this code sample. Click on the image below to download VS2008 C# project.

    Download VS2008 project

    VB.Net version of this code sample.



    Start new Windows Application project. Place on the form TabControl, ListBox, TextBox and LinkLabel controls.

    Add to the project new Web Reference pointing at http://www.news2news.com/vfp/wsdl/webservices.WSDL.
    Word Index links for this example:
    Translate this page:
      Spanish    Portuguese    German    French    Italian  
    FreeTranslation.com offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.


    Copyright © 2001-2013 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

    Privacy policy
    Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (50.17.109.248)
    2.15 hrs.Example: 'Saving HKEY_LOCAL_MACHINE\\Software\\ODBC Registry Entries to an XML file'
     Example: 'Enhanced GetFont dialog'
    2.51 hrs.Function: 'CeFindFirstFile'
    3.41 hrs.Function: 'SetDlgItemInt'
     Example: 'Reading metrics for the currently selected font'
     Example: 'Obtaining heap handles and enumerating memory blocks for the current VFP session (WinNT only)'
    4.91 hrs.Function: 'getsockopt'
    10.62 hrs.Example: 'Scanning the hierarchy of child windows down from the main VFP window'
     Example: 'Retrieving local computer and user names'
    10.63 hrs.Function: 'SQLGetInfo'
    Google
    Advertise here!