Board index » delphi » More pipes problems & Thanks! (Was assorted pipe threads).

More pipes problems & Thanks! (Was assorted pipe threads).

Hiyaz,

Just to say many thanks to all the people on this newsgroup who helped
me with my pipes DLL, particularly ahal...@hotmail.com, who pointed out
a very hard to diagnose slip concerning forgetting to derefence a
pointer, which wasn't caught due to my general pointer casting hackery
defeating the compiler type checking.

I haven't yet fixed all the problems (I haven't touched it for a couple
of weeks due to lack of time), but I have at least fixed all the
synchronisation problems, and subtle bugs.

The only real problem left is that when the following executes:

BiDirPipeLocks.MapHandle:=CreateFileMapping($FFFFFFFF,nil,PAGE_READWRITE,0,SizeOf(TBiDirPipe),MapName);

SharedMapCreator:=not GetLastError=ERROR_ALREADY_EXISTS;

SharedMapCreator is *always* false!!!!

I should mention that:

const
     MapName='MCHGlobalPipeMap';

BiDirPipeLocks.MapHandle is of type THandle.

Is it acceptable to pass string constants to win32 functions requiring
PChars? I would  have thought so, otherwise I'm going to have to do lots
of StrCpy's.

MH.

--
Martin Harvey

mailto:mar...@aziraphale.demon.co.uk
http://www.harvey27.demon.co.uk/mch24/

Undoubtedly, someone can learn Object Oriented Programming from
reading code - after all Alan Kay learned OO by deciphering
an 80 page Simula program thinking it was Algol.
However, most people are not in the same league as Alan.
- Bjarne Stroustrup

 

Re:More pipes problems & Thanks! (Was assorted pipe threads).


Martin,

Is it not the case, since MapName is MCHGlobalPipeMap that this handle _ought_
to be in scope and shareable? If you want to prevent this being shareable,
you'd have to alter thhe security attributes accordingly.

Yes, you can use a literal in an API call PChar parameter.

Charles Johnson

Re:More pipes problems & Thanks! (Was assorted pipe threads).


On Tue, 27 Oct 1998 22:57:55 +0000, Martin Harvey

Quote
<mar...@aziraphale.demon.co.uk> wrote:

Hi !

[snip]

Quote

>SharedMapCreator:=not GetLastError=ERROR_ALREADY_EXISTS;

>SharedMapCreator is *always* false!!!!

Of course, since "not" has a higher precedence (sp?) than "=".

SharedMapCreator:=not (GetLastError=ERROR_ALREADY_EXISTS);

should do the trick.

[snip]

Bye,
Georg

--
Georg Stegmueller
email: gs...@sbox.tu-graz.ac.at

Re:More pipes problems & Thanks! (Was assorted pipe threads).


On Tue, 27 Oct 1998 22:57:55 +0000, Martin Harvey

Quote
<mar...@aziraphale.demon.co.uk> wrote:

(snip)

Quote
>The only real problem left is that when the following executes:

>BiDirPipeLocks.MapHandle:=CreateFileMapping($FFFFFFFF,nil,PAGE_READWRITE,0,SizeOf(TBiDirPipe),MapName);

>SharedMapCreator:=not GetLastError=ERROR_ALREADY_EXISTS;

>SharedMapCreator is *always* false!!!!

Hi Martin,
Sigh, precedence of operators ...  The NOT in your expression is used
as "Bitwise Negation (1's complement)" on the result of GetLastError...

You should use brackets like "NOT (A = B)", IMHO this would even
increase readability (for humans) ...

Quote
>Is it acceptable to pass string constants to win32 functions requiring
>PChars? I would  have thought so, otherwise I'm going to have to do lots
>of StrCpy's.

Do not worry. It is OK (and was since BP 7.0 - that time Win16 of course).

HTH
Helge Pretzlaff

Re:More pipes problems & Thanks! (Was assorted pipe threads).


Quote
Georg Stegmueller wrote:

> SharedMapCreator:=not (GetLastError=ERROR_ALREADY_EXISTS);

> should do the trick.

Awww.... s**t. That was a really stupid error. Many thanks folks :-)

MH.

Other Threads