Odczyt SerialNumber płyty głównej z Win32_BaseBoard pod Windows XP

0

Hello,

Problem jak w temacie. Kawałek kodu poniżej, pisane w Delphi 7, działa pod Win7 ale pod XP już jest pusto.
Niestety nie mam możliwości debugowania pod XP wiec nie wiem co się dzieje w kodem.

Przeczytałem, poniższy artykuł, ale nie to jest chyba moim problemem bo nie dostaje żadnego błędu
http://theroadtodelphi.wordpress.com/2010/11/28/be-careful-when-you-import-the-microsoft-wmiscripting-library/

Nie chce korzystać z dodatkowych komponentów.
Ktoś nakieruje?

procedure TForm1.ShowMotherBoardInfo;
var
  WMIServices     : ISWbemServices;
  SWbemObjectSet  : ISWbemObjectSet;
  SObject         : ISWbemObject;
  Enum            : IEnumVariant;
  TempObj         : OleVariant;
  Value           : Cardinal;
  SWbemPropertySet: ISWbemPropertySet;
begin
  WMIServices := CoSWbemLocator.Create.ConnectServer('.', 'root\cimv2','', '', '', '', 0, nil);
  SWbemObjectSet := WMIServices.ExecQuery('Select * FROM Win32_BaseBoard', 'WQL', 0, nil);
  Enum := (SWbemObjectSet._NewEnum) as IEnumVariant;

  while (Enum.Next(1, TempObj, Value) = S_OK) do
  begin
    SObject     := IUnknown(tempObj) as ISWBemObject;
    SWbemPropertySet := SObject.Properties_;
    Memo1.Lines.add('SerialNumber  = ' + SWbemPropertySet.Item('SerialNumber', 0).Get_Value);
  end;
end;
0
{ Pobieranie numeru seryjnego płyty głównej }
function GetMotherBoardSerial: String;
var
  objWMIService: OLEVariant;
  colItems: OLEVariant;
  colItem: OLEVariant;
  oEnum: IEnumvariant;
  iValue: LongWord;

  function GetWMIObject(const objectName: String): IDispatch;
  var
    chEaten: Integer;
    BindCtx: IBindCtx;
    Moniker: IMoniker;
  begin
    OleCheck(CreateBindCtx(0, BindCtx));
    OleCheck(MkParseDisplayName(BindCtx, StringToOleStr(objectName), chEaten, Moniker));
    OleCheck(Moniker.BindToObject(BindCtx, nil, IDispatch, Result));
  end;

begin
  Result := '';
  objWMIService := GetWMIObject('winmgmts:\\localhost\root\cimv2');
  colItems := objWMIService.ExecQuery('SELECT SerialNumber FROM Win32_BaseBoard', 'WQL', 0);
  oEnum := IUnknown(colItems._NewEnum) as IEnumvariant;
  if oEnum.Next(1, colItem, iValue) = 0 then
    Result := VarToStr(colItem.SerialNumber);
end;

Procedura sprawdzona i działa na pewno na win 98, win xp, win 7 , Vista

1 użytkowników online, w tym zalogowanych: 0, gości: 1