Recent

Author Topic: detect that my app is open on the windows installation screen or windows live cd  (Read 947 times)

Ericktux

  • Sr. Member
  • ****
  • Posts: 350
hello friends, a question, how can I detect that my application is open on the windows installation screen or windows live cd.
« Last Edit: August 18, 2020, 07:08:04 pm by Ericktux »

jamie

  • Hero Member
  • *****
  • Posts: 6518
You could use "GetDriveType"

You need to feed it the path of your app that is currently running..

https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getdrivetypea

The only true wisdom is knowing you know nothing

Ericktux

  • Sr. Member
  • ****
  • Posts: 350
I found a possible solution, I have to query these registry values:

HKEY_LOCAL_MACHINE\System\Setup\SystemSetupInProgress
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\MiniNT

I share the code

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, registry;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     Label1: TLabel;
  17.     Label2: TLabel;
  18.     Label3: TLabel;
  19.     Label4: TLabel;
  20.     procedure Button1Click(Sender: TObject);
  21.   private
  22.  
  23.   public
  24.  
  25.   end;
  26.  
  27. var
  28.   Form1: TForm1;
  29.   datos1, datos2: Tregistry;
  30.  
  31. implementation
  32.  
  33. {$R *.lfm}
  34.  
  35. { TForm1 }
  36.  
  37. procedure TForm1.Button1Click(Sender: TObject);
  38. begin
  39.     datos1:=TRegistry.Create(KEY_READ);
  40.     datos1.RootKey:=HKEY_LOCAL_MACHINE;
  41.     datos1.OpenKey('\System\Setup', false);
  42.     if datos1.ReadInteger('SystemSetupInProgress')=0 then
  43.     begin
  44.          Label1.Caption:='SystemSetupInProgress = 0';
  45.          Label3.Caption:='you are in windows normal';
  46.     end
  47.        else
  48.        begin  // SystemSetupInProgress = 1
  49.             Label1.Caption:='SystemSetupInProgress = 1';
  50.             Label3.Caption:='you are in windows installation';
  51.        end;
  52.     datos1.CloseKey;
  53.     datos1.Free;
  54.  
  55.  
  56.     datos2:=TRegistry.Create;
  57.     datos2.RootKey:=HKEY_LOCAL_MACHINE;
  58.     datos2.OpenKey('\System\CurrentControlSet\Control', false);
  59.     if datos2.KeyExists('MiniNT') then
  60.     begin
  61.          Label2.Caption:='Key "MiniNT" exist';
  62.          Label4.Caption:='you are in windows PE';
  63.     end
  64.        else
  65.        begin
  66.             Label2.Caption:='Key "MiniNT" NOT exist';
  67.             Label4.Caption:='you are in windows normal';
  68.        end;
  69.     datos2.CloseKey;
  70.     datos2.Free;
  71.  
  72.     {
  73.     HKEY_LOCAL_MACHINE\System\Setup\SystemSetupInProgress
  74.     HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\MiniNT
  75.     HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\MiniNT
  76.     }
  77. end;
  78.  
  79. end.

at the moment it works perfect  :)
remember to have two versions of your app (32 and 64) and test.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5644
  • Compiler Developer
I found a possible solution, I have to query these registry values:

HKEY_LOCAL_MACHINE\System\Setup\SystemSetupInProgress
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\MiniNT

Yes, checking these is indeed the way to do this.

 

TinyPortal © 2005-2018