Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1079261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:50:32+00:00 2026-05-16T21:50:32+00:00

I am writing a console application using BDE 2006 and I want it to

  • 0

I am writing a console application using BDE 2006 and I want it to be able to prompt for a password string and mask it with “*” as the user is typing. I have looked around but I could not find examples of how to do this. Everything I saw was how to do this in TEdit. Any pointers on how to accomplish this?

Thanks in advance,

Nic

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:50:33+00:00Added an answer on May 16, 2026 at 9:50 pm

    Here’s a working solution:

    program Project2;
    
    {$APPTYPE CONSOLE}
    
    uses
      SysUtils, Windows;
    
    function GetPassword(const InputMask: Char = '*'): string;
    var
      OldMode: Cardinal;
      c: char;
    begin
      GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), OldMode);
      SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), OldMode and not (ENABLE_LINE_INPUT or ENABLE_ECHO_INPUT));
      try
        while not Eof do
        begin
          Read(c);
          if c = #13 then // Carriage Return
            Break;
          Result := Result + c;
          if c = #8 then // Back Space
            Write(#8)
          else
            Write(InputMask);
        end;
      finally
        SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), OldMode);
      end;
    end;
    
    begin
      try
        Writeln(Format(sLineBreak + 'pswd=%s',[GetPassword]));
        Readln;
      except
        on E: Exception do
          Writeln(E.ClassName, ': ', E.Message);
      end;
    end.
    

    Update: Note that the above code handles the BackSpaces visually, but keeps them embedded in the password, which might not be what you want.
    In that case the following code would filter them out:

      if c = #13 then // Carriage Return
        Break;
      if (c = #8) and (Length(Result) > 0) then  // Back Space
      begin
        Delete(Result, Length(Result), 1);
        Write(#8);
      end
      else
      begin
        Result := Result + c;
        Write(InputMask);
      end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If we are writing about power-wise option - is using a console-based application in
I have a C# console application that logs a lot to the console (using
I am writing a console application which makes use of the F1 key (for
I'm writing a sample console service host and I want to plug into WCF
I'm writing some excel-like C++ console app for homework. My app should be able
I'm writing a console application which is looking up information about SSIS packages in
I am trying to writing a console application. It has its original console, let's
I'm currently writing a c++ console application that grabs the mouse position at regular
I'm writing an Air application using only Actionscript, and Flex3 SDK as the compiler.
I am writing a console program in C#. Is there a way I can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.