Envoyer une requète avec winhttp

Contenu du snippet

Information sur le WinHTTP
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winhttp/http/winhttp_start_page.asp

Plateforme supportées:

Microsoft Windows Server 2003 family
Microsoft Windows XP, Service Pack 1
Microsoft Windows 2000, Service Pack 3 (except Datacenter Server)

Source / Exemple :


Public oform1
oform1=Newobject("form1")
oform1.Show
Return
Define Class form1 As Form
	DoCreate = .T.
	Caption = "Exemple de requete WinHTTP"
	Name = "Form1"
	Add Object command1 As CommandButton With ;
		AutoSize = .T., ;
		Top = 204, ;
		Left = 108, ;
		Height = 27, ;
		Width = 115, ;
		Caption = "WinHTTP requete", ;
		Name = "Command1"
	Add Object image1 As Image With ;
		Height = 110, ;
		Left = 48, ;
		Top = 12, ;
		Width = 241, ;
		Name = "Image1"
	Add Object text1 As TextBox With ;
		Height = 23, ;
		Left = 24, ;
		Top = 132, ;
		Width = 312, ;
		Name = "Text1"
	Procedure command1.Click
	Set Safety Off
	WinHttpReq=Createobject("WinHttp.WinHttpRequest.5.1")

    • ' Assemble an HTTP Request.
WinHttpReq.Open('GET','http://msdn.microsoft.com/vfoxpro/art/Foxpro_boxshot.jpg',.F.) WinHttpReq.Send() Thisform.text1.Value = Transform(WinHttpReq.Status) + " - " + WinHttpReq.StatusText
    • ' Put response data into a file.
Strtofile(WinHttpReq.ResponseBody,'c:\FOXPRO.JPG')
    • ' Load the data file as a picture.
Thisform.image1.Picture= 'c:\FOXPRO.JPG' Endproc ENDDEFINE

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.