Leaderboard
Popular Content
Showing content with the highest reputation on 11/26/21 in all areas
-
You can get any info with WMI support. WMI covers a very very incredible set of infos. This is a sample that I use to recover some system info. unit osSystemInfo; interface type TSystemInfoMode = ( simdCompact, simdFull ); TMotherBoardInfo = ( mbiSerialNumber, mbiManufacturer, mbiProduct, mbiModel ); TMotherBoardInfos = set of TMotherBoardInfo; TOSInfo = ( osiBuildNumber, osiBuildType, osiManufacturer, osiName, osiSerialNumber, osiVersion ); TOSInfos = set of TOSInfo; TProcessorInfo = ( priDescription, priManufacturer, priName, priProcessorId, priUniqueId, priSystemName ); TProcessorInfos = set of TProcessorInfo; type TSystemInfo = class private FBuffer: AnsiString; FMotherBoardInfos: TMotherBoardInfos; FNeedUninitialize: Boolean; FOSInfos: TOSInfos; FProcessorInfos: TProcessorInfos; private procedure Clear; public function GenerateInfo(Mode: TSystemInfoMode = simdCompact): Boolean; public property Buffer: AnsiString read FBuffer; property MotherBoardInfos: TMotherBoardInfos read FMotherBoardInfos write FMotherBoardInfos; property OSInfos: TOSInfos read FOSInfos write FOSInfos; property ProcessorInfos: TProcessorInfos read FProcessorInfos write FProcessorInfos; public constructor Create; destructor Destroy; override; end; implementation uses ComObj, ActiveX, SysUtils, Variants, osExceptionUtils; var MotherBoardInfoText: array[TMotherBoardInfo] of AnsiString = ( 'SerialNumber', 'Manufacturer', 'Product', 'Model' ); OSInfoText: array [TOSInfo] of AnsiString = ( 'BuildNumber', 'BuildType', 'Manufacturer', 'Name', 'SerialNumber', 'Version' ); ProcessorInfoText: array [TProcessorInfo] of AnsiString = ( 'Description', 'Manufacturer', 'Name', 'ProcessorId', 'UniqueId', 'SystemName' ); procedure TSystemInfo.Clear; begin FBuffer := ''; end; constructor TSystemInfo.Create; begin inherited; FBuffer := ''; FMotherBoardInfos := []; FNeedUninitialize := False; FOSInfos := []; FProcessorInfos := []; FNeedUninitialize := CoInitialize(nil) = S_OK; end; destructor TSystemInfo.Destroy; begin if FNeedUninitialize then CoUninitialize; inherited; end; function TSystemInfo.GenerateInfo(Mode: TSystemInfoMode): Boolean; var S: AnsiString; OSInfo: TOSInfo; IValue: LongWord; OSInfos: TOSInfos; OEnum: IEnumvariant; OWmiObject: OLEVariant; ObjWMIService: OLEVariant; ObjSWbemLocator: OLEVariant; objWbemObjectSet: OLEVariant; ProcessorInfo: TProcessorInfo; ProcessorInfos: TProcessorInfos; MotherBoardInfo: TMotherBoardInfo; MotherBoardInfos: TMotherBoardInfos; function VarArrayToStr(const vArray: Variant): AnsiString; function _VarToStr(const V: Variant): AnsiString; var Vt: Integer; begin Vt := VarType(V); case Vt of varSmallint, varInteger : Result := AnsiString(IntToStr(Integer(V))); varSingle, varDouble, varCurrency : Result := AnsiString(FloatToStr(Double(V))); varDate : Result := AnsiString(VarToStr(V)); varOleStr : Result := AnsiString(WideString(V)); varBoolean : Result := AnsiString(VarToStr(V)); varVariant : Result := AnsiString(VarToStr(Variant(V))); varByte : Result := AnsiChar(Byte(V)); varString : Result := AnsiString(V); varArray : Result := VarArrayToStr(Variant(V)); end; end; var I: Integer; begin Result := '['; if (VarType(vArray) and VarArray) = 0 then Result := _VarToStr(vArray) else begin for I := VarArrayLowBound(vArray, 1) to VarArrayHighBound(vArray, 1) do begin if I = VarArrayLowBound(vArray, 1) then Result := Result + _VarToStr(vArray[I]) else Result := Result + '|' + _VarToStr(vArray[I]); end; end; Result:=Result + ']'; end; function VarStrNull(const V: OleVariant): AnsiString; begin Result := ''; if not VarIsNull(V) then begin if VarIsArray(V) then Result := VarArrayToStr(V) else Result := AnsiString(VarToStr(V)); end; end; begin Clear; try ObjSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator'); if VarIsNull(ObjSWbemLocator) then AbortFast; ObjWMIService := objSWbemLocator.ConnectServer('localhost','root\cimv2', '',''); if VarIsNull(ObjWMIService) then AbortFast; if FMotherBoardInfos <> [] then begin MotherBoardInfos := FMotherBoardInfos; ObjWbemObjectSet := objWMIService.ExecQuery('SELECT * FROM Win32_BaseBoard', 'WQL', 0); OEnum := IUnknown(ObjWbemObjectSet._NewEnum) as IEnumVariant; while OEnum.Next(1, OWmiObject, IValue) = 0 do begin if MotherBoardInfos = [] then Break; for MotherBoardInfo := Low(TMotherBoardInfo) to High(TMotherBoardInfo) do begin if MotherBoardInfo in FMotherBoardInfos then begin S := VarStrNull(OWmiObject.Properties_.Item(MotherBoardInfoText[MotherBoardInfo]).Value); Exclude(MotherBoardInfos, MotherBoardInfo); case Mode of simdCompact: FBuffer := FBuffer + S; simdFull: FBuffer := FBuffer + MotherBoardInfoText[MotherBoardInfo] + ' = ' + S + #13#10; end; end; end; OWmiObject := Unassigned; end; end; if FOSInfos <> [] then begin OSInfos := FOSInfos; ObjWbemObjectSet := objWMIService.ExecQuery('SELECT * FROM Win32_OperatingSystem', 'WQL', 0); OEnum := IUnknown(ObjWbemObjectSet._NewEnum) as IEnumVariant; while OEnum.Next(1, OWmiObject, IValue) = 0 do begin if OSInfos = [] then Break; for OSInfo := Low(TOSInfo) to High(TOSInfo) do begin if OSInfo in OSInfos then begin S := VarStrNull(OWmiObject.Properties_.Item(OSInfoText[OSInfo]).Value); Exclude(OSInfos, OSInfo); case Mode of simdCompact: FBuffer := FBuffer + S; simdFull: FBuffer := FBuffer + OSInfoText[OSInfo] + ' = ' + S + #13#10; end; end; end; OWmiObject := Unassigned; end; end; if FProcessorInfos <> [] then begin ProcessorInfos := FProcessorInfos; ObjWbemObjectSet := objWMIService.ExecQuery('SELECT * FROM Win32_Processor', 'WQL', 0); OEnum := IUnknown(ObjWbemObjectSet._NewEnum) as IEnumVariant; while OEnum.Next(1, OWmiObject, IValue) = 0 do begin if ProcessorInfos = [] then Break; for ProcessorInfo := Low(TProcessorInfo) to High(TProcessorInfo) do begin if ProcessorInfo in ProcessorInfos then begin S := VarStrNull(OWmiObject.Properties_.Item(ProcessorInfoText[ProcessorInfo]).Value); Exclude(ProcessorInfos, ProcessorInfo); case Mode of simdCompact: FBuffer := FBuffer + S; simdFull: FBuffer := FBuffer + ProcessorInfoText[ProcessorInfo] + ' = ' + S + #13#10; end; end; end; OWmiObject := Unassigned; end; end; Result := True; except Clear; Result := False; end; end; end. There is also a WMI Delphi Code Generator in which you can brose the interesting data and it creates code for you: https://github.com/RRUZ/wmi-delphi-code-creator
-
I was able to figure out the correct download link (by looking at the first alpha download link. 🙂 The correct link is: https://download.dummzeuch.de/GExperts/1.3.19_2021-11-26_for_Delphi11-Patch2/GXRS11_1.3.19_ALPHA2_experimental-twm_2021-11-26.exe
-
M1, Parallels, Delphi IDE: ctrl + hovering ???
Joe Sansalone replied to Joe Sansalone's topic in Cross-platform
I have the base model "M1 Pro" 8 core/14 GPU 14" MacBook. (similar single-core to the M1, but faster multi-core) Running Windows 11 ARM via Parallels. Delphi 11. Delphi IDE runs very smoothly. And like you mentioned it's an Intel x86 so it's going through the emulator in order to run on ARM. IF Embarcadero were to produce a ARM version of the Delphi IDE, I suspect that it would be about 2.5x faster. I compiled the same program in Delphi for macOS twice. One for macOS Intel (goes through Rosetta 2 emulator) and the other for macOS ARM. The ARM version ran 2.8x faster. (3.5x faster if using Metal API) From what I read the "windows emulator" is about the same performance slowdown like Rosetta 2 (apple emulator). NOTE: Sometimes I'll notice something takes a little longer (in Delphi) than my windows machine ... but it's small difference. My windows machine is just a 2-core but I run Windows 7 on it. Hope this helps. -
I am afraid the download link does not work.
-
Xmas came early this year - and, as much as time permits, I will attempt to brave new frontiers. This is more or less my first attempt to use MacOS, and to make things even more exciting, I added the preview version of Windows 11 for ARM to a Parallels VM and I'm installing RAD Studio under that. I will prolly have a thousand MacOS / XCode questions... so any pointers to tips on getting a smooth start with XCode and Delphi will be much appreciated.
-
Embarcadero has released a second patch (called November Patch) for Delphi 11 which seems to fix several issues that blocked further progress on GExperts for Delphi 11. So here it is, fresh out of the compiler: The second Alpha version of GExperts for Delphi 11. Please keep in mind: This is not even a Beta version! There will be bugs and these will not only be UI glitches but functionality failures! You have been warned! read on in the blog post.
-
Delphi on Windows 11 on MacBook Pro 16 (2021)
Lars Fosdal replied to Lars Fosdal's topic in Cross-platform
It is kinda ass backwards, isn't it... -
Thanks! I just fixed the link. Note to self: Always check those links!
-
For Windows, MiTeC System Information Component Suite can get every hardware and software detail you can think of, and more; there is also a trial version available. https://www.mitec.cz/msics.html
-
There's Freepascal that you can estimate. Just extract Win-only part and count LOCs
-
How to deploy a large Android app (150+ MB) using "Play Feature Delivery"?
Vandrovnik replied to Hans♫'s topic in Cross-platform
Can you download these audio samples after installation from your server(s)? The same way as offline maps are downloaded by apps... And probably stored to SD cards instead of internal storage (user is asked where to store them). -
Has anyone tried "DelphiLSP" for Visual Studio Code yet?
Der schöne Günther replied to Perpeto's topic in General Help
For your reference, here is the official Embarcadero documentation: Using DelphiLSP Code Insight with Other Editors - RAD Studio (embarcadero.com) -
Has anyone tried "DelphiLSP" for Visual Studio Code yet?
Lajos Juhász replied to Perpeto's topic in General Help
I didn't tested Visual Studio Code. It uses the same thing. From Delphi 11 unfortunately only the LSP based code completion is available and it's not good enough (capable only to handle Hello World applications). -
I guess it's used here as an estimation sample
-
Thank you for your answer Dave Nottage. Actually I didn't consider such a solution like that 🙂 When I tried to add timer component into the Unit2 which is service's unit it adds FMX.Types library automatically. Once it's been added you can't delete until you remove the timer component. I've missed to remove that FMX.Types while creating a demo. It comes from my original app, I copied all the uses section from it. Anyway, your beautiful attention solved the problem 🙂 If you do not mind can you give an advice about how to use something like timer in my service because I am doing some tasks related to time
-
You have FMX.Types in the uses clause of Unit2 in your service. Not sure why, since it does not even need to be there. Regardless, that is why your service is failing. Please see this report: https://quality.embarcadero.com/browse/RSP-17857
-
When `Scaled` is set, form inheritance will cause duplicated scaling? Any one can confirm?
Stano replied to Edwin Yip's topic in VCL
I (not just me) have the experience that if there are several components differently aligned, then there are problems with that. Try to align the components when creating the form. It is best to create them dynamically -
After our last endeavour with C++ Builder (see here: Does C++ Builder have code completion? - General Help - Delphi-PRAXiS [en] (delphipraxis.net)), we switched to VS Code. Have absolutely not regrettet it, and it's free.
-
https://github.com/sonadorje/rabbitmq-delphi This project is directly translated from https://github.com/alanxz/rabbitmq-c. On windows, it is compiled with Lazarus and Delphi XE2 and above.
-
How to iterate a TDictionary using RTTI and TValue
Remy Lebeau replied to John Kouraklis's topic in Delphi IDE and APIs
Generics are not easy to serialize manually because of the nature of their dynamic types. You will likely have to resort to something like the following (untested, but should give you an idea of what is involved): var mc: TMClass; ctx: TRttiContext; rType: TRttiType; rProp: TRttiProperty; rMethod: TRttiMethod; rKeyField, rValueField: TRttiField; propValue, methValue, genKey, genValue: TValue; genDict, genDictEnum: TObject; genPair: Pointer; begin mc := TMClass.Create; try { if Assigned(mc.MC) then begin for var pair in mc.MC do begin // use pair.Key and pair.Value as needed ... end; end; which is actually this behind the scenes ... if Assigned(mc.MC) then begin var enum = mc.MC.GetEnumerator; while enum.MoveNext do begin var pair = enum.Current; // use pair.Key and pair.Value as needed ... end; end; } rType := ctx.GetType(mc.ClassInfo); // rType = TMClass rProp := rType.GetProperty('MC'); propValue := rProp.GetValue(mc); genDict := propValue.AsObject; if Assigned(genDict) then begin rType := rProp.PropertyType; // rType = TObjDict rMethod := rType.GetMethod('GetEnumerator'); methValue := rMethod.Invoke(genDict, []); genDictEnum := methValue.AsObject; rType := rMethod.ReturnType; // rType = TDictionary<TKey, TValue>.TPairEnumerator rMethod := rType.GetMethod('MoveNext'); rProp := rType.GetProperty('Current'); rType := rProp.PropertyType; // rType = TPair<TKey, TValue> rKeyField := rType.GetField('Key'); rValueField := rType.GetField('Value'); methValue := rMethod.Invoke(genDictEnum, []); while methValue.AsBoolean do begin propValue := rProp.GetValue(genDictEnum); genPair := propValue.GetReferenceToRawData; genKey := rKeyField.GetValue(genPair); // genKey.TypeInfo = TypeInfo(string) genValue := rValueField.GetValue(genPair); // genValue.TypeInfo = TypeInfo(string) // use genKey and genValue as needed ... methValue := rMethod.Invoke(genDictEnum, []); end; end; finally mc.Free; end; end. Because it doesn't exist. For a dictionary, TKey and TValue are Generic parameters of the TDictionary class. They are not standalone concrete types, like you are thinking of.