CreateNamedPipe without Disconnect & CloseHandle

K

kalpesh

i have a serious problem with CreateNamedPipe:

I am developing a virtual printer driver in VISTA, for that at one
point i use NamedPipe ok..


Now if my all code is run good then there is no any problem becuse at
the end of printing job i disconnect this named pipe and close this
handle.


Now consider the case that my NamedPipe is created and without close
it my printer driver crash at some point means when ever second time
any print job is there it does not createNamePipe gives me error
ERROR_ALREADY_EXISTS that "Cannot create a file when that file
already
exists".


here i write my code for create named pipe


hBitmapPrinterPipe = CreateNamedPipe( L"\\\\.\\Pipe\
\BitmapPrinterPipe", // pipe name
PIPE_ACCESS_DUPLEX|
FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE
|
PIPE_WAIT,


PIPE_UNLIMITED_INSTANCES,
MAX_PATH,
MAX_PATH,
NMPWAIT_USE_DEFAULT_WAIT,
NULL)


if(hBitmapPrinterPipe == INVALID_HANDLE_VALUE) {
GetLastError())
}


Using this code i create my pipe..


so my question is there is any method from which i can reopen my
existing server pipe and close it..
OR there is any solution from which i can open the another instance
of
the same name pipe..
so please write me which solution is best for me and how can i do
it..


Thanks in advance..
 
J

Jon

A bit specialised for this generalist group. You may get some kind soul will
be willing to plough through your code, but you're more likely to get a
response in one of the development newsgroups. Would suggest a repost.

--
Jon


"kalpesh" <kalpeshgedia@gmail.com> wrote in message
news:1183626668.448995.141960@z28g2000prd.googlegroups.com...
>i have a serious problem with CreateNamedPipe:
>
> I am developing a virtual printer driver in VISTA, for that at one
> point i use NamedPipe ok..
>
>
> Now if my all code is run good then there is no any problem becuse at
> the end of printing job i disconnect this named pipe and close this
> handle.
>
>
> Now consider the case that my NamedPipe is created and without close
> it my printer driver crash at some point means when ever second time
> any print job is there it does not createNamePipe gives me error
> ERROR_ALREADY_EXISTS that "Cannot create a file when that file
> already
> exists".
>
>
> here i write my code for create named pipe
>
>
> hBitmapPrinterPipe = CreateNamedPipe( L"\\\\.\\Pipe\
> \BitmapPrinterPipe", // pipe name
> PIPE_ACCESS_DUPLEX|
> FILE_FLAG_OVERLAPPED,
> PIPE_TYPE_BYTE
> |
> PIPE_WAIT,
>
>
> PIPE_UNLIMITED_INSTANCES,
> MAX_PATH,
> MAX_PATH,
> NMPWAIT_USE_DEFAULT_WAIT,
> NULL)
>
>
> if(hBitmapPrinterPipe == INVALID_HANDLE_VALUE) {
> GetLastError())
> }
>
>
> Using this code i create my pipe..
>
>
> so my question is there is any method from which i can reopen my
> existing server pipe and close it..
> OR there is any solution from which i can open the another instance
> of
> the same name pipe..
> so please write me which solution is best for me and how can i do
> it..
>
>
> Thanks in advance..
>
 
A

Andrew McLaren

> "kalpesh" <kalpeshgedia@gmail.com> wrote ...
>>i have a serious problem with CreateNamedPipe:
>>
>> Now consider the case that my NamedPipe is created and without close
>> it my printer driver crash at some point means when ever second time
>> any print job is there it does not createNamePipe gives me error
>> ERROR_ALREADY_EXISTS that "Cannot create a file when that file
>>
>> so my question is there is any method from which i can reopen my
>> existing server pipe and close it..
>> OR there is any solution from which i can open the another instance
>> of the same name pipe..


"Jon" <Email_Address@SomewhereOrOther.com> wrote ...
>A bit specialised for this generalist group. You may get some kind soul
>will be willing to plough through your code, but you're more likely to get
>a response in one of the development newsgroups. Would suggest a repost.


I tend to agree with Jon. "microsoft.public.windows.vista.general" is a
user-oriented group, very few people here know much about Windows or
computers. You will get better answers in a group like
microsoft.public.win32.programmer.networks. (even though your code is
running on a single machine, Named Pipes are usually classified as a form of
network computing ... although they're also very suitable as a form of IPC).

By way of comment ... this is a very fundamental, basic question in Named
Pipes programming. I'm not trying to make fun of you, because you're
probably a much better programmer than me (it wouldn't be hard :). But,
maybe you need to sit down with a good Named Pipes tutorial and really
understand the paradigm. There are many performance implications to
Overlapped IO, completion ports, etc which you will be missing if you just
find a Named Pipes code snippet which "works".

Good luck with the project!
--
Andrew McLaren
amclar (at) optusnet dot com dot au
 
Back
Top Bottom