|
Author Topic:   Handles
Kaeto
Member
posted October 29, 1999 10:22 AM            
Does Windows have something against handles being global? Has anyone had a problem with global handles? I can't get a global handle to work at all, but if I cut and paste the definition into my function, it works fine. I don't need a global handle, I thought I did but I don't, but I was just wondering if having global handles is taboo or something???

IP:

LDA Seumas
unregistered
posted October 29, 1999 08:05 PM           
You mean, a global variable (c-speak) that is a handle (windows-speak)? I don't see why there should be a problem, as long as you only use it when it's been properly initialized, properly get rid of it when you're done, and properly share it among code modules using an "extern" declaration in the headers. As with any globals shared among modules, it should only be defined (instantiated) in one module, and externally declared in all others.

------------------
-- Seumas McNally, Lead Programmer, Longbow Digital Arts

IP:

Kaeto
Member
posted October 30, 1999 12:16 PM            
It was a HANDLE declared up near the top of the only module in a small test program that was supposed to open a file and write some data to it. When I put "HANDLE afile;" on a line outside of any func declaration, my program ran for about half a second and then stopped, even when I wasn't using the handle anywhere. If I moved it INTO a function, no problem. Very wierd. Is windows just ^&$#&ing up or are you not supposed to do this?

IP: