*." & GetExtension(strFileName)
CDlg1.FileName = Left(strFileName, InStr(strFileName, ".") - 1)
ReSelect: CDlg1.ShowSave
If Err.Number = 32755 Then
AckByte() = StrConv("Cancel", vbFromUnicode)
WriteFile hNamePipe, AckByte(0), UBound(AckByte()) + 1, BytesWrited, 0
MsgBox "你选择了取消键!", vbInformation Or vbOKOnly
Exit Sub
End If
hFile = CreateFile(CDlg1.FileName, GENERIC_READ Or GENERIC_WRITE, 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)
If hFile = -1 Then
MsgBox "无法创建指定文件,请重新选择文件名!", vbInformation Or vbOKOnly
GoTo ReSelect
End If
AckByte() = StrConv("RecvOk", vbFromUnicode)
WriteFile hNamePipe, AckByte(0), UBound(AckByte()) + 1, BytesWrited, 0
End If
Else
WriteFile hFile, inBuffer(0), BytesReaded, BytesWrited, 0
AckByte() = StrConv("RecvOk", vbFromUnicode)
WriteFile hNamePipe, AckByte(0), UBound(AckByte()) + 1, BytesWrited, 0
End If
Loop Until 1 = 0
End Sub
Private Function GetExtension(ByVal FileName$) As String
GetExtension = Right(FileName, Len(FileName) - InStr(FileName, "."))
End Function
Public Sub ByteCopy(bySrc() As Byte, byDes() As Byte)
Dim i&
For i = LBound(bySrc) To UBound(bySrc)
byDes(i) = bySrc(i)
Next
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
CloseHandle hFile
CloseHandle hNamePipe
End Sub
该程序在VB5、Windows NT 4.0上调试通过。
在处理网络事务上,命名管道接口比Net BIOS要好,而且只需使用一个简单的调用就可达到目的,而无需通过Net BIOS执行许多操作。然而,命名管道接口并不提供Net BIOS的一些特征,如无连接数据报服务和允许向一个组发送消息的命名功能。
……