Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating a Child Process with Redirected Input and Outpu
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00810688
Message ID:
00810700
Vues:
23
Hi Franco,
This is an example of how to create an anonymous pipe:
DECLARE INTEGER CreatePipe IN kernel32;
	INTEGER @hReadPipe, INTEGER @hWritePipe,;
	STRING @lpPipeAttributes, INTEGER nSize

LOCAL lcSecurity, hGiveout, hWrite
STORE 0 TO hGiveout, hWrite

lcSecurity = Chr(12) + Repli(Chr(0),7) + Chr(1) + Repli(Chr(0),3)

IF CreatePipe(@hGiveout, @hWrite, @lcSecurity, 16384) = 0
* unable to create a pipe
	RETURN .F.
ENDIF
Take a look, there are many other examples of how to call Win32 functions in Visual FoxPro here:
http://www.news2news.com/vfp

A sample code utilizing named pipes is coming soon.

This is an excerpt:
PROCEDURE StartService
	ThisForm.StopService

	LOCAL cPipeName, cFullName, nOpenMode, nPipeMode, nBlockMode
	cPipeName = LOWER(ALLTRIM(ThisForm.txtName.Value))
	cFullName = '\\.\pipe\' + m.cPipeName

	nOpenMode = ThisForm.ogOpenMode.GetOpenMode()

	nPipeMode = Iif(ThisForm.ogPipeMode.Value=1,;
		BitOr(PIPE_TYPE_MESSAGE,PIPE_READMODE_MESSAGE),;
		BitOr(PIPE_TYPE_BYTE,PIPE_READMODE_BYTE))

	nBlockMode = Iif(ThisForm.ogBlockMode.Value=1,;
		PIPE_NOWAIT, PIPE_WAIT)

	ThisForm.txtHandle.Value = CreateNamedPipe(m.cFullName, nOpenMode,;
		BitOr(nPipeMode, nBlockMode), PIPE_UNLIMITED_INSTANCES,;
		1024, 1024, 20000, 0)

	IF ThisForm.txtHandle.Value = INVALID_HANDLE_VALUE
		= MessageB('Could not create named pipe     ' + Chr(13) +;
			m.cFullName, 48, ' Error')
	ELSE
		WITH ThisForm
			.txtName.ReadOnly=.T.
			STORE .F. TO .ogOpenMode.Enabled,;
				.ogPipeMode.Enabled, .ogBlockMode.Enabled
			.cmdInfo.Enabled=.T.
			.cmdStart.Enabled=.F.
			.cmdStop.Enabled=.T.
			.Caption = 'Named pipe server running...'
			.tm.Interval = 1000
		ENDWITH
	ENDIF
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform