简体   繁体   中英

Where can I find more information on using Microsoft Windows SLAPI?

In particular, I'm trying to find out how to use it to differentiate between server and server core editions of Windows. The SLGetWindowsInformation() looks simple enough to use, but I don't know what info names are available.

SLAPI = Software Licensing API

Maybe this and this will help.

If you don't want to use GetProductInfo() you can call SLQueryInformationDWORD and specify Kernel-ProductInfo for the name parameter. The returned values are the same as GetProductInfo():D (at least on my testsystem)

You can check this using the GetProductInformation API for that, just check the pdwReturnedProductType parameter for one of the server core values.

Example code (Delphi but not hard to translate to c(++)):

function IsServerCore: Boolean;
var
  osvi: OSVERSIONINFOEX;
  dwPT: DWORD;
begin
  ZeroMemory(@osvi, SizeOf(osvi));
  osvi.dwOSVersionInfoSize := SizeOf(osvi);
  Win32Check(GetVersionEx(osvi));

  Win32Check(GetProductInfo(osvi.dwMajorVersion, osvi.dwMinorVersion,
    osvi.wServicePackMajor, osvi.wServicePackMinor, dwPT));

  case dwPT of
    PRODUCT_DATACENTER_SERVER_CORE,
    PRODUCT_STANDARD_SERVER_CORE,
    PRODUCT_ENTERPRISE_SERVER_CORE,
    PRODUCT_WEB_SERVER_CORE,
    PRODUCT_DATACENTER_SERVER_CORE_V,
    PRODUCT_STANDARD_SERVER_CORE_V,
    PRODUCT_ENTERPRISE_SERVER_CORE_V,
    PRODUCT_STORAGE_EXPRESS_SERVER_CORE,
    PRODUCT_STORAGE_STANDARD_SERVER_CORE,
    PRODUCT_STORAGE_WORKGROUP_SERVER_CORE,
    PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE,
    PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE,
    PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE,
    PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE: Result := True
  else
    Result := False;
  end;
end;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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