13
我們使用以下函數來獲取當前引導配置指定的處理器數量。這個數字純粹用於記錄。無法使用WMI讀取Windows 2012 Server上的BCDStore信息
下面的函數在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運行它,在objWBL.GetElement
引發EOleSysError
例外文本OLE error D0000225
。谷歌並沒有發現什麼有意義的與此相關的錯誤代碼:(
堆棧跟蹤說,異常在System.Win.ComObj.DispatchInvokeError這是由這是由VarDispInvoke稱爲DispatchInvoke稱爲觸發。
所有這一切都是用XE2複製。我會盡量重複使用XE3問題,但我不相信德爾福RTL有什麼關係呢。
有誰有關於這種行爲的原因可能什麼想法?
你有更新4修補程序1嗎? –
是的,我應該有。我會仔細檢查。 (exe是建立在*應該安裝有U4H1的構建服務器上的。) – gabr
UAC是打開還是關閉?過程升高還是不升高? –