Server:===============================================
const
pipename:string='\\.\pipe\testpipe';
var
SPipeHandle:THandle;
Se:TSecurityAttributes;
WriteBuffer:DWORD;
Buffer:pchar;
begin
Se.nLength:=Sizeof(TSecurityAttributes);
Se.lpSecurityDescriptor:=nil;
Se.bInheritHandle:=True; SPipeHandle:=CreateNamedPipe(pchar(pipename),PIPE_ACCESS_DUPLE OR FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE or PIPE_WAIT,2,512,512,1000,@Se);
if SPipeHandle=-1 then
raise Exception.Create('Create pipe Failed');
try
if not ConnectNamedPipe(SPipeHandle,nil) then begin
CloseHandle(SPipeHandle);
Raise Exception.Create(IntToStr(GetLastError)+'fail con');end;
Buffer:=StrAlloc(512);
Buffer:=Pchar(Memo1.Text);
WriteFile(SPipeHandle,Buffer[0],512,WriteBuffer,nil);
finally
DisConnectNamedPipe(SPipeHandle);
CloseHandle(SPipeHandle);
end;
=================================
當在Win98下執行到ConnectNamedPipe時,立即返回為False(完全沒有時間上的等待),并且
GetLastError=6(Msg:無效代碼)。在2000下無此問題。這是什么原因,是否ConnectNamedPipe在
Win98下有什么限制?
const
pipename:string='\\.\pipe\testpipe';
var
SPipeHandle:THandle;
Se:TSecurityAttributes;
WriteBuffer:DWORD;
Buffer:pchar;
begin
Se.nLength:=Sizeof(TSecurityAttributes);
Se.lpSecurityDescriptor:=nil;
Se.bInheritHandle:=True; SPipeHandle:=CreateNamedPipe(pchar(pipename),PIPE_ACCESS_DUPLE OR FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE or PIPE_WAIT,2,512,512,1000,@Se);
if SPipeHandle=-1 then
raise Exception.Create('Create pipe Failed');
try
if not ConnectNamedPipe(SPipeHandle,nil) then begin
CloseHandle(SPipeHandle);
Raise Exception.Create(IntToStr(GetLastError)+'fail con');end;
Buffer:=StrAlloc(512);
Buffer:=Pchar(Memo1.Text);
WriteFile(SPipeHandle,Buffer[0],512,WriteBuffer,nil);
finally
DisConnectNamedPipe(SPipeHandle);
CloseHandle(SPipeHandle);
end;
=================================
當在Win98下執行到ConnectNamedPipe時,立即返回為False(完全沒有時間上的等待),并且
GetLastError=6(Msg:無效代碼)。在2000下無此問題。這是什么原因,是否ConnectNamedPipe在
Win98下有什么限制?
解决方案 »
- 请高手支个招!在线等
- 菜鸟问题:一个.pas文件编译出现错误,大侠们给看看。结贴马上给分!
- 求救各位
- 如何在monthcalonder显示多个月
- 急求delphi 7 用流方式传输文件的例子!感激不尽~
- 在D7中,有一个fsMDIForm,fsMDIChild若干,问题1.怎样可让一个MDIchild成为活动窗体.2.怎样可判断一个MDIchild已创建?
- 怎样写类哪? 求教!
- 请教高手,怎样得到要连接的服务器的计算机名和ip,并且要知道该服务器上是否已安装了sql server 2000
- 如何关闭CreateOleObject('internetExplorer.Application')打开的IE窗口
- 请教一下,cxgrid怎么知道数据显示完了
- 数据库指针移动的问题?郁闷
- 看不出有什么问题!
LPCTSTR lpName, // pointer to pipe name
DWORD dwOpenMode, // pipe open mode
DWORD dwPipeMode, // pipe-specific modes
DWORD nMaxInstances, // maximum number of instances
DWORD nOutBufferSize, // output buffer size, in bytes
DWORD nInBufferSize, // input buffer size, in bytes
DWORD nDefaultTimeOut, // time-out time, in milliseconds
LPSECURITY_ATTRIBUTES lpSecurityAttributes // pointer to security attributes
);
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.