HINSTANCE data type HINSTANCE data type

Reprinted: https://www.cnblogs.com/furzoom/p/hinstance.html

HINSTANCE data type

 

Author: Ma Yan ( Furzoom ) ( http://www.cnblogs.com/furzoom/ )
Copyright: garden belongs to the author of this blog and common to all. When reprinting, please indicate the detailed link of this article in an obvious place. Please do not delete this statement without the author's consent. Thank you for your contribution to the protection of intellectual property rights.

在看《 WINDOWS程序设计 》过程中,对于HINSTANCE的理解很重要,网上多数说其是一个整型变量,其实是不对的。http://furzoom.com/

HINSTANCE定义

HINSTANCE数据类型-枫竹梦

通过查找HINSTANCE的定义有WINDEF.H中为:

001
DECLARE_HANDLE( HINSTANCE );

Guess it should be a macro definition, continue to look at the definition of DECLARE_HANDLE (), also in WINDEF.H, as follows:

001
002
003
004
005
006
007
008
#ifdef STRICT
typedef void * HANDLE ;
#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
#else
typedef PVOID HANDLE ;
#define DECLARE_HANDLE(name) typedef HANDLE name
#endif
typedef HANDLE * PHANDLE ;

It can be seen that DECLARE_HANDLE () is defined in a pre-defined condition, so whether the condition is true, continue to search for the definition of STRICT, at the beginning of WINDEF.H are as follows:

001
002
003
004
005
006
007
008
#ifndef _WINDEF_
#define _WINDEF_
 
#ifndef NO_STRICT
#ifndef STRICT
#define STRICT 1
#endif
#endif /* NO_STRICT */

In this way, we know that STRICT is defined by default.

Then look at the definition of DECLARE_HANDLE () macro,

001
#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name

## is a character connection, then

001
DECLARE_HANDLE( HINSTANCE )

Equivalent to

001
struct HINSTANCE__ { int unused; }; typedef struct HINSTANCE__ * HINSTANCE ;

HINSTANCE is a pointer variable that points to the HINSTANCE structure, and there is only one int variable in the structure. In WINDOWS, handles are mostly defined in this way.

From: HINSTANCE data type - WINDOWS programming - Maple Bamboo Dream

在看《 WINDOWS程序设计 》过程中,对于HINSTANCE的理解很重要,网上多数说其是一个整型变量,其实是不对的。http://furzoom.com/

HINSTANCE定义

HINSTANCE数据类型-枫竹梦

通过查找HINSTANCE的定义有WINDEF.H中为:

001
DECLARE_HANDLE( HINSTANCE );

Guess it should be a macro definition, continue to look at the definition of DECLARE_HANDLE (), also in WINDEF.H, as follows:

001
002
003
004
005
006
007
008
#ifdef STRICT
typedef void * HANDLE ;
#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
#else
typedef PVOID HANDLE ;
#define DECLARE_HANDLE(name) typedef HANDLE name
#endif
typedef HANDLE * PHANDLE ;

It can be seen that DECLARE_HANDLE () is defined in a pre-defined condition, so whether the condition is true, continue to search for the definition of STRICT, at the beginning of WINDEF.H are as follows:

001
002
003
004
005
006
007
008
#ifndef _WINDEF_
#define _WINDEF_
 
#ifndef NO_STRICT
#ifndef STRICT
#define STRICT 1
#endif
#endif /* NO_STRICT */

In this way, we know that STRICT is defined by default.

Then look at the definition of DECLARE_HANDLE () macro,

001
#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name

## is a character connection, then

001
DECLARE_HANDLE( HINSTANCE )

Equivalent to

001
struct HINSTANCE__ { int unused; }; typedef struct HINSTANCE__ * HINSTANCE ;

HINSTANCE is a pointer variable that points to the HINSTANCE structure, and there is only one int variable in the structure. In WINDOWS, handles are mostly defined in this way.

From: HINSTANCE data type - WINDOWS programming - Maple Bamboo Dream

Guess you like

Origin www.cnblogs.com/MCSFX/p/12670894.html