Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Enumerating data formats currently available on the clipboard
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Winsock: sending email messages (SMTP, port 25)
Mapping and disconnecting network drives
Winsock: retrieving directory listing from an FTP server using passive data connection (FTP, port 21)
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Custom GDI+ class
Converting Unicode data from the Clipboard to a character string using a given code page
Disk in drive A:
How to display the Properties dialog box for a file (ShellExecuteEx)
Enumerating network resources
Detecting changes in connections to removable drives (VFP9)
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
How to download a file from the FTP server using FtpGetFile
Using EnumPrinters function to enumerate locally installed printers
How to play AVI file on the _screen
Retrieving the name of the network resource associated with a local device
Creating a console window for Visual FoxPro application
Custom HttpRequest class (WinHTTP)
Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)
Custom FTP Class for Visual FoxPro application
How to put a horizontal text scrolling on the form (a news line)
Splash Screen for the VFP application
Custom HttpRequest class (WinHTTP)

User rating: 8/10 (1 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:
Use this class to send HTTP POST, HTTP GET and other HTTP requests. Use the following code to test it:

SET MEMOWIDTH TO 120
#DEFINE ccUrl "http://www.news2news.com/vfp/?example=397"

oHttp = CreateObject("WinHttpRequest")
WITH oHttp
        IF Not .Open("GET", ccUrl)
                ? "Error:", .ErrorCode, .ErrorMsg
        ELSE
                IF Not .Send()
                        ? "Error:", .ErrorCode, .ErrorMsg
                ELSE
                        ? .Status
                        ? .StatusText
                        ? .GetAllResponseHeaders()
                        ? .GetResponseHeader("connection:")
                        ? "Response length:", .ResponseLen
                        SET SAFETY OFF
                        StrToFile(.ResponseText, "tmp.txt")
                        SET SAFETY ON
                        MODI FILE tmp.txt NOWAIT
                ENDIF
        ENDIF
ENDWITH

There is a similar class built on WinINet functions: Custom HttpRequest class (WinINet).
 
  Members area. Log in to view this example.
 
  User name:
  Password:
 
 
  Forgot your password?
 
  Sign up for
the Membership
 
 


User rating: 8/10 (1 votes)
Rate this code sample:
  • ~
12922 bytes  
Created: 2003-04-07 19:20:07  
Modified: 2011-12-10 09:20:22  
Visits in 7 days: 222  
Listed functions:
GetLastError
GlobalAlloc
GlobalFree
GlobalSize
WinHttpAddRequestHeaders
WinHttpCloseHandle
WinHttpConnect
WinHttpCrackUrl
WinHttpOpen
WinHttpOpenRequest
WinHttpQueryDataAvailable
WinHttpQueryHeaders
WinHttpReadData
WinHttpReceiveResponse
WinHttpSendRequest
WinHttpSetCredentials
Printer friendly API declarations
My comment:
Nov. 26, 2003: code completely rewritten.

Take a look at About WinHTTP page on MSDN.

* * *
Dec.26, 2006: For C++ part, install WinHttp 5.1 SDK. The most straightforward way of doing that is downloading 400Mb of Windowsฎ Server 2003 R2 Platform SDK.

#kwd: sln_http.
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:
Jacek Cenzartowicz | 2006-10-05 15:31:31
Hello. There is some problem with CrackUrl function from WinHttpRequest class. After HttpCrackUrl, .host property contain in unicode, some extra trash data at end of the string. The .host property is not null terminated.
When class is used from Command Window (DO example397.prg) it's running fine.
But if you call example397.prg form Click method of CommandButton, you will get corrupted .host very often.
I wrote my own CrackUrl, and now this class is working fine.
A.M. | 2006-10-09 13:08:32
Jacek, thanks!

I have added changes to the function. When parsing the return of WinHttpCrackUrl() the Length members of the URL_COMPONENTS structure are used instead of double CHR(0).

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.19.155.235)
6.48 min.Example: 'Subclassing CommandButton control to create BackColor property'
11.35 hrs.Function: 'OpenService'
 Function: 'PathGetShortPath'
14.23 hrs.Example: 'Hiding mouse cursor'
15.39 hrs.Example: 'Moving shortcut to a specified position on the Windows Desktop'
15.5 hrs.Function: 'GetPrivateProfileSectionNames'
Function group: 'Registry'
17.86 hrs.Example: 'Accessing LSA Policy object (Local Security Authority)'
 Example: 'Reading security permissions for NTFS files and folders'
 Function: 'GlobalAlloc'
1 day(s)Function: 'PathIsNetworkPath'
Google
Advertise here!