Delphi

Delphi service locator

北城余情 提交于 2021-01-28 10:51:48
问题 As I had before in Java, I try to do a ServiceLocator in Delphi. Some code exist but it's didn't work like expected. I don't want a case with enum or anything else, I want a code that I don't have to touch when I create a new class. I have a global interface for my application, and all the other : type IMyApp = interface end; IBuilder = interface(IMyApp) procedure Build; end; IPrint = interface(IMyApp) procedure Print; end; ICalculator = interface(IMyApp) procedure Calc; end; I want a class

TClientDataSet error: “Missing data provider or data packet”

纵然是瞬间 提交于 2021-01-28 10:05:38
问题 I'm creating a TClientDataSet and TDataSetProvider in code in Delphi, and loading the data from a TUniQuery (Devart UniDAC). After setting the properties for the dataset provider and the clientdataset, I try to open the clientdataset and get the runtime exception: "Missing data provider or data packet". I'm not sure why its happening and would be glad if anyone could point out what exactly is wrong. This is my code: //uq is a TUniQuery correctly set to an active TUniConnection cdsFirstNames :

TClientDataSet error: “Missing data provider or data packet”

非 Y 不嫁゛ 提交于 2021-01-28 10:01:28
问题 I'm creating a TClientDataSet and TDataSetProvider in code in Delphi, and loading the data from a TUniQuery (Devart UniDAC). After setting the properties for the dataset provider and the clientdataset, I try to open the clientdataset and get the runtime exception: "Missing data provider or data packet". I'm not sure why its happening and would be glad if anyone could point out what exactly is wrong. This is my code: //uq is a TUniQuery correctly set to an active TUniConnection cdsFirstNames :

FireDAC Query dropping special characters in SQL statement to SQL Server

你离开我真会死。 提交于 2021-01-28 08:13:24
问题 I have hit this issue off and on in Delphi 10.3 using FireDAC and the EMS Rad Server. I have not experienced it in Delphi 10.2 or below, but I am not using FireDAC anywhere but in Delphi 10.3. The issue I am experiencing is some special characters seem to be getting stripped out of the SQL statements before they reach the Database. For example, if I run: update messageread set MessageDeliveredDateTime = '8/11/2020 6:33:45 PM' where messageread.dts in ('5/7/2020 12:48:20 PM-!+[[786', '5/7/2020

Run an external program as admin in a standard user account (Delphi) [closed]

喜你入骨 提交于 2021-01-28 08:00:29
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 28 days ago . Improve this question I have a code that helps me run an external program as admin. It works smoothly if the user that is running my program is an admin. procedure RunApp; const NotepadPath = 'C:\windows\system32\notepad.exe'; var SI: TStartupInfo; PI: TProcessInformation; begin ZeroMemory(@SI,

Is there a way to get GUID from a generic constraint type?

喜夏-厌秋 提交于 2021-01-28 06:42:38
问题 In the sample code below, the Run<T>() displays the values of GUID IFoo and IFoo<T> interfaces: type IBar = interface ['{992E6597-42F1-40F8-B678-C4A86864B030}'] end; IFoo = interface ['{0C589AF8-5727-4EAA-BB41-6D51D70B9D35}'] end; IFoo<T> = interface(IFoo) ['{8FF54F6B-0896-4EA3-85F8-66BA70F9D2DA}'] end; TTest = class public class procedure Run<T: IFoo>; end; class procedure TTest.Run<T>; var LContext: TRttiContext; IFoo_T_TypeInfo: PTypeInfo; IFooTypeInfo: PTypeInfo; begin IFoo_T_TypeInfo :=

Invalid float point operation on Move?

泪湿孤枕 提交于 2021-01-28 06:41:40
问题 I´m experiencing an weird issue that I have never seen before, in Delphi 2010 sometimes when using the routine CopyMemory (Which internally calls Move) I get an Invalid Float Point Operation exception, when such thing could happen when using Move?? I have a debug information in assembler, I have checked the source code of Move and the problem happens in FILD instruction, I found that FILD converts an integer value from memory to float point in a register and it could trigger that invalid

Using Delphi, I'm trying to change the volume of the AndroidTTS, but I seem to keep getting the error “External exeception 1”

一曲冷凌霜 提交于 2021-01-28 06:12:54
问题 I'm using these libraries: https://github.com/jimmckeeth/FireMonkey-Android-Voice https://github.com/FMXExpress/android-object-pascal-wrapper/tree/master/android-25 Here is my source code: unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, SpeechRecognition, FMX.Controls.Presentation, FMX.ScrollBox, FMX.Memo, FMX.StdCtrls, FMX.Memo.Types, AndroidTTS, FMX.Media, System.IOUtils

[转载]delphi实现音频捕捉与播放

拜拜、爱过 提交于 2021-01-28 04:02:00
delphi实现音频捕捉与播放 unit unit1; interface uses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms, Dialogs, mmsystem, StdCtrls; const memBlockLength = 500; type Tmemblock = array[0..memblocklength] of byte; PmemBlock = ^TmemBlock; TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); private { Private declarations } HwaveIn : PHWaveIn ; HWaveOut: PHWaveOut ; close_invoked, close_complete : boolean ; in_count, out_count : integer ; procedure MMOutDone(var msg:Tmessage);message MM_WOM_DONE; procedure

How to save a memo as unicode

霸气de小男生 提交于 2021-01-28 03:58:17
问题 I am using Delphi 7, How can I save a Memo as a Unicode text file, I find some example for save it as UTF-8 text file, but I need an example for saving file as unicode. Thanks for any help 回答1: You need to use a control that supports Unicode. Delphi 7 TMemo does not. Which means that your real problem is not so much saving the content, but admitting the content in the first place. You should deal with this by switching to the TNT Unicode components. Once you start using the TNT Unicode