Jump to content

Cristian Peța

Members
  • Content Count

    343
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by Cristian Peța


  1. Strange how it worked in D7. Maybe the garbage on the stack was useful.

    With stdcall TSystemTime will be passed as value directly on the stack.

    Without stdcall TSystemTime will be passed as reference.

    Do I'm missing something?

     

    https://docwiki.embarcadero.com/RADStudio/Sydney/en/Program_Control_(Delphi)

    Quote
    • Sets, records, and static arrays of 1, 2, or 4 bytes are passed as 8-bit, 16-bit, and 32bit values. Larger sets, records, and static arrays are passed as 32-bit pointers to the value. An exception to this rule is that records are always passed directly on the stack under the cdecl, stdcall, and safecall conventions; the size of a record passed this way is rounded upward to the nearest double-word boundary.

     


  2. This is working for me. Probably you are doing something else in your code.

    program Project1;
    
    {$APPTYPE CONSOLE}
    
    uses
      System.SysUtils,
      System.Variants,
      System.Classes,
      FireDAC.Stan.Intf,
      FireDAC.Stan.Option,
      FireDAC.Stan.Error,
      FireDAC.UI.Intf,
      FireDAC.Phys.Intf,
      FireDAC.Stan.Def,
      FireDAC.Stan.Pool,
      FireDAC.Stan.Async,
      FireDAC.Phys,
      FireDAC.Phys.SQLite,
      FireDAC.Phys.SQLiteDef,
      FireDAC.Stan.ExprFuncs,
      FireDAC.VCLUI.Wait,
      FireDAC.Stan.Param,
      FireDAC.DatS,
      FireDAC.DApt.Intf,
      FireDAC.DApt,
      FireDAC.Phys.SQLiteWrapper.Stat,
      Data.DB,
      FireDAC.Comp.DataSet,
      FireDAC.Comp.Client;
    
    var
      FDConnection1: TFDConnection;
      FDTable1: TFDTable;
    
    begin
      FDConnection1 := TFDConnection.Create(nil);
      FDTable1 := TFDTable.Create(nil);
    
      FDConnection1.DriverName := 'SQLite';
      FDConnection1.Params.Database := ExtractFilePath(ParamStr(0)) + 'test.db';
      FDTable1.Connection := FDConnection1;
      FDTable1.TableName := 'table1';
    
      //Default FDConnection1.Params.Values['LockingMode'] is 'Exclusive'
      FDConnection1.Open;
      FDConnection1.ExecSQL('CREATE TABLE table1 (a INTEGER)');
      FDTable1.Open;
      FDTable1.InsertRecord([10]);
      FDTable1.Close;
      DeleteFile(FDConnection1.Params.Database);//here is not working because LockingMode = Exclusive
      FDConnection1.Close;
      DeleteFile(FDConnection1.Params.Database);//here is working for me
    end.

     


  3. Have you checked what PRAGMA locking_mode is returning? You can use TFDQuery for this.

    With UniDAC implicit is EXCLUSIVE and maybe also for FireDAC.

     

    Can you delete the file before opening any connection?

    Better try this after a system restart (or unlock the file) because if you kill the processes in debug, for example, before the connection is closed the file will remain locked.

     

    PS: I prefer to use locking_mode=NORMAL. There is some performance penalty but I don't need any more to respond with: restart the OS.


  4. On 4/25/2024 at 9:38 AM, Die Holländer said:

    In the early BASIC times, like for the ❤️ ZX-Spectrum ❤️ there were

    no functions or procedures but instead they introducted a way to

    jump to another part of the source and return to the next line after

    the jump. The statements: Gosub and Return. 

    ZX-Spectrum BASIC was like an easier assembler where you use CALL and RET (Z80 assembler).


  5. 11 minutes ago, A.M. Hoornweg said:

    "Take control on entry and restore on exit" would be very cumbersome in the case of DLL's written in Delphi.  It would need to be done in every exposed function / method.

    procedure Foo; stdcall;
    begin
      SetFPCR;
      ...
      RestoreFPCR;
    end;

    Do you think is so cumbersome to do this for every exposed function?

    The SetFPCR and RestoreFPCR you need to write for yourself but only once.


  6. 12 minutes ago, A.M. Hoornweg said:

    My question is about threads literally running simultaneously on different CPU cores, does each core always have an independent FPU + FPCR so one thread cannot jeopardize another ?  

    If FPCR would not be per core then one processes would change FPCR of all processes! This can't be.

    FPCR must be pe core like all CPU registers.


  7. Here something on this them:

    https://stackoverflow.com/questions/77764786/remove-runfulltrust-capability-from-flutter-windows-application

     

    And Win32 apps packaged as msix will need runFullTrust. You can avoid runFullTrust with UWP but a Delphi app will call all sort of Win32 API that will need runFullTrust.

    Quote

    Apps using the FullTrust entrypoint can call any API they want. Usually this is your main Win32/.Net executable. I’ll refer to these applications as FullTrust apps.

    https://blogs.windows.com/windowsdeveloper/2017/07/06/calling-winrt-components-win32-process-via-desktop-bridge/


  8. 43 minutes ago, David Schwartz said:

    So what DO you do in a case where, say, you might use an object to collect an accumulation of data that is provided by multiple sources? 

     

    It's often done for contextual state management over time...

     

    The sources must register to the collector. And unregister when the source does not need the collector anymore.

    The collector must not be destroyed if there is an active source.

     

    This is a little like ARC for interfaces work.

    • Like 1

  9. On 3/22/2024 at 7:22 PM, david_navigator said:

    I was hoping there was something that the OS could deal with.

     

    29 minutes ago, david_navigator said:

    @Kas Ob. could you explain in a little more detail about the memory manager please ? 

    The OS will free the memory when you unload the dll.

×