1
0
mirror of synced 2024-12-22 09:13:07 +01:00

LocalIfGLobalFails property for X2UtSingleInstance

VistaMan units; like XPMan but with various requested privilege levels
This commit is contained in:
Mark van Renswoude 2010-01-31 00:11:02 +00:00
parent fcd8d4a46d
commit b08e7df883
15 changed files with 147 additions and 12 deletions

View File

@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<DCC_DCCCompiler>DCC32</DCC_DCCCompiler> <DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
<DCC_DependencyCheckOutputName>..\..\..\..\bin\D2007\X2Utils2007.bpl</DCC_DependencyCheckOutputName> <DCC_DependencyCheckOutputName>..\..\..\bpl\D2006\X2Utils2007.bpl</DCC_DependencyCheckOutputName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Version>7.0</Version> <Version>7.0</Version>
@ -33,6 +33,16 @@
<BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><Package_Options><Package_Options Name="PackageDescription">X2Utils</Package_Options><Package_Options Name="ImplicitBuild">True</Package_Options><Package_Options Name="DesigntimeOnly">False</Package_Options><Package_Options Name="RuntimeOnly">True</Package_Options><Package_Options Name="LibSuffix">2007</Package_Options></Package_Options><VersionInfo><VersionInfo Name="IncludeVerInfo">True</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">1</VersionInfo><VersionInfo Name="MinorVer">0</VersionInfo><VersionInfo Name="Release">0</VersionInfo><VersionInfo Name="Build">0</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">1043</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName"></VersionInfoKeys><VersionInfoKeys Name="FileDescription"></VersionInfoKeys><VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName"></VersionInfoKeys><VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="Comments"></VersionInfoKeys></VersionInfoKeys><Source><Source Name="MainSource">X2Utils.dpk</Source></Source><Excluded_Packages> <BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><Package_Options><Package_Options Name="PackageDescription">X2Utils</Package_Options><Package_Options Name="ImplicitBuild">True</Package_Options><Package_Options Name="DesigntimeOnly">False</Package_Options><Package_Options Name="RuntimeOnly">True</Package_Options><Package_Options Name="LibSuffix">2007</Package_Options></Package_Options><VersionInfo><VersionInfo Name="IncludeVerInfo">True</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">1</VersionInfo><VersionInfo Name="MinorVer">0</VersionInfo><VersionInfo Name="Release">0</VersionInfo><VersionInfo Name="Build">0</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">1043</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName"></VersionInfoKeys><VersionInfoKeys Name="FileDescription"></VersionInfoKeys><VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName"></VersionInfoKeys><VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="Comments"></VersionInfoKeys></VersionInfoKeys><Source><Source Name="MainSource">X2Utils.dpk</Source></Source><Excluded_Packages>
<Excluded_Packages Name="$(BDS)\bin\dcloffice2k100.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages> <Excluded_Packages Name="$(BDS)\bin\dcloffice2k100.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
<Excluded_Packages Name="$(BDS)\bin\dclofficexp100.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages> <Excluded_Packages Name="$(BDS)\bin\dclofficexp100.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
</Excluded_Packages></Delphi.Personality></BorlandProject></BorlandProject> </Excluded_Packages></Delphi.Personality></BorlandProject></BorlandProject>
@ -42,12 +52,12 @@
<DelphiCompile Include="X2Utils.dpk"> <DelphiCompile Include="X2Utils.dpk">
<MainSource>MainSource</MainSource> <MainSource>MainSource</MainSource>
</DelphiCompile> </DelphiCompile>
<DCCReference Include="$(SystemRoot)\system32\rtl.dcp" />
<DCCReference Include="$(SystemRoot)\system32\vcl.dcp" />
<DCCReference Include="$(SystemRoot)\system32\vclx.dcp" />
<DCCReference Include="$(SystemRoot)\system32\VirtualTreesD207.dcp" /> <DCCReference Include="$(SystemRoot)\system32\VirtualTreesD207.dcp" />
<DCCReference Include="$(SystemRoot)\system32\VirtualTreesD27.dcp" /> <DCCReference Include="$(SystemRoot)\system32\VirtualTreesD27.dcp" />
<DCCReference Include="$(SystemRoot)\system32\VirtualTreesD7.dcp" /> <DCCReference Include="$(SystemRoot)\system32\VirtualTreesD7.dcp" />
<DCCReference Include="..\..\..\..\rtl.dcp" />
<DCCReference Include="..\..\..\..\vcl.dcp" />
<DCCReference Include="..\..\..\..\vclx.dcp" />
<DCCReference Include="..\..\X2UtApp.pas" /> <DCCReference Include="..\..\X2UtApp.pas" />
<DCCReference Include="..\..\X2UtBits.pas" /> <DCCReference Include="..\..\X2UtBits.pas" />
<DCCReference Include="..\..\X2UtGraphics.pas" /> <DCCReference Include="..\..\X2UtGraphics.pas" />

Binary file not shown.

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="x86" />
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="asInvoker"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View File

@ -0,0 +1 @@
1 24 "VistaManAsInvoker.manifest"

Binary file not shown.

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="x86" />
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="highestAvailable"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View File

@ -0,0 +1 @@
1 24 "VistaManHighestAvailable.manifest"

Binary file not shown.

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="x86" />
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="requireAdministrator"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View File

@ -0,0 +1 @@
1 24 "VistaManRequireAdministrator.manifest"

11
VistaManAsInvoker.pas Normal file
View File

@ -0,0 +1,11 @@
unit VistaManAsInvoker;
{$WEAKPACKAGEUNIT ON}
interface
{$R 'Resources\VistaManAsInvoker.RES'}
implementation
end.

View File

@ -0,0 +1,11 @@
unit VistaManHighestAvailable;
{$WEAKPACKAGEUNIT ON}
interface
{$R 'Resources\VistaManHighestAvailable.RES'}
implementation
end.

View File

@ -0,0 +1,11 @@
unit VistaManRequireAdministrator;
{$WEAKPACKAGEUNIT ON}
interface
{$R 'Resources\VistaManRequireAdministrator.RES'}
implementation
end.

View File

@ -452,7 +452,7 @@ end;
function TX2App.FormatVersion(const ABuild: Boolean = True; function TX2App.FormatVersion(const ABuild: Boolean = True;
const AProductName: Boolean = False): String; const AProductName: Boolean = False): String;
begin begin
Result := FVersion.FormatVersion(ABuild, AProductName); Result := Version.FormatVersion(ABuild, AProductName);
end; end;

View File

@ -72,11 +72,13 @@ type
FFileMapData: PX2InstanceMapData; FFileMapData: PX2InstanceMapData;
FFileMapping: THandle; FFileMapping: THandle;
FObservers: TInterfaceList; FObservers: TInterfaceList;
FLocalIfGlobalFails: Boolean;
protected protected
function GetCount(): Integer; virtual; function GetCount(): Integer; virtual;
procedure SetActive(const Value: Boolean); virtual;
procedure SetApplicationID(const Value: String); virtual; procedure SetApplicationID(const Value: String); virtual;
procedure SetGlobal(const Value: Boolean); virtual; procedure SetGlobal(const Value: Boolean); virtual;
procedure SetActive(const Value: Boolean); virtual; procedure SetLocalIfGlobalFails(const Value: Boolean); virtual;
procedure WindowProc(var Message: TMessage); virtual; procedure WindowProc(var Message: TMessage); virtual;
@ -108,6 +110,7 @@ type
property ApplicationID: String read FApplicationID write SetApplicationID; property ApplicationID: String read FApplicationID write SetApplicationID;
property FirstInstance: Boolean read FFirstInstance; property FirstInstance: Boolean read FFirstInstance;
property Global: Boolean read FGlobal write SetGlobal; property Global: Boolean read FGlobal write SetGlobal;
property LocalIfGlobalFails: Boolean read FLocalIfGlobalFails write SetLocalIfGlobalFails;
property Count: Integer read GetCount; property Count: Integer read GetCount;
end; end;
@ -217,6 +220,7 @@ begin
inherited; inherited;
FObservers := TInterfaceList.Create; FObservers := TInterfaceList.Create;
FLocalIfGlobalFails := True;
end; end;
destructor TX2Instance.Destroy(); destructor TX2Instance.Destroy();
@ -299,7 +303,15 @@ begin
PChar(ScopePrefix[Global] + PChar(ScopePrefix[Global] +
'SingleInstance.' + ApplicationID)); 'SingleInstance.' + ApplicationID));
if FFileMapping = 0 then if FFileMapping = 0 then
begin
if Global and LocalIfGlobalFails then
begin
FGlobal := False;
Open();
Exit;
end else
RaiseLastOSError(); RaiseLastOSError();
end;
FActive := True; FActive := True;
try try
@ -442,6 +454,11 @@ begin
end; end;
procedure TX2Instance.SetLocalIfGlobalFails(const Value: Boolean);
begin
FLocalIfGlobalFails := Value;
end;
// Copied from System unit because Borland didn't make it public // Copied from System unit because Borland didn't make it public
function GetParamStr(P: PChar; var Param: String): PChar; function GetParamStr(P: PChar; var Param: String): PChar;