home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmPipeSource
- Caption = "Pipe Source"
- ClientHeight = 2205
- ClientLeft = 1095
- ClientTop = 1515
- ClientWidth = 3780
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 2205
- ScaleWidth = 3780
- Begin VB.TextBox txtSrc
- Height = 1215
- Left = 180
- TabIndex = 0
- Top = 720
- Width = 3315
- End
- Begin VB.Label Label1
- Caption = "Type into the text box:"
- Height = 255
- Left = 180
- TabIndex = 1
- Top = 240
- Width = 3375
- End
- Attribute VB_Name = "frmPipeSource"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- ' Copyright
- 1997 by Desaware Inc. All Rights Reserved
- Dim destdir$
- Dim hPipeRead&
- Dim hPipeWrite&
- Private Sub Form_Load()
- Dim si As STARTUPINFO
- Dim pi As PROCESS_INFORMATION
- Dim sa As SECURITY_ATTRIBUTES
- Dim res&
- Dim holdstd&
- destdir$ = InputBox$("Enter directory containing PipeDest.exe", , "d:\zdbook3\source\ch14\")
- sa.nLength = Len(sa)
- sa.bInheritHandle = True
- si.cb = Len(si)
- res = CreatePipe(hPipeRead, hPipeWrite, sa, 0)
- If res = 0 Then
- MsgBox "Can't create the pipe"
- Exit Sub
- End If
- Call SetStdHandle(STD_INPUT_HANDLE, hPipeRead)
- ' The child process inherits the handle
- res = CreateProcess(destdir & "PipeDest.exe", vbNullString, sa, sa, True, NORMAL_PRIORITY_CLASS, ByVal 0&, vbNullString, si, pi)
- If res = 0 Then
- MsgBox "Can't create process"
- Unload Me
- Exit Sub
- End If
- ' Always close the process handles
- Call CloseHandle(pi.hProcess)
- Call CloseHandle(pi.hThread)
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- If hPipeWrite <> 0 Then
- Call CloseHandle(hPipeWrite)
- End If
- End Sub
- Private Sub txtSrc_KeyPress(KeyAscii As Integer)
- Dim char As Byte
- Dim res&
- char = KeyAscii
- Dim written&
- res = WriteFile(hPipeWrite, char, 1, written, 0)
- KeyAscii = 0
- End Sub
-