简体   繁体   English

CONFIGRET返回类型是什么意思?

[英]What does the CONFIGRET return-type mean?

I was taking a look at the PnP Configuration Manager functions and saw that each begins with these three macros: 我查看了PnP配置管理器功能 ,发现每个功能都以以下三个宏开头:

CMAPI CONFIGRET WINAPI

I had to dig inside CfgMgr32.h to find CMAPI , which is defined as: 我必须在CfgMgr32.h中进行挖掘以找到CMAPI ,该CMAPI定义为:

#if !defined (_CFGMGR32_)
#define CMAPI     DECLSPEC_IMPORT
#else
#define CMAPI
#endif

According to Tim Roberts' article on DLL's in Kernel Mode , this allows functions with CMAPI to be either loaded at run-time or link-time. 根据蒂姆·罗伯茨(Tim Roberts)关于内核模式下DLL的文章 ,这允许带有CMAPI函数在运行时或链接时加载。 And we already know that WINAPI is just a macro for a calling convention . 我们已经知道WINAPI只是调用约定

But what about CONFIGRET ? 但是CONFIGRET呢? From CfgMgr32.h , it is defined as: CfgMgr32.h定义为:

//
// Standardized Return Value data type
//
typedef _Return_type_success_(return == 0) DWORD        RETURN_TYPE;
typedef RETURN_TYPE  CONFIGRET;

I've never seen this before, what does this mean? 我以前从未见过,这是什么意思? What is the return type of these functions? 这些函数的返回类型是什么?

The underlying data type for CONFIGRET is a DWORD , as defined in CfgMgr32.h : CONFIGRET的基础数据类型是DWORD ,如CfgMgr32.h中所定义:

//
// Standardized Return Value data type
//
typedef _Return_type_success_(return == 0) DWORD        RETURN_TYPE;
typedef RETURN_TYPE  CONFIGRET;

CONFIGRET is an alias for RETURN_TYPE , and RETURN_TYPE an alias for a DWORD with additional semantic information attached by means of SAL annotations (SAL annotations are used by static code analyzers). CONFIGRET是一个别名RETURN_TYPE ,和RETURN_TYPE别名为一个DWORD与借助于附接附加的语义信息SAL注释 (SAL注释由静态代码分析仪上使用)。

Annotating Function Behavior contains detailed information on this particular annotation: 注释功能行为包含有关此特定注释的详细信息:

_Return_type_success_(expr)

May be applied to a typedef. 可以应用于typedef。 Indicates that all functions that return that type and do not explicitly have _Success_ are annotated as if they had _Success_(expr) . 指示所有返回该类型且没有显式具有_Success_的函数都被注释为好像具有_Success_(expr) _Return_type_success_ cannot be used on a function or a function pointer typedef. _Return_type_success_不能用于函数或函数指针typedef。


The CMAPI preprocessor symbol defined in CfgMgr32.h as 所述CMAPICfgMgr32.h定义为预处理器符号

#if !defined (_CFGMGR32_)
#define CMAPI     DECLSPEC_IMPORT
#else
#define CMAPI
#endif

serves a different purpose, than what you proposed: It allows the same header file to be used for the consumer and producer of the library. 与您建议的目的不同,它的目的不同:它允许将相同的头文件用于库的使用者和生产者。 The producer defines the _CFGMGR32_ preprocessor symbol, and provides the function definitions. 生产者定义_CFGMGR32_预处理器符号,并提供函数定义。 The consumer doesn't define the _CFGMGR32_ preprocessor symbol, and CMAPI expands to an import specifier ( __declspec(dllimport) , defined in ntdef.h ). 使用者没有定义_CFGMGR32_预处理器符号,并且CMAPI扩展为导入说明符( __declspec(dllimport) ,在ntdef.h中定义)。 This is used for Load-Time Dynamic Linking (vs. Run-Time Dynamic Linking ). 这用于加载时动态链接 (相对于运行时动态链接 )。 It is not used for static linking at all. 根本不用于静态链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM