Delphi

Execute external program from Linux/Delphi 10.2 console application

爱⌒轻易说出口 提交于 2021-01-27 21:08:39
问题 How can I execute an external program from a Linux console application created in Delphi 10.2 Tokyo? What I want to do is execute a shell command with parameters like /home/test/qrencode -o /tmp/abc.png '08154711' I do not need the output of the program but it should be executed synchronously. It is easy in Windows environments but as 64 bit Linux support in Delphi (after Kylix) is quite new, I could not find any hints on the Web by now. Any tip helping me to solve that is very appreciated.

TDirectory.GetDirectoryRoot does not handle correctly paths of Max_Path characters

一笑奈何 提交于 2021-01-27 17:51:10
问题 IOUtils.TDirectory.GetDirectoryRoot(Folder) gives me an error when 'Folder' is 259 chars long (yes, it includes the \ separator at the end): Project Tester.exe raised exception class EPathTooLongException with message 'The specified path is too long'. I though that I can use up to 260 chars in paths. Why GetDirectoryRoot does not accept paths that are of Max_Path chars? 回答1: And this is why: class procedure TDirectory.InternalCheckDirPathParam(const Path: string; const ExistsCheck: Boolean);

How to format a number in scientific notation

爱⌒轻易说出口 提交于 2021-01-27 17:01:48
问题 So basically I have this function which returns: 3.00000000000E000 function lang():extended; begin wynik := 0 ; counter := 1; temp :=1; input := 2; for i:= 1 to 4 do begin for k:= 1 to 4 do begin if i = k then counter := counter else temp := temp * ((input - a[k]) / (a[i] - a[k])); end; wynik := wynik + temp*f[i]; temp := 1; end; Result := wynik; end; But when I try to print it on the application screen using FloatToStr, I get only 3. procedure TFormCalculator.Button1Click(Sender: TObject);

How to format a number in scientific notation

时光总嘲笑我的痴心妄想 提交于 2021-01-27 17:01:31
问题 So basically I have this function which returns: 3.00000000000E000 function lang():extended; begin wynik := 0 ; counter := 1; temp :=1; input := 2; for i:= 1 to 4 do begin for k:= 1 to 4 do begin if i = k then counter := counter else temp := temp * ((input - a[k]) / (a[i] - a[k])); end; wynik := wynik + temp*f[i]; temp := 1; end; Result := wynik; end; But when I try to print it on the application screen using FloatToStr, I get only 3. procedure TFormCalculator.Button1Click(Sender: TObject);

Delphi - Create a custom TToolBar component

五迷三道 提交于 2021-01-27 15:50:17
问题 I want to create a custom toolbar control (descendant TToolBar) which should have some default-toolbarButtons. So I've created a simple constructor which creates 1 default button: constructor ZMyToolbart.Create(AOwner: TComponent); var ToolButton : TToolButton; begin inherited; Parent := Owner as TWinControl; ToolButton := TToolButton.Create(Self); ToolButton.Parent := Self; ToolButton.Caption := 'Hallo'; end; The problem is, after draggign the custom control on a form, the toolbar-button is

Hooking an App made on MSVC++ with __fastcall enabled from an injected Delphi dll

可紊 提交于 2021-01-27 14:37:26
问题 I am trying to hook a function within a application compiled with microsoft visual studio 2010, with __fastcall enabled from a delphi 2010 dll, but I am not to skilled to figure out how to detour the following problem: The C++ function is: void __fastcall function(int arg1; char* arg2); I was trying something like that (using uallHook): var FTextMessage : procedure(Modo: integer; Msg: pchar); register; procedure onTextMessage(Modo: integer; Msg: pchar); register; begin ShowMessage(inttostr

Conditional Compilation in common unit depending from specific project?

荒凉一梦 提交于 2021-01-27 14:13:58
问题 In Delphi XE2, I have a unit MyUnit.pas which is used by two different projects ProjectA and ProjectB . MyUnit contains a statement DoSomething; (which is a procedure implemented in an other unit OtherUnit.pas ). Now I want to use Conditional Compilation to include DoSomething only in ProjectA compilation and not in ProjectB compilation, so to avoid ProjectB including/compiling OtherUnit.pas indirectly. This MUST be Conditional Compilation , as a simple if/else statement obviously does not

Delphi XE LiveBindings - Bits to Byte

十年热恋 提交于 2021-01-27 12:43:20
问题 I just discovered livebindings with Delphi. And created my first components for handling a control-word for a frequency converter. The component it self seems to work well testing it in the form designer. However, compiling and running the application things doesn't work. Screenshot from livbindings like this: And here is the code for the component unit cBits2Byte; interface uses System.SysUtils, System.Classes; type TBits2Byte = class(TComponent) private { Private declarations } fBit00,

How do I export an interface written in C# to achieve Delphi code generated by TLB

馋奶兔 提交于 2021-01-27 12:28:46
问题 I'm currently developing a "drop-in" replacement of an old COM interface (which is used to communicate with other devices). This interface is currently used in a big application. The old COM interface is now deprecated by the author of the library they now only support and develop a C# interface. My task is to develop the above mentioned "drop-in" replacement. Which acts as a proxy between the old application (written in Delphi) and the new C# based interface. Im trying to have as little as

Wait for process started by IContextMenu.InvokeCommand

拥有回忆 提交于 2021-01-27 12:12:58
问题 I have a TListView whose items are files, which the user can open via double clicking on them. To do this, I save the file in the windows temp folder, start a thread that opens the saved file with ShellExecuteEx() , and let it wait for ShellExecuteInfo.hProcess , like this: TNotifyThread = class(TThread) private FFileName: string; FFileAge: TDateTime; public constructor Create(const FileName: string; OnClosed: TNotifyEvent); overload; procedure Execute; override; property FileName: String