Jump to content

Cristian Peța

Members
  • Content Count

    438
  • Joined

  • Last visited

  • Days Won

    5

Posts posted by Cristian Peța


  1. 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.

     


  2. 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.


  3. 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).


  4. 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.


  5. 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/


  6. 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

  7. 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.


  8. 16 hours ago, gioma said:

    in reality that data can be a UTF8 string or a UNICODE string or a file.
    The first character of the data tells me what type of data I have to work with.

    Then you don't know if that first char is one or two bytes.

    You test first byte (suppose UTF-8) and if it is not what you expected then you test first two bytes?

×