Yes, da para fazer sem usar o Banco de Dados, basta gravar essa informação no Registro do Windows como mencionado no comentário do amigo @Paruba, podemos gravar na pasta do Registro HKEY_CURRENT_USER
, we will create a Folder inside this folder with the name of our system, and inside this folder we will create a record with the desired information!
Function for Reading Record:
function frmteste.LerRegistro: Boolean;
const
vRaiz: String = 'Nome_Seu_Sistema';
var
Registro: TRegistry;
begin
Result := False;
//Chama o construtor do objeto
Registro := TRegistry.Create;
with Registro do
begin
// Somente abre se a chave existir
if OpenKey(vRaiz, False) then
begin
//Validando se ja abriu ou não...
if ValueExists('Hint_Inicial') then
begin
if (ReadInteger('Hint_Inicial') = 1) then
Result := True;
end;
// Fecha a chave e o objeto
Registro.CloseKey;
Registro.Free;
end;
end;
End;
With this function, you can know if you have ever opened the System or if it is the first execution, because in Create
we will implement the recording of this information:
procedure frmTeste.FormCreate(Sender: TObject);
const
vRaiz: String = 'Nome_Seu_Sistema';
var
Registro: TRegistry;
begin
{Se não encontrou o Registro, Cria o Registro informando...
...que ja mostrou o Hint Inicial}
if (LerRegistro = False) then
begin
//Chama o construtor do objeto
Registro := TRegistry.Create;
{ Abre a chave (se o 2°. Parâmetro for True, ele cria a chave caso ela ainda não exista.}
Registro.OpenKey(vRaiz, True);
//Aqui passamos 1 como parâmetro, 0 = nunca abriu 1 = ja abriu
Registro.WriteInteger('Hint_Inicial', 1);
//Fecha a chave e o objeto
Registro.CloseKey;
Registro.Free;
end;
end;
Now on the Show
of the Main Form you implement the reading of the Record:
procedure frmTeste.FormShow(Sender: TObject);
begin
if LerRegistro = False then
begin
{Aqui você chama o procedimento do Hint Inicial
Chamada da função ou procedimento responsável pelo Hint Inicial.}
end;
end;
In the given example, the registry folder would be with the following structure:
HKEY_CURRENT_USER\Nome_Seu_sistema\Hint_Inicial
Edit:
It is still possible to Read and Write to a text file at the root of your system, just use a Tstringlist at the time of Show
form using its properties: LoadFromFile
or SaveToFile
. But the Best and Most Professional Option is to use the method I reported above, write to the Windows Registry!
Important Note: Whenever you save a value in the Windows Registry, the
Uninstall your system don’t forget to remove that entry! So
does not get junk in User Registration!
I await the Feedback!
You can save the information to an INI file or to the Windows Registry. Be careful with the issue of permissions, if saving in INI prefer in a folder where the user has full permission. In the case of the record, you must use the key HKEY_CURRENT_USER... Ah, and you don’t have to do anything at hand, there are free components that help you make this settings recording, have a look. Hug.
– Guybrush