Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
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 18-Feb-13 3:11am
Edited 18-Feb-13 3:13am
v2
Comments
Stefan_Lang at 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 at 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 at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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!
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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

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

  Print Answers RSS
0 OriginalGriff 6,651
1 Sergey Alexandrovich Kryukov 6,400
2 CPallini 5,230
3 George Jonsson 3,574
4 Gihan Liyanage 2,542


Advertise | Privacy | Mobile
Web03 | 2.8.140921.1 | Last Updated 18 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100