Jump to content

David Heffernan

Members
  • Content Count

    3701
  • Joined

  • Last visited

  • Days Won

    185

Everything posted by David Heffernan

  1. David Heffernan

    Creating an array of controls in Delphi

    What's wrong with just adding the controls to a collection? Controls.Add(control1); Controls.Add(control2); Etc.
  2. David Heffernan

    Cross-platform solution to forcefully end a thread

    Maybe you are right. Maybe my multithreaded program doesn't work.
  3. David Heffernan

    Cross-platform solution to forcefully end a thread

    What are you on about. It is perfectly possible to write code that is correct, and behaves in a deterministic fashion with threads. For sure the order of scheduling and execution is not deterministic, but that doesn't mean that you can't write programs whose behaviour is deterministic. I for one make a living doing just that.
  4. David Heffernan

    Cross-platform solution to forcefully end a thread

    pthread_kill But don't do it. It's surely not the solution to your problem.
  5. David Heffernan

    Extend Delphi 10.3 Code Editor

    FYI, cross posted here: https://stackoverflow.com/questions/58858474/how-do-i-extend-the-delphi-10-3-code-editor
  6. David Heffernan

    How to manage defined list values

    [Names('foo', 'bar')] TMyEnum = (foo, bar); It's kinda flaky of course because of the limitations on attribute constructor arguments being true constants. Later on I can write Enum.Name(someEnum)
  7. David Heffernan

    How to manage defined list values

    I use a cache, a dictionary keyed on the type info pointer, iirc
  8. David Heffernan

    How to manage defined list values

    Yes http://docwiki.embarcadero.com/RADStudio/en/Attributes_(RTTI)
  9. David Heffernan

    TThread issue

    It's a bug for the very reasons that you raised! When the thread was created in the constructor of `TThread` it meant that you couldn't synchronise passing state to the thread before it started.
  10. David Heffernan

    TThread issue

    Creating them non-suspended explicitly does what you wish also.
  11. David Heffernan

    TThread issue

    Do that in the constructor of the thread if you wish. No need to create the thread suspended.
  12. David Heffernan

    TThread issue

    That was a bug fixed in Delphi 6, and one of the reasons for the introduction of AfterCreation. I never create threads suspended.
  13. David Heffernan

    TThread issue

    Yes. What happens if you pass False and so don't create suspended?
  14. David Heffernan

    How to manage defined list values

    I use attributes attached to enumerated types to handle this
  15. David Heffernan

    TThread issue

    Why are you creating the thread suspended. What happens if you don't do that?
  16. David Heffernan

    Shellexecute @ UBUNTU platform

    If I actually disagreed with you, I'd produce a counter example. I don't think I have because I don't think there is one. Therefore I can't believe that I disagree.
  17. I don't think that there was any difference regarding the streams. I think you've just mixed up the begin/end update with the streams and got a bit of cargo cult. FWIW your try/finally is not right.
  18. This looks a bit bogus to my eyes. Why would this change anything. Surely LoadFromFile use a file stream.
  19. David Heffernan

    New TForm - Defaults

    I guess you could modify DefFontData in a design time package
  20. David Heffernan

    Shellexecute @ UBUNTU platform

    No need for a workaround. Creating processes, and waiting for them to terminate is routine stuff on all platforms. Definitely worth seconding everything that @Remy Lebeau said. You don't want to replicate ShellExecute because you don't want to use it at all. ShellExecute is used to execute shell verbs. But you want to create a process. A quite different thing altogether. Albeit the open verb on an executable file often results in a new process being created.
  21. David Heffernan

    Shellexecute @ UBUNTU platform

    There is no way to replace all the functionality of ShellExecute which encompasses the entire shell verb mechanism in Windows. What specific functionality of ShellExecute are you looking to replicate?
  22. David Heffernan

    Patch a private virtual method

    @Stefan Glienke Your code above (and in spring4d) uses WriteProcessMemory to modify executable pages. This relies on an undocumented implementation detail of WriteProcessMemory. Namely that it will handle the protection flags on your behalf. Personally I would prefer to use VirtualProtect with this sort of pattern: procedure PatchCode(Address: Pointer; const NewCode; Size: Integer); var OldProtect: DWORD; begin if not VirtualProtect(Address, Size, PAGE_EXECUTE_READWRITE, OldProtect) then begin Fail; end; Move(NewCode, Address^, Size); FlushInstructionCache(GetCurrentProcess, nil, 0); if not VirtualProtect(Address, Size, OldProtect, @OldProtect) then begin Fail; end; end;
  23. David Heffernan

    ShellExecute and passing of password

    You probably need to decide what you want to be secure from. As it stands it's probably impossible to give you specific advice.
  24. David Heffernan

    class constructor - Backport to D2007.

    Class vars are global variables inside a type's name's pace. Class constructors are called from unit initialization. Class destructor from unit finalization.
  25. David Heffernan

    Arab in iOS

    Firemonkey doesn't support right to left languages. Delphi is the wrong tool for you I am afraid.
×