Recent

Author Topic: Manifest in Windows 7 ?  (Read 4016 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 3945
    • StrumPract is the musicians best friend
Manifest in Windows 7 ?
« on: April 15, 2011, 01:05:54 pm »
Hello everybody  :)

Could you try this code in Windows 7 ?

Code: [Select]
unit Unit1;

{$mode objfpc}{$H+}

interface

uses

 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)

  procedure FormCreate(Sender: TObject);

  private

    { private declarations }

  public

    { public declarations }

  end;

var

  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);

begin

  if DirectoryExists(pchar('C:\Program Files\test')) then else

       ForceDirectories(pchar('C:\Program Files\test'));

   if DirectoryExists(pchar('C:\Program Files\test')) then

   MessageDlg('\test\ exists...'  ,mtInformation, [mbYes], 0)

   else MessageDlg('\test\ do not exist...'  ,mtWarning, [mbYes], 0) ;

 if DirectoryExists(pchar('C:\Program Files\test')) then

 removedir(pchar('C:\Program Files\test')) ;

   end;
         end;
end.

In Windows 7
First try to compile without Manifest enabled.
You should get message \test\ exists...
Now compile it with Manifest : the directory is not created and you get \test\ do NOT exist !

The new policy of Microsoft redirects all files created in C:\Program Files to
C:\Users\your_user_name\AppData\Local\VirtualStore\Program Files\

It seems that Manifest do not care about that... :'(
« Last Edit: April 15, 2011, 01:08:59 pm by fredvs »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

DirkS

  • Sr. Member
  • ****
  • Posts: 251
Re: Manifest in Windows 7 ?
« Reply #1 on: April 15, 2011, 01:23:28 pm »
You need UAC elevation to manipulate files / directories in 'Program Files' directly. Lazarus has no method of doing that for you at the moment, so you'll have to create / change the manifest file to request elevation.

Gr.
Dirk.

Fred vS

  • Hero Member
  • *****
  • Posts: 3945
    • StrumPract is the musicians best friend
Re: Manifest in Windows 7 ?
« Reply #2 on: April 15, 2011, 01:26:17 pm »
@ DirkS.

OK, or, simpler, i do not use Manifest.... ;)

Thanks
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018