Mike,

Running as Administrator does not really solve the problem.
Vista protects everything beneath the "C:\Program Files" directory.
This is simple to do in the right way, which has been in place since
Windows NT 4.0. The operating system maintains an environment
variable: USERPROFILE which is the PATH to a directory which is
private to the currently logged in user. In a batch file, you can
dereference the environment variable like this:

CD /D %USERPROFILE%

The statement above changes to the users private directory.

When writing a program, the Windows API call:
GetEnvironmentVariable

will return the value of an environment variable.
Check the Delphi help for details.

Glenn Lawler
www.incodesystems.com

-----Original Message-----
From:   Mike [SMTP:[EMAIL PROTECTED]
Sent:   Tuesday, July 31, 2007 4:13 PM
To:     advanced_delphi@yahoogroups.com
Subject:        Re: [advanced_delphi] Re-Writing for Vista

the problem really is Vista - it changed all programs to run at a User 
Level - it's easy enough to change - may not be the best way (at least in 
M$'s eyes)

right click on the desktop shortcut icon and change it to "Run as 
Administrator"


  ----- Original Message -----
  From: Marie F Vihonsky
  To: Advance Delphi
  Sent: Tuesday, July 31, 2007 3:35 PM
  Subject: [advanced_delphi] Re-Writing for Vista


  Hi All,

  I have just gotten the first glitches with Vista from users and it
  involves the logic for writing to the databases and indexs. I'm still
  of the old DOS mindset and a self-taught programmer. I have all my
  files located under the main folder where the program is installed and
  using Inno-Setup, I have the user install to:
  c:\program files\myprogram

  Using Delphi 5, I can determine if the user has installed the program
  somewhere else by determining where the EXE is located using this code:
  exepath:=ExtractFilePath(Application.ExeName);
  datapath := exepath + 'data\';
  if not DirectoryExists(datapath) then
  if not CreateDir(datapath) then begin
  raise Exception.Create('Cannot create '+ datapath);
  exit;
  end;
  mdxpath := exepath + 'indexs\';
  if not DirectoryExists(mdxpath) then
  if not CreateDir(mdxpath) then begin
  raise Exception.Create('Cannot create '+ mdxpath);
  exit;
  end;

  Under Vista, I understand that this is a NO-NO since it requires write
  permission from the Administer. Now my Users are all individual HOME
  users, who are the Admins and don't know how to set-up their pc's to run
  the program they way it did under all previous versions of Windows.

  I'm at a loss, since I don't have a PC with Vista. Soon to be rectified
  before I go nuts trying to answer questions from my users!

  Meanwhile, how should I re-write my programs? Where can I write from the
  program so that the user doesn't need Admin privileges and how do I
  determine the folder name?

  Marie

Reply via email to