-
Content Count
169 -
Joined
-
Last visited
-
Days Won
3
Everything posted by rvk
-
Why is my firebird database code unstable under load? (code included)
rvk replied to Yaron's topic in Databases
For good measure I would add Connected := false after dbQuery.ExecSQL; (But my guess this is also done in dbConn.Free) dbQuery.ExecSQL; dbConn.Connected := false; But I see you update the table in the thread. You didn't do that in your original post. The deadlock can come from using transactions incorrectly (or updating the same record in different transactions/threads), http://www.firebirdfaq.org/faq151/ -
Why is my firebird database code unstable under load? (code included)
rvk replied to Yaron's topic in Databases
It's not if you're using a pool. When using a pool the connection is given back to the pool. It's not closed. At least that's what the documentation says. http://docwiki.embarcadero.com/RADStudio/Rio/en/Multithreading_(FireDAC) But maybe the TFDConnection.Free already does that. What's your code like now? -
Why is my firebird database code unstable under load? (code included)
rvk replied to Yaron's topic in Databases
Maybe putting a amNonBlocking in there? FDQuery1.ResourceOptions.CmdExecMode := amNonBlocking; You're not updating anything so I'm not sure why there would be a deadlock there. You set the TFDConnection.Connected to false afterwards in the thread? (because that releases the connection back to the pool) -
Yes, that sometimes happens to me too. Often this is due to the IDE not recognizing some lines and not knowing it already has a {$R *.res} line. Sometimes reordering the uses-units and other elements will fix this (if it keeps happening). (I had to move my {$R} lines above the uses- and {$SETPEFLAGS} lines.)
-
Look in your project source (the .dpr file)... do you have multiple {$R *.res} lines?
-
Why is my firebird database code unstable under load? (code included)
rvk replied to Yaron's topic in Databases
I have no experience with FireDac, but shouldn't you create a TFDConnection in each thread to be used with TFDQuery? As is shown in http://docwiki.embarcadero.com/RADStudio/Rio/en/Multithreading_(FireDAC) -
I'm not sure but there might be a way to do it from one exe. But that might be really advanced stuff (haven't looked st the details). https://blog.mattmags.com/2007/06/30/accessing-32-bit-dlls-from-64-bit-code/
-
Cannot get correct path to Documents folder on Android using Delphi 10.3
rvk replied to jon_bondy's topic in RTL and Delphi Object Pascal
Because with older Android version the permission is given during install (if it's asked for by the program). With newer Android the permission needs to be given during runtime (because during install everybody just clicks through without thinking). -
Cannot get correct path to Documents folder on Android using Delphi 10.3
rvk replied to jon_bondy's topic in RTL and Delphi Object Pascal
If you set the proper permission in the manifest you might be able to manually 'activate' that permission in the permission section of the App-settings in Android (instead of asking this via your program). (But for a production program it is best to ask for it in the program itself) -
See my previous post, because I already got this working.
-
Yes, there are... (although I could also appreciate the comment of FredS ) I have it working here in 64 bit. Besides the INVALID_HANDLE_VALUE I mentioned earlier, you need to use the correct GetMsgProc() definition. The one now used is only valid in 32 bit. If you change it into this it worked here (both in the implementation and interface part). (although you might want to avoid a parameter named wParam because it is also a type in the Windows unit which you need, solved here with unit-prefixing)
-
Yep. That was my conclusion too. There still must be something wrong. Using WH_CBT you do get some messages. There supposed to be a HCBT_SYSCOMMAND message containing the information but I haven't looked at it further.
-
The reason for this is because GetMsgProcRec seems to be nil in the DLL. It seems that the call to CreateFileMapping fails in 64 bit. For testing this you can add your fwGetMsgProc dll project to the projectgroup of TESTHks and debug the dll-calls. Set a breakpoint in InitializeDll and you'll see it stops at the first MappedMem line. Next (on the second try) trace into the procedure with F7 and you'll see the exception for cErrorCreating,['TMappedMem'] is called. You'll see a $FFFFFFFF as parameter, meaning an invalid handle (see https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createfilemappinga) But INVALID_HANDLE_VALUE is THandle(-1) which is something different then $FFFFFFFF in 64 bit. (you'll need $FFFFFFFFFFFFFFFF) So change it to Now the hook can successfully be installed. (I hadn't much luck with catching anything but now you're a step closer )
-
I don't think 'injecting code' is the best way to go. I think you need to catch the WM_SYSCOMMAND which is sent to the other application(s). You should be able to do that with SetWindowsHookEx(). https://social.msdn.microsoft.com/Forums/windows/en-US/f87193b7-ccc2-4c30-9b1e-195addd375c8/how-to-intercept-a-wmsyscommand-sent-to-another-app?forum=winforms An example in C++ http://forums.codeguru.com/showthread.php?161054-System-wide-hook-for-WM_SYSCOMMAND
-
Zero cost, fully automated secure off-site database backup (FireBird 3.0.4)
rvk replied to Yaron's topic in Databases
Ah, Ok. I wanted my backup script to make transportable backups. nbackup doesn't do that (but is faster because of it). Because speed isn't an issue (because both can backup a database while in use and I only make daily backups, not hourly) I went for gbak. https://firebirdsql.org/manual/nbackup-overview.html -
Zero cost, fully automated secure off-site database backup (FireBird 3.0.4)
rvk replied to Yaron's topic in Databases
I did something similar with gbak i.c.w. nextcloud and the task scheduler (inside a cmd-script). Any reason to prefer nbackup above gbak? -
is there any "currency to words" routine for Delphi?
rvk replied to Attila Kovacs's topic in Algorithms, Data Structures and Class Design
Correct. The base of the code from NumWords is just 70-somewhat lines and can easily be adjusted to follow the additional/proper rules. const Digits: array [1 .. 9] of string = ( 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'); Teens: array [1 .. 9] of string = ( 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'); TenTimes: array [1 .. 9] of string = ( 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'); function DoTriplet(TheNumber: Integer): string; var Digit, Num: Integer; begin Result := ''; Num := TheNumber mod 100; if (Num > 10) and (Num < 20) then begin Result := Teens[Num - 10]; Num := TheNumber div 100; end else begin Num := TheNumber; Digit := Num mod 10; Num := Num div 10; if Digit > 0 then Result := Digits[Digit]; Digit := Num mod 10; Num := Num div 10; if Digit > 0 then Result := TenTimes[Digit] + ' ' + Result; Result := Trim(Result); end; Digit := Num mod 10; if (Result <> '') and (Digit > 0) then Result := 'and ' + Result; if Digit > 0 then Result := Digits[Digit] + ' hundred ' + Result; Result := Trim(Result); end; function NumberInWords(TheNumber: Integer): string; var Num, Triplet, Pass: Integer; begin if TheNumber < 0 then Result := 'Minus ' + NumberInWords(-TheNumber) else begin Result := ''; Num := TheNumber; if Num > 999999999 then raise Exception.Create('Can''t express more than 999,999,999 in words'); for Pass := 1 to 3 do begin Triplet := Num mod 1000; Num := Num div 1000; if Triplet > 0 then begin if (Pass > 1) and (Result <> '') then Result := ', ' + Result; case Pass of 2: Result := ' thousand' + Result; 3: Result := ' million' + Result; end; Result := Trim(DoTriplet(Triplet) + Result); end; end; end; end; procedure TForm1.FormCreate(Sender: TObject); begin Showmessage(NumberInWords(2120229)); end; -
is there any "currency to words" routine for Delphi?
rvk replied to Attila Kovacs's topic in Algorithms, Data Structures and Class Design
You mentioned a "great solution on a website". https://www.calculator.org/calculate-online/mathematics/text-number.html It translates 2019 to "two thousand, nineteen" How does that one follow those rules? But maybe there are better ones. But I haven't even seen any ones online that convert according to those rules. (or maybe this one https://www.tools4noobs.com/online_tools/number_spell_words/) -
is there any "currency to words" routine for Delphi?
rvk replied to Attila Kovacs's topic in Algorithms, Data Structures and Class Design
And what doesn't satisfy you with the NumWords v.4.6 result? (Worked fine for me) -
is there any "currency to words" routine for Delphi?
rvk replied to Attila Kovacs's topic in Algorithms, Data Structures and Class Design
Something like this? https://torry.net/quicksearchd.php?String=numwords&Title=Yes It would be useful if you mentioned which ones didn't satisfy you because now you could get duplicate suggestions. -
Looking at the source, each time you press the OK button a private variable FAttempt is increased. When it goes over the AttemptNumber a Cancel is automatically triggered. So the Login will fail. procedure TJvLoginForm.OkBtnClick(Sender: TObject); begin Inc(FAttempt); if Assigned(FOnOkClick) then FOnOkClick(Self) else ModalResult := mrOk; if (ModalResult <> mrOk) and (FAttempt >= AttemptNumber) then ModalResult := mrCancel; end;
-
That depends on where you put the TJvLoginDialog. If you have a DataModule, ideally the TJvLoginDialog goes on the TDataModule and you'll execute it in the DataModuleCreate() after connecting to the TDatabase. Set Active to false at designtime so you can do this yourself in the DataModuleCreate(). Login.Active := true; if not Login.Execute then begin // inform the user and exit Application.Terminate; end; In the OnCheckUser you can check the database if the user has entered valid credentials. If you have the TDatabase component on a TForm and you initialize it there, then you'll need to put the TJvLoginDialog there too (in FormCreate() and after the initialization of the TDatabase-component).
-
Like I stated before, you can do it with Synapse (from Ararat) and libssh2.dll. There is a SimpleSFTP.pas in the demo-directory. But that one uses cryptlib.dll which isn't free distributable. But there are version which can also use libssh2.dll (which is free). I have one for FPC but not ported to Delphi. There are also versions which use plain winsock in combination with libssh2.dll (no need for Synapse). For example: https://github.com/pult/libssh2_delphi (and like others on github) Using the searchwords libssh2 and delphi in Google will get you a lot of results too. For the Synapse version you can just search for SimpleSFTP.pas and libssh2 and you can search for the latest working with libssh2.dll. If you have any problems let us know.
-
You can do it with Synapse in combination with cryptlib, or better libssh2.dll, for free. There is some source out there (I think sftp_2000) for Delphi. If you can't find it I could convert the example I have from FPC/Lazarus back to Delphi (will need some time for that).
-
You can use TWebBrowser.WebBrowser1DocumentComplete() and read out WebBrowser1.Document.documentElement.outerHTML; (like discussed above) You can strip out any script tags and html tags and you end up with the plain text. (you should add line breaks on div en br tags though otherwise you have text on one line.) Or you might look for HTML2TEXT function which does all that work for you. But the readable text is there in the .outerHTML.