次の関数を使用して、現在のブート構成で指定されたプロセッサの数を取得しています。この番号は、ロギングのみに使用されます。
以下の関数は、XP、Vista、7、2003、および 2008 で正常に動作します。ただし、Windows 2012 Server では失敗します。
// -1 = not implemented or not allowed
// 0 = not limited
// >0 = number of processors in the {current} boot entry
function Internal_GetBCDNumberOfProcessors: integer;
var
objBcdStore : OleVariant;
objElement : OleVariant;
objWBL : OleVariant;
objWMIService: OleVariant;
begin
// for more info, see: http://stackoverflow.com/questions/7517965/accessing-bcdstore-from-delphi/7527164#7527164
Result := -1;
try
objWMIService := GetObject('winmgmts:{(Backup,Restore)}\\.\root\wmi:BcdStore');
if (not VarIsNull(objWMIService)) and
boolean(objWMIService.OpenStore('', objBcdStore)) and
(not VarIsNull(objBcdStore)) and
boolean(objBcdStore.OpenObject('{fa926493-6f1c-4193-a414-58f0b2456d1e}', objWBL)) and
(not VarIsNull(objWBL))
then
if objWBL.GetElement($25000061, objElement) and //<-- fails here on Server 2012
(not VarIsNull(objElement))
then
Result := StrToIntDef(objElement.Integer, 0)
else
Result := 0;
except
on E: EOleSysError do
Result := -1;
end;
end;
Win2012 で実行しようとすると、text で例外objWBL.GetElement
が発生します。Google は、このエラー コードに関連する意味のあるものを見つけられませんでした :(EOleSysError
OLE error D0000225
スタック トレースは、VarDispInvoke によって呼び出される DispatchInvoke によって呼び出される System.Win.ComObj.DispatchInvokeError で例外がトリガーされることを示しています。
これはすべて XE2 を使用して再現されました。XE3 でこの問題を再現することはできますが、Delphi RTL がそれと関係があるとは思えません。
この動作の考えられる理由について誰か考えがありますか?