Jump to content

Fr0sT.Brutal

Members
  • Content Count

    2268
  • Joined

  • Last visited

  • Days Won

    46

Everything posted by Fr0sT.Brutal

  1. Ah yes right I haven't noticed the getter returning pointer to array item. In my record list class I use dynamically allocated records and store pointers only so have no such issues.
  2. Fr0sT.Brutal

    RzLauncher vs. Win API call

    1-sec googling: https://wiki.delphi-jedi.org/wiki/JVCL_Help:TJvCreateProcess that claims to have CDir setting. I could suggest my implementation but it's somewhat tied to other util units. Anyway there's nothing hard in launching (code is NOT standalone - some additional utils required) // Launch a process with I/O redirect. // @param ExecProps - requisites for launch // @param [OUT] Handles - in / out pipe handles, process handle // @raises Exception on error procedure ExecProcess(const ExecProps: TExecProps; out Handles: THandleArr); var si: TStartupInfo; pi: TProcessInformation; sa: TSecurityAttributes; hStdOut, hStdIn, hStdErr: THandle; IntCmdLine, IntCurrDir, Env: string; begin Handles := Default(THandleArr); hStdOut := 0; hStdIn := 0; hStdErr := 0; si := Default(TStartupInfo); pi := Default(TProcessInformation); try try // TSecurityAttributes для процесса и труб sa := Default(TSecurityAttributes); sa.nLength := SizeOf(sa); sa.lpSecurityDescriptor := nil; sa.bInheritHandle := True; // create pipes if needed // ! We can't simply override only some of handles - https://stackoverflow.com/questions/30494945 // But assigning standard values with GetStdHandle results in weird behavior // (I/O error on ReadLn specifying standard STDIN, weird hangs etc). // As the situation when STDIN is required in executed process but not redirected // will unlikely happen, just set the handle to NULL. // As for output pipes, create and redirect them always to avoid bugs. // STDIN if pStdIn in ExecProps.RedirectPipes then begin if not CreatePipe(hStdIn, Handles[ehStdIn], @sa, PipeBufSize) then raise LastOSErr('CreatePipe'); // Ensure the write handle to the pipe for STDIN is not inherited (from MSDN example) SetHandleInformation(Handles[ehStdIn], HANDLE_FLAG_INHERIT, 0); end; // STDOUT // if pStdOut in ExecProps.RedirectPipes then begin if not CreatePipe(Handles[ehStdOut], hStdOut, @sa, PipeBufSize) then raise LastOSErr('CreatePipe'); // Ensure the read handle to the pipe for STDOUT is not inherited (from MSDN example) SetHandleInformation(Handles[ehStdOut], HANDLE_FLAG_INHERIT, 0); end; // STDERR // if pStdErr in ExecProps.RedirectPipes then begin if not CreatePipe(Handles[ehStdErr], hStdErr, @sa, PipeBufSize) then raise LastOSErr('CreatePipe'); // Ensure the read handle to the pipe for STDERR is not inherited (from MSDN example) SetHandleInformation(Handles[ehStdErr], HANDLE_FLAG_INHERIT, 0); end; si.cb := SizeOf(si); si.dwFlags := STARTF_USESHOWWINDOW; if ExecProps.RedirectPipes <> [] then si.dwFlags := si.dwFlags or STARTF_USESTDHANDLES; si.wShowWindow := SW_HIDE; si.hStdInput := hStdIn; si.hStdOutput := hStdOut; si.hStdError := hStdErr; if ExecProps.CurrDir = '' then IntCurrDir := GetCurrentDir else IntCurrDir := ExecProps.CurrDir; // Construct a new env from an old one with addition of that given in parameters and // error signature. Env := StrArrToEnv(ExecProps.EnvVars) + GetEnv + #0; IntCmdLine := ExecProps.CmdLine; // command line MUST be modifyable - CreateProcessW requirement UniqueString(IntCmdLine); if not CreateProcess(nil, PChar(IntCmdLine), @sa, nil, True, {} // show window CREATE_NEW_CONSOLE{$IFDEF UNICODE} or CREATE_UNICODE_ENVIRONMENT{$ENDIF}, PChar(Env), PChar(IntCurrDir), si, pi) then raise LastOSErr('CreateProcess', GetLastError, '"'+IntCmdLine+'"'); Handles[ehProcess] := pi.hProcess; // Set priority if not default if ExecProps.Priority <> NORMAL_PRIORITY_CLASS then SetPriorityClass(Handles[ehProcess], ExecProps.Priority); except CloseHandles(Handles); raise; end; finally // Free thread handles and unneeded pipe ends CloseAndZeroHandle(hStdIn); CloseAndZeroHandle(hStdOut); CloseAndZeroHandle(hStdErr); CloseAndZeroHandle(pi.hThread); end; end;
  3. Fr0sT.Brutal

    RzLauncher vs. Win API call

    Actually I'm not as I use my own app launcher with STDIN/OUT redirection. I have an app running 24/7 for months that constantly launches external apps (archiver and some others) without any issue. Btw, your problem looks very alike to resource leakage. You can check if there are non-disposed resources with ProcessExplorer -> Opened handles
  4. Fr0sT.Brutal

    What is wrong with TStringList

    No problem, that subject was interesting and useful as well. But talking about ideal stringlist, what features do you need really? I've never felt I miss something in SL's for many years of Delphi using.
  5. Fr0sT.Brutal

    On the use of Interposers

    And again the topic has turned to some other direction 😉
  6. Fr0sT.Brutal

    TSMBIOS or equivalent?

    There's WMI component in my Awesome list. No idea for Linux
  7. Fr0sT.Brutal

    RzLauncher vs. Win API call

    No idea. Maybe JVCL implementation would perform better?
  8. Well, I have several 24/7 network apps that I'd make console or service if I were starting them now. And as we're slowly moving to Linux, it's very common for it to have no GUI at all on servers
  9. Fr0sT.Brutal

    On the use of Interposers

    I doubt it. In this very case most of these features are specific for editor application. Others won't even notice troubles.
  10. As for me, everywhere I need search in arrays, I use generic classes or wrappers. Of course, if I have an array and need finding an item in just one place, I don't implement separate functions @dummzeuch, @Remy Lebeau good point though I prefer separating the methods
  11. In my practice if I made Find* methods first, later I always came to situation when I also needed the index of the item found. So I had to add IndexOf method and then use it in Find* methods. Why not doing this from the start 🙂
  12. Could FMX message queue be used in console applications?
  13. Fr0sT.Brutal

    Issues Deploying Firebird DB on Ubuntu 8.04LTS

    Very informative ))) DAC guys rock! I'd recommend you to try opening DB from Firebird's own tool ISQL (on Linux it's called isql-fb). Thus you can ensure the DB is really accessible.
  14. Fr0sT.Brutal

    List of packages used by a project

    Hmm, section "requires" in package.dpk?
  15. Fr0sT.Brutal

    Issues Deploying Firebird DB on Ubuntu 8.04LTS

    +1. Just copy DB file to another location. Do you really need connecting to DB locally?
  16. Fr0sT.Brutal

    Use of Ansistring in Unicode world?

    Ah, THAT Andy )) David really puzzled me!
  17. Fr0sT.Brutal

    remove ExplicitXxxx properties

    I apparently saw some expert allowing to exclude some properties from saved DFM... maybe CnPack? I haven't tried too much experts so if not GExperts then it should be CnPack
  18. Fr0sT.Brutal

    Use of Ansistring in Unicode world?

    Comment about inefficiency of Unicode strings? Ok, I read it, what that nonsense should have told me?
  19. Fr0sT.Brutal

    Use of Ansistring in Unicode world?

    If you care about performance so much, you can use if Ord(c) in [Ord('A')..Ord('Z')] or case c of 'A'..'Z': ... end;
  20. Fr0sT.Brutal

    CPP or C++ Category

    +1 for adding the CB-related forum IF there will be someone with knowledge. Major part of 'Delphi' is IDE+RTL+VCL which are common with CB. Moreover, as CB has been a poor brother of Delphi for long time, many things fluent with Delphi still raise issues with CB.
  21. It seems so http://docwiki.embarcadero.com/RADStudio/Sydney/en/What's_New#Key_FireMonkey_Platform_Enhancements
  22. Fr0sT.Brutal

    best practise unit testing , DUNITX

    None. You can use categories [Category('bench')] procedure BenchMsgThreads; [Category('stability')] procedure TestMsgThreadStab; and corresponding arguments
  23. Fr0sT.Brutal

    where can I get general git process questions answered?

    Very likely that everyone will tell you to RTFM first (true gitters are severe unixoids that don't like to mess with noobs). There are tons of manuals everywhere. Probably you could try generic IT discussion boards for non-concrete subjects. Maybe Reddit (haven't used it myself though)
  24. Fr0sT.Brutal

    Securing your data over time

    Storage box in a bank xD
×