开发者

Windows API reserved parameters

开发者 https://www.devze.com 2023-01-30 03:39 出处:网络
I was wondering why some functions have some parameters that must be set to NULL because of \"reserved parameters\". For example:

I was wondering why some functions have some parameters that must be set to NULL because of "reserved parameters". For example:

LONG WINAPI RegQueryValueEx(
  __in         HKEY hKey,
  __in_opt     LPCTSTR lpValueName,
  __reserved   LPDWORD lpReserved,
  __out_opt    LPDWORD lpType,
  __out_op开发者_如何学Pythont    LPBYTE lpData,
  __inout_opt  LPDWORD lpcbData
);

I can't understand why lpReserved exists? I mean, if it's reserved why put it, wouldn't be simpler to directly omit it?

Thanks! :) (pay no attention to my English please..)


I see at least two reasons.

One would be that this parameter is reserved for future use and possible functionality extension. Making sure it's set to NULL could guarantee to some degree that in the future, when the new functionality has been added it won't break older programs.

Second possible reason would be that this parameter could actually be used internally as part of private API and public part of API dictates to set this parameter to NULL.

Why not to omit it altogether? It's much easier later to extend functionality of the system without changing the interface. It stays binary and source code compatible with the old API and does not require rebuilding of the older software.

0

精彩评论

暂无评论...
验证码 换一张
取 消