rruz / delphi-wmi-class-generator Goto Github PK
View Code? Open in Web Editor NEWCreates Object Pascal classes to access the WMI
Home Page: https://theroadtodelphi.wordpress.com/
Creates Object Pascal classes to access the WMI
Home Page: https://theroadtodelphi.wordpress.com/
So get this to compile on Lazarus 1.4.0 and FPC 2.6.4 I had to change a few lines of uWmiDelphiClass.pas:
101 moved
{$IFDEF WMI_LateBinding}
FSWbemLocator : OleVariant;
//FWMIService : OleVariant; // commented out and moved:
to line 104:
{$IFDEF FPC}
FWMIService : OleVariant;
Line 192:
{$IFDEF WMI_LateBinding}
property SWbemLocator : OleVariant read FSWbemLocator;
property WMIService : OleVariant read FWMIService; // moved to an FPC IFEDF
to
{$IFDEF WMI_LateBinding}
property SWbemLocator : OleVariant read FSWbemLocator;
//property WMIService : OleVariant read FWMIService;
{$IFDEF FPC}
property WMIService : OleVariant read FWMIService;
{$ENDIF}
1169 from
objWbemObjectSet : = FWMIService.ExecQuery( WQL,'WQL',0);
to
objWbemObjectSet := WmiConnection.FWMIService.ExecQuery( WQL,'WQL',0);
D10.2.3
Trying to compile your demo
procedure TFrmMain.Refresh;
begin
FWin32_Process.LoadWmiData;
FillListProcesses(FWin32_Process);
FWin32_Service.LoadWmiData;
FillListServices(FWin32_Service);
end;
LoadWmiData; does not exist
RRUZ
Just tried out the Object Pascal WMI Class Generator for use with Lazarus and Freepascal. Absolutely amazing stuff!! Really very impressed with it - many thanks for sharing it.
I have an issue that I am not sure if the problem is me or the code. I am trying to use the generated units with Lazarus 1.4.0 and FPC 2.6.4 on Windows 7 Pro, 64-bit.
I am trying to use the units 'SystemConfig_V2_PhyDisk' and 'SystemConfig_V2_LogDisk'. I have created the units using the generator and copied the pas files for them, and the uWmiDelphiClass.pas file, to my project folder.
When I try TSystemConfig_V2_PhyDisk.Create in my project and compile, the compiler reports some problems:
uWmiDelphiClass.pas(1163,26) Error: Identifier not found "FWMIService" which is:
{$IFDEF FPC}
WQL := Format('SELECT * FROM %s',[FWmiClass]);
objWbemObjectSet := FWMIService.ExecQuery( WQL,'WQL',0);
oEnum := IUnknown(objWbemObjectSet._NewEnum) as IEnumVariant;
{$ELSE}
FMIService is first defined on line 97 as part of an IFDEF for WbemScripting_TLB and are greyed out and then again on line 101 as an OLEVariant, and is not greyed out. If I comment out the IFDEF it then cannot find ISWbemLocator. That is first defined on line 194 and is also greyed out as a result of the IFDEF {$IFDEF WbemScripting_TLB} .
I might be wrong but I think one or two of the declaratiosn needed for FPC need to be moved to the FPC IFDEF delcarations? But I know you know what you're doing so I suspect I need to do something different? Or is this an error with the units?
Could you direct me as to how to fix properly without me moving things about in an almost random fashion!?
What steps will reproduce the problem?
- Create the units with WMI Class Generator (eg. uWin32_OperatingSystem,
uWin32_LocalTime)
- Trying to retrieve from remote PC the WMIdata using:
objWMIOperatingSystem := TWin32_OperatingSystem.Create(false);
objWMILocalTime := TWin32_LocalTime.Create(false);
objWMIOperatingSystem.WmiServer := sWMIremotePC;
objWMIOperatingSystem.WmiUser := sWMIuser;
objWMIOperatingSystem.WmiPass := sWMIpass;
objWMIOperatingSystem.LoadWmiData;
objWMILocalTime.WmiServer := sWMIRemotePC;
objWMILocalTime.WmiUser := sWMIuser;
objWMILocalTime.WmiPass := sWMIpass;
objWMILocalTime.LoadWmiData;
What is the expected output? What do you see instead?
- When I call .LoadWmiData it takes long to retrieve the information at both
calls, because the WMI connection are not shared between the objects. Sharing
the WMI connection, the second information should retrieve much faster because
I would be already authenticated at remote PC.
What version of the product are you using? On what operating system?
Delphi XE, Windows 7 (x86)
Original issue reported on code.google.com by [email protected]
on 19 Mar 2011 at 3:03
Hi
Just playing around and trying to work out how to call and use
In my program, I have delclared the uses and so on and started with :
var
PhysDiskSet : TSystemConfig_V2_PhyDisk;
tmpVal1 : widestring;
begin;
PhysDiskSet := TSystemConfig_V2_PhyDisk.Create;
PhysDiskSet.SetCollectionIndex(0); \ I assume 0 is for PhysicalDisk0, 1 for PhysicalDisk 2 etc?
tmpVal1 := IntToStr(PhysDiskSet.PartitionCount);
ShowMessage(tmpVal1);
Zero is always returned. Tried the same with SectorsPerTrack and a few others. Always returns zero. So I am obviously not using the class correctly? Can you explain or give a demo of how to call the procedures in uSystemConfig_V2_PhyDisk.pas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.