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.
 
A

Andrew McLaren

Jon said:
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top