Delphi Wmi 클래스 생성기 는 WMI(Windows Management Instrumentation)에 액세스하기 위해 완전히 문서화된 오브젝트 파스칼 클래스를 생성하는 애플리케이션입니다.
생성된 코드는 Delphi 7, 2005, BDS/Turbo 2006 및 RAD Studio 2007-2010, XE-XE7 및 Free Pascal Compiler 2.2.4(win32)와 호환됩니다.
Delphi 2005부터 사용 가능한 도움말 통찰력 기능과 호환되는 전체 문서화된 클래스를 만듭니다.

참고: 메소드, 매개변수 및 속성 설명의 언어는 단위를 생성하는 창의 언어에 따라 달라집니다.
애플리케이션은 대략 99%의 사용 준비가 완료된 코드를 생성합니다. 그러나 일부 WMI 클래스는 잘못된 형식으로 메타데이터를 노출하거나 메타데이터의 구조가 개체 파스칼 코드를 생성하는 데 사용된 알고리즘과 호환되지 않는 경우가 있습니다. 이러한 경우 코드를 수동으로 패치해야 합니다.
이 페이지에서는 문제가 있는 수업을 찾을 수 있습니다. 또 다른 옵션은 생성된 패치 클래스를 저장소에서 직접 다운로드하는 것입니다.
이 도구는 WMI 클래스에 저장된 메타데이터(속성, 메소드, 한정자, 유효한 값 및 설명)를 추출하고 구문 분석하여 오브젝트 파스칼 호환 클래스를 다시 생성합니다.
응용 프로그램에서 생성된 각 오브젝트 파스칼 클래스는 기본 클래스 TWmiClass의 자손입니다. 이 클래스는 wmi에 대한 액세스를 캡슐화하고, 호출 클래스에서 반환된 값(OleVariant)을 기본 유형으로 변환하고, 내부 컬렉션(버퍼)에 값을 저장합니다. 속성 및 인스턴스 주소입니다.
TWmiClass 클래스는 두 가지 모드로 컴파일될 수 있습니다.
Microsoft WMI 스크립팅 V1.2 라이브러리 사용
이 래퍼(WbemScripting_TLB)는 델파이 컴파일러에 의해 생성됩니다. 이 옵션은 WMI에 대한 초기 액세스를 향상시킵니다(이 옵션은 FPC와 호환되지 않음). 이 모드를 사용하는 경우 프로젝트에 WbemScripting_TLB 유닛을 포함해야 합니다.
후기 바인딩 사용
이 옵션은 작은 exe 파일을 생성해야 할 때 유용합니다. 초기 실행에서는 성능이 조금 더 느려집니다.
이 2가지 모드 중에서 선택하려면 uWmiDelphiClass 유닛에서 다음 줄을 주석 처리하거나 주석 처리를 제거해야 합니다.
{ $DEFINE WbemScripting_TLB }응용 프로그램의 기본 창에서 생성할 네임스페이스와 클래스를 선택하고(기본적으로 WMI 네임스페이스의 모든 클래스가 선택됨) "단위 생성" 버튼을 누르면 도구가 다음 위치에 폴더를 생성합니다. 네임스페이스 이름과 이 폴더 내부의 exe가 테스트 콘솔 프로젝트, uWmiDelphiClass.pas 파일의 복사본 및 선택한 클래스로 생성됩니다. 각 클래스는 "u" 문자와 Wmi 클래스 이름으로 구성된 이름을 가진 별도의 단위에 저장됩니다. 예를 들어 Win32_BIOS 클래스의 단위 이름은 uWin32_BIOS.pas 입니다.
소스 저장소에서 생성된 클래스의 사용법에 대한 데모 세트를 찾을 수 있습니다.
Win32_BaseBoard WMI 클래스를 사용하는 매우 간단한 콘솔 애플리케이션을 확인해 보세요.
program TestWin32_BaseBoard;
{ $APPTYPE CONSOLE }
uses
SysUtils,
uWin32_BaseBoard in ' ....root_CIMV2uWin32_BaseBoard.pas ' ,
uWmiDelphiClass in ' ....uWmiDelphiClass.pas ' ; // the base class
procedure TestBaseBoard ;
var
BaseBoard : TWin32_BaseBoard;
begin
BaseBoard:=TWin32_BaseBoard.Create;
try
Writeln( ' Base Board Info ' );
Writeln( ' --------------- ' );
Writeln( ' Manufacturer ' +BaseBoard.Manufacturer);
Writeln( ' Model ' +BaseBoard.Model);
Writeln( ' SKU ' +BaseBoard.SKU);
Writeln( ' SerialNumber ' +BaseBoard.SerialNumber);
Writeln( ' PartNumber ' +BaseBoard.PartNumber);
Writeln( ' Tag ' +BaseBoard.Tag);
Readln;
finally
BaseBoard.Free;
end ;
end ;
begin
try
TestBaseBoard;
except
on E:Exception do
begin
Writeln(E.Classname, ' : ' , E.Message);
Readln;
end ;
end ;
end .이 도구는 Delphi XE를 사용하여 컴파일되었습니다.
Win32_Share WMI 클래스용 애플리케이션에서 생성된 소스 코드 샘플입니다.
// / <summary>
// / Unit generated using the Delphi Wmi class generator tool, Copyright Rodrigo Ruz V. 2010
// / Application version 0.1.0.113
// / WMI version 7600.16385
// / Creation Date 23-12-2010 22:39:55
// / Namespace rootCIMV2 Class Win32_Share
// / MSDN info about this class http://msdn2.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/Win32_Share.asp
// / </summary>
{ $IFDEF FPC }
{ $MODE DELPHI } { $H+ }
{ $DEFINE OLD_DELPHI }
{ $ENDIF }
unit uWin32_Share;
interface
uses
Classes,
Activex,
Variants,
ComObj,
uWmiDelphiClass;
type
{ $IFDEF FPC }
Cardinal=Longint;
Int64=Integer;
Word=Longint;
{ $ENDIF }
{ $IFNDEF FPC }
{ $IF CompilerVersion <= 15 }
{ $DEFINE OLD_DELPHI }
{ $IFEND }
{ $ENDIF }
{ $IFDEF UNDEF }{ $REGION 'Documentation' }{ $ENDIF }
// / <summary>
// / The Win32_Share class represents a shared resource on a Win32 system. This may be a disk drive, printer, interprocess communication, or other shareable device.
// / Example: C:PUBLIC.
// / </summary>
{ $IFDEF UNDEF }{ $ENDREGION }{ $ENDIF }
TWin32_Share= class (TWmiClass)
private
FAccessMask : Cardinal;
FAllowMaximum : Boolean;
FCaption : String;
FDescription : String;
FInstallDate : TDateTime;
FMaximumAllowed : Cardinal;
FName : String;
FPath : String;
FStatus : String;
FType : Cardinal;
public
constructor Create(LoadWmiData : boolean=True); overload;
destructor Destroy;Override;
{ $IFDEF UNDEF }{ $REGION 'Documentation' }{ $ENDIF }
// / <summary>
// / This property has been deprecated in favour of the GetAccessMask method of this
// / class due to the expense of calling GetEffectiveRightsFromAcl. The value will
// / be set to NULL
// / </summary>
{ $IFDEF UNDEF }{ $ENDREGION }{ $ENDIF }
property AccessMask : Cardinal read FAccessMask;
{ $IFDEF UNDEF }{ $REGION 'Documentation' }{ $ENDIF }
// / <summary>
// / The AllowMaximum property indicates whether the number of concurrent users for this resource has been limited.
// / Values: TRUE or FALSE. A value of TRUE indicates the number of concurrent users of this resource has not been limited and the value in the MaximumAllowed property is ignored.
// / </summary>
{ $IFDEF UNDEF }{ $ENDREGION }{ $ENDIF }
property AllowMaximum : Boolean read FAllowMaximum;
{ $IFDEF UNDEF }{ $REGION 'Documentation' }{ $ENDIF }
// / <summary>
// / The Caption property is a short textual description (one-line string) of the
// / object.
// / </summary>
{ $IFDEF UNDEF }{ $ENDREGION }{ $ENDIF }
property Caption : String read FCaption;
{ $IFDEF UNDEF }{ $REGION 'Documentation' }{ $ENDIF }
// / <summary>
// / The Description property provides a textual description of the object.
// / </summary>
{ $IFDEF UNDEF }{ $ENDREGION }{ $ENDIF }
property Description : String read FDescription;
{ $IFDEF UNDEF }{ $REGION 'Documentation' }{ $ENDIF }
// / <summary>
// / The InstallDate property is datetime value indicating when the object was
// / installed. A lack of a value does not indicate that the object is not installed.
// / </summary>
{ $IFDEF UNDEF }{ $ENDREGION }{ $ENDIF }
property InstallDate : TDateTime read FInstallDate;
{ $IFDEF UNDEF }{ $REGION 'Documentation' }{ $ENDIF }
// / <summary>
// / The MaximumAllowed property indicates the limit on the maximum number of users allowed to use this resource concurrently. The value is only valid if the AllowMaximum member set to FALSE
// / Example: 10.
// / </summary>
{ $IFDEF UNDEF }{ $ENDREGION }{ $ENDIF }
property MaximumAllowed : Cardinal read FMaximumAllowed;
{ $IFDEF UNDEF }{ $REGION 'Documentation' }{ $ENDIF }
// / <summary>
// / The Name property indicates the alias given to a path set up as a share on a Win32 system.
// / Example: public.
// / </summary>
{ $IFDEF UNDEF }{ $ENDREGION }{ $ENDIF }
property Name : String read FName;
{ $IFDEF UNDEF }{ $REGION 'Documentation' }{ $ENDIF }
// / <summary>
// / The Path property indicates the local path of the Win32 share.
// / Example: C:Program Files
// / </summary>
{ $IFDEF UNDEF }{ $ENDREGION }{ $ENDIF }
property Path : String read FPath;
{ $IFDEF UNDEF }{ $REGION 'Documentation' }{ $ENDIF }
// / <summary>
// / The Status property is a string indicating the current status of the object.
// / Various operational and non-operational statuses can be defined. Operational
// / statuses are "OK", "Degraded" and "Pred Fail". "Pred Fail" indicates that an
// / element may be functioning properly but predicting a failure in the near
// / future. An example is a SMART-enabled hard drive. Non-operational statuses can
// / also be specified. These are "Error", "Starting", "Stopping" and "Service". The
// / latter, "Service", could apply during mirror-resilvering of a disk, reload of a
// / user permissions list, or other administrative work. Not all such work is on-
// / line, yet the managed element is neither "OK" nor in one of the other states.
// / </summary>
{ $IFDEF UNDEF }{ $ENDREGION }{ $ENDIF }
property Status : String read FStatus;
{ $IFDEF UNDEF }{ $REGION 'Documentation' }{ $ENDIF }
// / <summary>
// / The Type property specifies the type of resource being shared. Types include
// / disk drives, print queues, interprocess communications (IPC), and general
// / devices.
// / </summary>
{ $IFDEF UNDEF }{ $ENDREGION }{ $ENDIF }
property { $IFDEF OLD_DELPHI } _Type { $ELSE } & Type { $ENDIF } : Cardinal read FType;
function Create ( const Access : OleVariant; const Description : String; const MaximumAllowed : Cardinal; const Name : String; const Password : String; const Path : String; const { $IFDEF OLD_DELPHI } _Type { $ELSE } & Type { $ENDIF } : Cardinal): Integer;overload;
function SetShareInfo ( const Access : OleVariant; const Description : String; const MaximumAllowed : Cardinal): Integer;
function GetAccessMask : Integer;
function Delete : Integer;
procedure SetCollectionIndex (Index : Integer); override;
end ;
{ $IFDEF UNDEF }{ $REGION 'Documentation' }{ $ENDIF }
// / <summary>
// / Return the description for the value of the property TWin32_Share.Type
// / </summary>
{ $IFDEF UNDEF }{ $ENDREGION }{ $ENDIF }
function GetTypeAsString ( const APropValue:Cardinal) : string;
implementation
function GetTypeAsString ( const APropValue:Cardinal) : string;
begin
Result:= ' ' ;
case APropValue of
0 : Result:= ' Disk Drive ' ;
1 : Result:= ' Print Queue ' ;
2 : Result:= ' Device ' ;
3 : Result:= ' IPC ' ;
2147483648 : Result:= ' Disk Drive Admin ' ;
2147483649 : Result:= ' Print Queue Admin ' ;
2147483650 : Result:= ' Device Admin ' ;
2147483651 : Result:= ' IPC Admin ' ;
end ;
end ;
{ TWin32_Share }
constructor TWin32_Share.Create(LoadWmiData : boolean=True);
begin
inherited Create(LoadWmiData, ' rootCIMV2 ' , ' Win32_Share ' );
end ;
destructor TWin32_Share.Destroy;
begin
inherited ;
end ;
procedure TWin32_Share.SetCollectionIndex (Index : Integer);
begin
if (Index>= 0 ) and (Index<=FWmiCollection.Count- 1 ) and (FWmiCollectionIndex<>Index) then
begin
FWmiCollectionIndex:=Index;
FAccessMask := VarCardinalNull( inherited Value [ ' AccessMask ' ]);
FAllowMaximum := VarBoolNull( inherited Value [ ' AllowMaximum ' ]);
FCaption := VarStrNull( inherited Value [ ' Caption ' ]);
FDescription := VarStrNull( inherited Value [ ' Description ' ]);
FInstallDate := VarDateTimeNull( inherited Value [ ' InstallDate ' ]);
FMaximumAllowed := VarCardinalNull( inherited Value [ ' MaximumAllowed ' ]);
FName := VarStrNull( inherited Value [ ' Name ' ]);
FPath := VarStrNull( inherited Value [ ' Path ' ]);
FStatus := VarStrNull( inherited Value [ ' Status ' ]);
FType := VarCardinalNull( inherited Value [ ' Type ' ]);
end ;
end ;
// static, OutParams=1, InParams>0
function TWin32_Share.Create ( const Access : OleVariant; const Description : String; const MaximumAllowed : Cardinal; const Name : String; const Password : String; const Path : String; const { $IFDEF OLD_DELPHI } _Type { $ELSE } & Type { $ENDIF } : Cardinal): Integer;
var
objInParams : OleVariant;
objOutParams : OleVariant;
begin
objInParams := GetInstanceOf.Methods_.Item( ' Create ' ).InParameters.SpawnInstance_();
objInParams.Properties_.Item( ' Access ' ). Value := Access;
objInParams.Properties_.Item( ' Description ' ). Value := Description;
objInParams.Properties_.Item( ' MaximumAllowed ' ). Value := MaximumAllowed;
objInParams.Properties_.Item( ' Name ' ). Value := Name ;
objInParams.Properties_.Item( ' Password ' ). Value := Password;
objInParams.Properties_.Item( ' Path ' ). Value := Path;
objInParams.Properties_.Item( ' Type ' ). Value := { $IFDEF OLD_DELPHI } _Type { $ELSE } & Type { $ENDIF } ;
objOutParams := WMIService.ExecMethod(WmiClass, ' Create ' , objInParams, 0 , GetNullValue);
Result := VarIntegerNull(objOutParams.ReturnValue);
end ;
// not static, OutParams=1, InParams>0
function TWin32_Share.SetShareInfo ( const Access : OleVariant; const Description : String; const MaximumAllowed : Cardinal): Integer;
var
ReturnValue : OleVariant;
begin
ReturnValue := GetInstanceOf.SetShareInfo(Access,Description,MaximumAllowed);
Result := VarIntegerNull(ReturnValue);
end ;
// not static, OutParams=1, InParams=0
function TWin32_Share.GetAccessMask : integer;
var
ReturnValue : OleVariant;
begin
ReturnValue := GetInstanceOf.GetAccessMask;
Result := VarIntegerNull(ReturnValue);
end ;
// not static, OutParams=1, InParams=0
function TWin32_Share.Delete : integer;
var
ReturnValue : OleVariant;
begin
ReturnValue := GetInstanceOf.Delete;
Result := VarIntegerNull(ReturnValue);
end ;
end .설치 프로그램을 찾고 계십니까? 출시 지역을 확인하세요