Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows API reserved parameters

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_opt    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..)

like image 491
BlackBear Avatar asked Dec 08 '10 21:12

BlackBear


1 Answers

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.

like image 162
detunized Avatar answered Sep 18 '22 10:09

detunized