Jump to content

Lars Fosdal

Administrators
  • Content Count

    3416
  • Joined

  • Last visited

  • Days Won

    113

Everything posted by Lars Fosdal

  1. Lars Fosdal

    Getters & Settters??

    Look further back in the thread for constructor overloading. It seems like I didn't understand your "not quite the same thing" comment. Care to elaborate?
  2. Lars Fosdal

    Getters & Settters??

    True. But if I need multiple constructors with different arguments to set up a class before use - is that class overly complicated and should it be broken down into a hierarchy?
  3. Lars Fosdal

    Getters & Settters??

    @David Heffernan - I rarely make classes that have so few fields that they are passed in the constructor. Most of my instance data are retrieved from database tables, and each class knows what fields to retrieve (or store). The generic container instantiates the class, the instances fill themselves from the db query. I also have polymorphic classes where each element requires different initializations, which firstly are done by default initializations in the class create, and then secondarily from attributes before the declaration of the class instance reference field. I use this mechanism to build grids in code - and not in design mode. Again, the inits and attributes are the defaults. Overrides are then applied from stored settings.
  4. Lars Fosdal

    Getters & Settters??

    I prefer my constructors without arguments. More abstract / generics friendly. Ref. an earlier comment - I am not so fond of the (ab)use of overload either. It is great for dealing with type translation methods - but multiple overloaded constructors could be very confusing before LSP and inline documentation actually became helpful again. As for number of arguments to a method - as many as it takes, but more than five is pretty rare.
  5. Lars Fosdal

    Getters & Settters??

    ... appear to be nice at first glance, but they tend to be confusing. I'd recommend unique names for each constructor instead.
  6. Lars Fosdal

    generics

    TArray = a rack.
  7. I love Continua CI and FinalBuilder. Massive time-savers!
  8. Lars Fosdal

    NetGroupGetUsers strange errors on Win64 on buffered reads

    Perhaps check that the types used in the declaration of the API doesn't inappropriately change size on the Delphi side depending on if we compile for 32-bit vs 64-bit?
  9. Lars Fosdal

    FireDAC performances

    We went from ADO to FireDAC and significantly improved the performance. However - we do NOT use db aware components and inserts and updates are done through stored procedures. We systematically use FetchOptions.Mode := fmAll; FetchOptions.Unidirectional := Unidirectional; For stored procs, we add FetchOptions.Items := FetchOptions.Items - [fiMeta]; We also avoid MARS concurrency by ensuring that every query gets a connection of its own.
  10. Lars Fosdal

    NetGroupGetUsers strange errors on Win64 on buffered reads

    It is a very old legacy Windows function, though...
  11. Lars Fosdal

    NetGroupGetUsers strange errors on Win64 on buffered reads

    Working as admin by default would be considered a massive no-no by my company.
  12. Lars Fosdal

    NetGroupGetUsers strange errors on Win64 on buffered reads

    Confirmed. It worked running elevated with the MAX_PREFERRED_LENGTH and returned some 16k+ users.
  13. Lars Fosdal

    NetGroupGetUsers strange errors on Win64 on buffered reads

    The 64-bit simply refuses to run, unless I run it elevated. Then I get /--- Started --- hres = 0 dwRead = 35 dwTotal = 712 hres = 3608717696 EAccessViolation: Access violation at address 00007FFBCE7CB0EC in module 'SAMCLI.DLL'. Read of address 00000000D718A9A8 Press Enter: Perhaps there are further access rights that come into play?
  14. Lars Fosdal

    NetGroupGetUsers strange errors on Win64 on buffered reads

    Check out unit web.win.AdsTypes: Here is some code I wrote to find out if a user had an AD membership. unit ActiveDSUtil; /// Written by Lars Fosdal, 16 DEC 2014 /// Note that calling AD functions is slow. interface uses Classes, SysUtils, ActiveX, ActiveDS_tlb, web.win.adstypes; type TADGroupList = array of String; TAnonParamFunc<TA,TR> = reference to function (const v:TA):TR; /// <summary> Enumerates the group memberships of an AD user </summary> function EnumADUserGroupMemberships(const aDomain, aUser: String; EnumHandler: TAnonParamFunc<IAdsGroup, Boolean>):Boolean; /// <summary> Returns a list of all AD groups for an AD user </summary> function GetADUserGroupMemberships(const aDomain, aUser: String):TStringList; /// <summary> Checks if an AD user is member of one or more specific groups</summary> function UserHasADGroupMembership(const aDomain, aUser: String; const GroupList: TAdGroupList): Boolean; implementation function EnumADUserGroupMemberships(const aDomain, aUser: String; EnumHandler: TAnonParamFunc<IADsGroup, Boolean>):Boolean; var hr: HREsult; User: IADsUser; Enum: IEnumVariant; varGroup: OleVariant; EnumHelper: LongWord; begin Result := False; CoInitialize(nil); try hr := ADsGetObject('WinNT://'+aDomain+'/'+aUser+',user',IID_IADsUser3 , User); if not Failed(hr) then begin try Enum := User.Groups._NewEnum as IEnumVariant; while Assigned(Enum) and (Enum.Next(1, varGroup, EnumHelper) = S_OK) do begin try if EnumHandler(IDispatch(varGroup) as IADsGroup) then EXIT(True); finally VariantClear(varGroup); end; end; finally User := nil; end; end; finally CoUninitialize; end; end; function GetADUserGroupMemberships(const aDomain, aUser: String):TStringList; var List: TStringList; begin List := TStringList.Create; List.BeginUpdate; try EnumADUserGroupMemberships(aDomain, aUser, function(const Group: IAdsGroup):Boolean begin Result := False; List.Add(Group.Name + ' ' + Group.Class_); end); finally List.Sort; List.Insert(0, aDomain +'\'+ aUser); List.EndUpdate; Result := List; end; end; function UserHasADGroupMembership(const aDomain, aUser: String; const GroupList: TAdGroupList): Boolean; begin Result := EnumADUserGroupMemberships(aDomain, aUser, function(const Group: IAdsGroup):Boolean var GroupName: String; begin Result := False; for GroupName in GroupList do begin Result := CompareText(GroupName, Group.Name) = 0; if Result then Break; // Return true for first match end; end); end; end.
  15. Lars Fosdal

    NetGroupGetUsers strange errors on Win64 on buffered reads

    @Davide Angeli - BTW- Why don't you use the AD APIs instead?
  16. Lars Fosdal

    NetGroupGetUsers strange errors on Win64 on buffered reads

    Windows 10, 64-bit Compile to 32-bit target - runs as expected Compile to 64-bit target - unable to create process
  17. Lars Fosdal

    TEdgeBrowser : "Unsafe attempt to load URL"

    I'd complain loudly to the company that wrote that app. These folders have been forbidden for the last 15 years - at least. Dynamic data should go to user folders for user specific data, or AppData for system wide data.
  18. Lars Fosdal

    TEdgeBrowser : "Unsafe attempt to load URL"

    It was an possibly premature assumption from my side...
  19. You sort of posted the answer with your question. Not sure what you are trying to improve?
  20. Lars Fosdal

    TEdgeBrowser : "Unsafe attempt to load URL"

    Putting writable files under C:\Program Files is a very bad idea, but probably not related to the errors. You could in theory have your own built in web server and serve the files from there to avoid direct file system access from the browser? Comment #3 here is a possible explanation. https://bugs.chromium.org/p/chromium/issues/detail?id=512542#c3
  21. Lars Fosdal

    PowerBuilder Code Covert to Delphi

    I'd forgo all PowerBuilder UI related things and focus on the function of the app - what does it need to do. Analyse the code (a "screen" here is a reference to a window or combination of windows/controls) - how do you navigate it - what does each screen do - where does it get its data - how does it treat and display the data - what can you do within that screen You would only need to focus on bringing the content and functionality over, without dwelling too much on the old-school PowerBuilder UI code. It would be more of a rewrite than a migration.
  22. Please post in English (use Google translate if necessary).
  23. Lars Fosdal

    Replacing Apostrophe

    So, TNetEncoding.HTML.Decode needs to be updated to support HTML5... Edit: Looks like a significant expansion of named entities. HTML5: https://www.w3.org/TR/2011/WD-html5-20110525/named-character-references.html HTML4: https://www.w3.org/TR/html4/sgml/entities.html
  24. Lars Fosdal

    Replacing Apostrophe

    Nope. https://stackoverflow.com/questions/2083754/why-shouldnt-apos-be-used-to-escape-single-quotes
  25. Lars Fosdal

    Windows 11 22H2 lost batch file association

    https://www.educba.com/cmd-vs-bat/
×