Search the Community
Showing results for tags 'console'.
Found 10 results
-
I am trying to hide console input when a user has to enter a password in a command prompt window. I had the bright idea of redirecting the output of the command prompt to the NUL file but this code does not work even though you can execute the function without error. I am sure there used to be an easy way to do this! Do forget to include windows in the uses clause. Thanks for any help in advance Jack T function GetPassWordInput:String; var C:Char; S:String; H,HNULL:Cardinal; B:BOOL; begin HNULL := CreateFile('NUL',GENERIC_WRITE,FILE_SHARE_WRITE,nil, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM,0); Assert(HNULL <> 0,'CREATING NUL FILE FAILED'); H:= GetStdHandle(STD_OUTPUT_HANDLE); B:=SetStdHandle(STD_OUTPUT_HANDLE,HNULL); Assert(B,'Set standhard handle failed to assign HNULL'); try begin repeat Read(C); if C=#8 then begin if Length(S)>1 then begin S:=LeftStr(S,Length(S)-1); end; end else if C<>#13 then begin S:=S+C; end; until C=#13; end finally begin SetStdHandle(STD_OUTPUT_HANDLE,H); CloseHandle(HNULL); end; end; Result := S; end;
- 1 reply
-
- win32
- command prompt
-
(and 2 more)
Tagged with:
-
I have a stupid question on how to "gracefully" terminate a Windows console application. I am not very familiar with how processes are established, how parent/child relationships are handled, consoles, all that. I might be missing basics. What I am doing: I have a central application with a VCL interface It uses CreateProcess(..) to invisibly spawn some console applications in the background Some are kept running 24/7, some are just started on demand, crunch some data, then terminate These console applications get their stdIn, stdOut and stdErr pipes redirected to some pipes I created in my central applications, so I can easily process their output, and control them (if they get controlled from stdIn). So far, everything worked like a breeze My issue now: I am now integrating another console application that just runs 24/7 and has no way of gracefully shutting it down It will only end on either pressing CTRL+C on a regular terminal, or by sending it a CTRL_BREAK_EVENT from my central application by using GenerateConsoleCtrlEvent. I know that Windows will "clean up" after the process has ended, but I am not sure if this way of shutting the process down is still a bit too "rude" My question: The documentation of the GenerateConsoleCtrlEvent function states "All console processes have a default handler function that calls the ExitProcess function." The documentation on ExitProcess gets into more detail of what it actually does, but I have a hard time understanding the implications. After sending the CTRL_BREAK_EVENT to the console application, my application will still give it a few hundred milliseconds to power down until it will resort to TerminateProcess but never has to, because the console application will finish within less than 5 ms. I am just unsure whether I am doing it right or maybe there is a better way of "gracefully" shutting down a console application that does not handle CTRL+C at all.
-
Website: github.com/viniciusfbb/skia4delphi Skia4Delphi is a cross-platform 2D graphics API for Delphi based on Google's Skia Graphics Library (skia.org). Google's Skia Graphics Library serves as the graphics engine for Google Chrome and Chrome OS, Android, Flutter, Xamarin, Mozilla Firefox and Firefox OS, and many other products. Skia provides a more robust Canvas, being very fast and very stable, with hundreds of features for drawing 2D graphics, in addition to a text shaping engine designed to render texts in the most diverse languages with right-to-left support (such as the Persian language), full support for loading SVG files, support for creating PDF files, support for rendering Lottie files (verotized animations created in Adobe After Effects), integration with the GPU, among countless other cool features. Skia's idea is similar to Firemonkey's, the same codebase used in an OS will work the same on other platforms. It is also possible to design using the CPU in independent background threads. Skia also has native codecs, of course if you don't use the SKCodec class, when loading an encoded image it will give priority to using the platform's native codec, but it is possible to use its codec, for example for jpeg files it uses libjpeg-turbo and for png files libpng which maybe in certain environments may perform better than native. See some examples: Advanced shapes Advanced text rendering / shaping Svg Lottie files And much more...
-
I have created library for Delphi-Console-Applications Supports Windows 11 (and earlier from XE5?) Replaces CRT Unit - crt.pas Can be used to write modern and appealing console applications. Should allow older (legacy) source code (Borland Pascal 7.0) to run under Windows. Unicode-Support (including e.g. chinese characters) many more features - see GitHub https://github.com/playcom-de/Console I hope this is helpful for someone. Question, suggestions and error reports are welcome.
-
v4.0.0 Skia library version has been updated from Milestone 98 to 107; [API] Added support for iOS Simulator ARM 64-bit to RAD Studio 11.2 Alexandria or newer. [API] Added TBitmap.CreateFromSkImage; [Framework] Added LinesCount and DidExceedMaxLines properties to TSkLabel; [Framework] Added new splashscreen to our main demo; [Samples] Added ISkParagraph.Visit method; (#136) [API] Rewritted TSkAnimatedImage and TSkAnimatedPaintBox, adding features to have full control over the animation; (#104) [Framework] Some of them are: Start and Stop methods, and AutoReverse, CurrentTime, Delay, Duration, Enabled, Inverse, Loop, Pause, Progress, Running, Speed, StartFromCurrent, StartProgress and StopProgress properties. All these properties and methods are in the Animation property of the TSkAnimatedImage and TSkAnimatedPaintBox. Improved automatic tests; [Tests] Fixed issue in edit controls with emoji or Chinese char; (#159) [Render] Fixed custom fonts on Android deployed to assets\internals that was not automatically loaded; (#153) [Render] Fixed webinar demo splashscreen; [Samples] Fixed exception loading images from stream or bytes; (#111) [Framework] Fixed TSkAnimatedImage exceeding bounds in some WrapMode [Framework] Fixed TBitmap.SkiaDraw issues in VCL; [Framework] Fixed TBitmap.ToSkImage AV in VCL; [Framework] Fixed flicker problem in TSkAnimatedImage in VCL; [Framework] Fixed text print; (RSP-16301) [Render] Fixed TSkAnimatedImage with 90° rotation that fails to play; [Framework] Fixed high DPI issues of TSkLabel in VCL; [Framework] Fixed high DPI issues in VCL demo; [Samples] Fixed SkRegion.IsEqual; [API] Fixed link with runtime packages; (#163) [Setup] Fixed big GIF issue; (#118) [API] Fixed wrong pixel format on Android in Delphi 10.3 Rio; [Render] Minor improvements and fixes. Skia version: 107.0.0 Compatibility break We are in continuous development, so some updates will bring compatibility breaks. So, pay attention to version numbers, we use semantic versions (for major versions there is some compatibility break). See some breaking changes in this version: No longer use TSkAnimatedImage.Enabled to start or stop an animation. Now use TSkAnimatedImage.Animation.Enabled. The class TSkTypefaceManager is deprecated in favor to TSkDefaultProviders; Several changes in API (Skia.pas); Supported platforms RAD Studio 11 Alexandria: All platforms RAD Studio 10.3 Rio or newer: Windows and Android RAD Studio XE7 or newer: Windows Github: github.com/skia4delphi/skia4delphi Website: skia4delphi.org
-
v3.3.0 Added HeightMultiplier property to TSkLabel to change the default line height; Added tag properties to TCustomWordsItem of TSkLabel; Added TItemClickedMessage to intercept the OnClick of all TCustomWordsItem of TSkLabel controls; Improvements in the OnClick triggering of TSkLabel items; Fixed many issues in Windows when using Skia4Delphi Canvas (including combobox dropdown); Fixed wrong colors in iOS with services when using Skia4Delphi Canvas: IFMXTakenImageService, IFMXCameraService, IFMXPhotoLibrary and IFMXShareSheetActionsService; Fixed effects and filters issue in Metal when using Skia4Delphi Canvas; Fixed wrong text size when using Skia4Delphi Canvas (fixing problems with TMemo and TTMSFMXHTMLText); Fixed AV in TSkLabel when the text of a TWordsItem starts with a sLineBreak; Fixed case-insensitive of image formats when saving images; Fixed wrong draws with stroke thickness zero when using Skia4Delphi Canvas; Fixed black screen startup on iOS in simple forms with only shapes when using Skia4Delphi Canvas; Fixed specific cases of performance issues in Windows when using Skia4Delphi Canvas; Fixed projects of RAD Studio 11; Fixed popup menu exception in rasterization mode when using Skia4Delphi Canvas; Fixed modulate color problem before RAD Studio 11.1 (which involves TintColor and TintIconColor properties on mobile); Minor improvements and fixes. Github: github.com/skia4delphi/skia4delphi Website: skia4delphi.org
-
v3.0.1 Increase default form quality of Skia4Delphi Canvas in Android and iOS; Improve documentation about Righ-To-Left text rendering with Skia4Delphi Canvas; Fixed demo in Android 11; Fixed exception in ExcludeClipRect; Fixed quality of DrawImage of Skia4Delphi Canvas; Fixed some wrong pixel format in Android and iOS (without metal) that caused wrong colors of TCameraComponet; Fixed opacity of TSkAnimatedImage, TSkLabel and TSkSVG when using Skia4Delphi Canvas; Fixed TSkSVG cache; Fixed compilation with FmxLinux; Fixed FontWeight in FmxLinux; Fixed PDF viewer of demo in FmxLinux; Fixed setup and improve the logs; Fixed build.sh script; Fixed chocolatey package; v3.0.2 Fixed pixelformat of TBitmap of Skia4Delphi Canvas; Github: github.com/skia4delphi/skia4delphi Website: skia4delphi.org
-
Hi Guys, D10.4.2, latest Indy 10, Win 10. I have created a console app with my Indy code in it. The code is exactly the same as I have in my VCL app, same settings/parameters, etc, which works. But. When I run it in the cmd prompt I get the following error. >>EIdTLSClientTLSHandShakeFailed: SSL negotiation failed.<< Now, I freely acknowledge I probably don't have something set right. 😞 Here is the source I have att.. program DBiPREmail; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, IdMessage, IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, IdMessageClient, IdSMTPBase, IdSMTP, IdBaseComponent, IdComponent, IdIOHandler, IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdSSLOpenSSL, IdAttachment, IdMessageParts, IdEMailAddress, IdAttachmentFile, IdGlobal, IdText; // These are all in just to start. To be cleaned up when working.. var dmPREmail: TdmPREmail; IdSMTP: TIdSMTP; IdMessage: TIdMessage; IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL; // to allow SSL authenticate // try // try // IdSMTP := TIdSMTP.Create(nil); // try // IdSSLIOHandlerSocketOpenSSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(IdSMTP); // IdMessage := TIdMessage.Create(IdSMTP); // // IO HANDLER SETTINGS // with IdSSLIOHandlerSocketOpenSSL1 do begin MaxLineAction := maException; SSLOptions.Method := sslvTLSv1; end; // IdSMTP.Host := 'my smtp email host'; // IdSMTP.Port := 587; // IdSMTP.Username := 'my user name'; IdSMTP.Password := 'my password'; // IdSMTP.IOHandler := IdSSLIOHandlerSocketOpenSSL1; IdSMTP.AuthType := satDefault; // IdSMTP.UseTLS := utUseExplicitTLS; // // SETTING email MESSAGE DATA // IdMessage.Clear; // IdMessage.From.Address := 'my email address'; IdMessage.Recipients.EMailAddresses := 'second email address'; IdMessage.CCList.EMailAddresses := 'third email address'; // IdMessage.Subject := 'Test Email Subject'; IdMessage.Body.text := 'Test Email Body'; IdMessage.Priority := mpHigh; // with TIdText.Create(IdMessage.MessageParts, nil) do begin // Body.text := Body.text + '<p style="color: #5e9ca0;">This is a test <strong>message</strong> for <span style="color: #ff0000;"><strong>emailing</strong></span>.</p><h1 style="color: #5e9ca0;"> </h1>'; ContentType := 'text/html'; end; // IdMessage.ContentType := 'multipart/mixed'; // try IdSMTP.Connect; except on E: Exception do begin Writeln(E.ClassName, ': ', E.Message); Exit; end; end; // try try IdSMTP.Send(IdMessage); finally IdSMTP.Disconnect(); end; except on E: Exception do begin Writeln(E.ClassName, ': ', E.Message); Exit; end; end; // finally // IdSMTP.Free; // end; // except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; // end. Thoughts, suggestions appreciated.. Regards & TIA, Ian
-
class wrongly placed, when added in the context of a Console application
Didier Cabalé posted a topic in MMX Code Explorer
Hi there, here are the steps that lead to the problem: 1. from the IDE, create a "console application" 2. from MMX code explorer, click on the "Add Class" button, and add the proposed class 3. state the class is added at the wrong place in the IDE editor (cf attached picture) -
Hello, I'm sorry if this topic was discussed several times, I was able to find only a REALLY low amount of information and none of them seemed to work. I need to create a TSslHttpServer (in runtime) and serve the client requests. Everything went fine in my test app so I started to port it to it's final state but it refused to work. Port is opened but no events are being fired. Since I already met this with the standard TClientSocket / TServerSocket so I quickly put my message pump generator in the Repeat...Until Terminated cycle in my main thread. No joy, so I started to investigate. I already found that I should do something with the NOFORMS directive but I was unable to make it work. Result is always the same: connection to the opened port is possible, but no events are fired in my Delphi app, nor the connection responds. - I added the NOFORMS directive to the ICS install package and rebuilt all - I added the NOFORMS directive to my app and rebuilt all - I added the {$DEFINE NOFORMS} to my app's dpr - tried enabling or disabling the MultiThreaded property - Tried moving to my messagepump to SslHttpServer.OnMessagePump - Tried SslHttpServer.ProcessMessages, .MessagePump, .MessageLoop I also mixed the above, meaning tried each combination of each message processor method with each directive. TMyThread = Class(TThread) strict private myhttpsrv: TSslHttpServer; [...] Constructor TMyThread.Create; Begin myhttpsrv := TSSlHttpServer.Create(nil); myhttpsrv.OnClientConnect := WebServerClientConnect; myhttpsrv.OnMessagePump := WebServerMessagePump; [...] Procedure TMyThread.Execute; Begin Repeat If Not _httpsrv.ListenAllOK Then _httpsrv.Start; // myhttpsrv.ProcessMessages; // myhttpsrv.MessageLoop; // myhttpsrv.MessagePump; Until Terminated; [...] Procedure TMyThread.WebServerClientConnect(Sender: TObject); Begin WriteLn('Client connected...'); [...] Procedure TMyThread.WebServerMessagePump(Sender: TObject); Begin If PeekMessage(msg, 0, 0, 0, 0) Then Begin GetMessage(msg, 0, 0, 0); TranslateMessage(msg); DispatchMessage(msg); End; [...] What I am doing wrong? Any ideas on how I can make it work? Thanks!