Many people add a “requireAdministrator” manifest to their Application to elevate their application in Vista. However itis not needed all the time so there is a second way that allows  to elevate the program even in Windows XP.
The solution is to restart the application with ShellExecute and the “runas” verb. In Vista you’ll get the elevation prompt, on XP (or if UAC is disabled) you’ll get a logon dialog that allows the user to type in Administrator credentials.

The following code executes the same application a second time but does the trick with “runas”. JwShellExecute raises an exception if anything goes wrong. The exception error constant E_USER_CANCELED_OPERATION reports that the user has canceled the elevation.

uses JwaWindows,JwsclElevation, JwsclConstant;

  //const E_USER_CANCELED_OPERATION = HRESULT($800704C7); HRESULT_CODE(E_…) = 1223
  try
    JwShellExecute(0, //const hWnd: HWND;
        ParamStr(0), //FileName,
        //Parameters,
        , //Directory: TJwString;
        0, //ShowCmd: Integer;
        [sefIgnoreElevationIfNotAvailable]);
  except
    on E : EJwsclWinCallFailedException do
    begin
      if E.LastError = HRESULT_CODE(E_USER_CANCELED_OPERATION) then
        //runas canceled
      else
      //error catching here
    end;
  end;