Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi. Can HANDLE be a return type for function? If so, how it can be achieved since there is no such thing as "HANDLE function (void)" ? Thanks.
Posted
Updated 18-Feb-13 3:13am
v2
Comments
Stefan_Lang 18-Feb-13 9:20am    
The return type of a function is whatever you define. Considering that, your question sounds kind of odd. Maybe you didn't express your problem well?

What makes you think there is no such function?
YourAverageCoder 18-Feb-13 9:24am    
So it's possible. Thanks. I thought it wasn't possible because when i googled it, it didn't come up with anything relevant.
Stefan_Lang 18-Feb-13 9:33am    
You may have been confused by the type HANDLE. The Microsoft development environment defines a whole lot of types, including HANDLE. In fact it defines and uses this type in different places and in different ways, depending on which system library you look at.

All you need when defining such a function, is that at the point of declaration the compiler knows that type. I. e. you may need to include the appropriate system header that contains the type definition. In windows, it usually suffices to either use a project wizard for creating a Windows application (which automatically adds the needed headers), or including something like windwos.h

Maybe you should read here: http://en.wikibooks.org/wiki/Windows_Programming/Handles_and_Data_Types[^]

There are actually a whole bunch of handle types defined if you care to look here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751%28v=vs.85%29.aspx[^] Note: Scroll down in the list to where the words start with an H.

Cheers!
 
Share this answer
 
v2
Quote:
Hi. Can HANDLE be a return type for function?

Yes.



Quote:
If so, how it can be achieved since there is no such thing as "HANDLE function (void)" ?

That's false. For instance Windows API's function CreateFile returns a HANDLE.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900