From b08e7df8831ac2a60ec54393a4bb9a966d99c5f0 Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Sun, 31 Jan 2010 00:11:02 +0000 Subject: [PATCH] LocalIfGLobalFails property for X2UtSingleInstance VistaMan units; like XPMan but with various requested privilege levels --- Packages/D2007/X2Utils.dproj | 18 +++++++--- Resources/VistaManAsInvoker.RES | Bin 0 -> 712 bytes Resources/VistaManAsInvoker.manifest | 24 ++++++++++++++ Resources/VistaManAsInvoker.rc | 1 + Resources/VistaManHighestAvailable.RES | Bin 0 -> 720 bytes Resources/VistaManHighestAvailable.manifest | 24 ++++++++++++++ Resources/VistaManHighestAvailable.rc | 1 + Resources/VistaManRequireAdministrator.RES | Bin 0 -> 724 bytes .../VistaManRequireAdministrator.manifest | 24 ++++++++++++++ Resources/VistaManRequireAdministrator.rc | 1 + VistaManAsInvoker.pas | 11 +++++++ VistaManHighestAvailable.pas | 11 +++++++ VistaManRequireAdministrator.pas | 11 +++++++ X2UtApp.pas | 2 +- X2UtSingleInstance.pas | 31 ++++++++++++++---- 15 files changed, 147 insertions(+), 12 deletions(-) create mode 100644 Resources/VistaManAsInvoker.RES create mode 100644 Resources/VistaManAsInvoker.manifest create mode 100644 Resources/VistaManAsInvoker.rc create mode 100644 Resources/VistaManHighestAvailable.RES create mode 100644 Resources/VistaManHighestAvailable.manifest create mode 100644 Resources/VistaManHighestAvailable.rc create mode 100644 Resources/VistaManRequireAdministrator.RES create mode 100644 Resources/VistaManRequireAdministrator.manifest create mode 100644 Resources/VistaManRequireAdministrator.rc create mode 100644 VistaManAsInvoker.pas create mode 100644 VistaManHighestAvailable.pas create mode 100644 VistaManRequireAdministrator.pas diff --git a/Packages/D2007/X2Utils.dproj b/Packages/D2007/X2Utils.dproj index ef3573e..b87d6d7 100644 --- a/Packages/D2007/X2Utils.dproj +++ b/Packages/D2007/X2Utils.dproj @@ -5,7 +5,7 @@ Debug AnyCPU DCC32 - ..\..\..\..\bin\D2007\X2Utils2007.bpl + ..\..\..\bpl\D2006\X2Utils2007.bpl 7.0 @@ -33,6 +33,16 @@ FalseTrueFalseX2UtilsTrueFalseTrue2007TrueFalse1000FalseFalseFalseFalseFalse104312521.0.0.01.0.0.0X2Utils.dpk + + + + + + + + + + Microsoft Office 2000 Sample Automation Server Wrapper Components Microsoft Office XP Sample Automation Server Wrapper Components @@ -42,12 +52,12 @@ MainSource + + + - - - diff --git a/Resources/VistaManAsInvoker.RES b/Resources/VistaManAsInvoker.RES new file mode 100644 index 0000000000000000000000000000000000000000..00f7d3c28ad05d97ccbf87549094505dac6bcff7 GIT binary patch literal 712 zcma)4O;6)65DkdSR_bXl94#M_nzT?VKnVyTR;qSa+5_yKU1w4({82nkXnw)|Y<3cG zmWm6GEZOsB=FNL?k|YVE{qpj<>A180?nnHPa`t*`ntVNoN%_^*Xx4y76A0D z(v`}t3x0q1ZF0sL24PE~orQw8fc)xmJQ|O3fe2=$TShG`7QFWM0_6i3ffJ*ocj&4x zkchOR&3FzFvVcW9>XIYe%MYX%y@*&>4 z(EAd6jbUjk_eqzJc_cxQwI_4_+vee^CikKI*+O&S@~ k-KpRLm$o4 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Resources/VistaManAsInvoker.rc b/Resources/VistaManAsInvoker.rc new file mode 100644 index 0000000..84e3810 --- /dev/null +++ b/Resources/VistaManAsInvoker.rc @@ -0,0 +1 @@ +1 24 "VistaManAsInvoker.manifest" \ No newline at end of file diff --git a/Resources/VistaManHighestAvailable.RES b/Resources/VistaManHighestAvailable.RES new file mode 100644 index 0000000000000000000000000000000000000000..025b93b02deb271dd128fed1e152dc3ab94266d5 GIT binary patch literal 720 zcma)4J#X7E5LJpUHQ*^rMuKAjOLpQINgyRKf)ogv0v*zJrm2%mlpijSQmjAGznq?w zP>s>06bO*_?(W@tVv-~Yqy7B+vgvrRe!q+O3FRCO*gQFYACvN%z0s@%kILDCFVZ<@ zV5KXStqcC`@zd;rGYrC(LOTlu?*RGD^>i|wn^()USKu~19r-GnD*LQeXq1(}r zPs*O1^6BJ*6^5=~;xOqCWlQ&j>8&%y+1ahL!8?t8>gd5Lo%dfK+cg`lHbvkt*W=wVciO)#YO{;Gw=X9vUN*{F*6^DO?(>m>ODyV2Kv literal 0 HcmV?d00001 diff --git a/Resources/VistaManHighestAvailable.manifest b/Resources/VistaManHighestAvailable.manifest new file mode 100644 index 0000000..83e6304 --- /dev/null +++ b/Resources/VistaManHighestAvailable.manifest @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Resources/VistaManHighestAvailable.rc b/Resources/VistaManHighestAvailable.rc new file mode 100644 index 0000000..cdb56bf --- /dev/null +++ b/Resources/VistaManHighestAvailable.rc @@ -0,0 +1 @@ +1 24 "VistaManHighestAvailable.manifest" \ No newline at end of file diff --git a/Resources/VistaManRequireAdministrator.RES b/Resources/VistaManRequireAdministrator.RES new file mode 100644 index 0000000000000000000000000000000000000000..c41377d4e68533b51f73385abea72c01636854f0 GIT binary patch literal 724 zcma)4!EV$r5Dkb6EA5F3N6SZ~O?Jz6RjQ=bswz?iNE`~Bz0PE7VUHJ&v)%j#KU^kh z9lGLzBTM$YnR)YGoMl-ict1QmZayBZ-!BvXmUCVV*gSjlDkYVd2WQ0|0vV5$T;y{p z0JX0TZY%li_T%hK3W^GAWj#VAJ0N*^F`Y~&r6K~iv7O)+NR?~@o|C=R{ExQl(*I@R>!WL)*+0_xgK5%K|2k{y9U|FLO swm(&}PcZ@3wKHfa1{HmfNfx&##vcDrl*Q3NWicw_8OkF4(u*wn18Nl6a{vGU literal 0 HcmV?d00001 diff --git a/Resources/VistaManRequireAdministrator.manifest b/Resources/VistaManRequireAdministrator.manifest new file mode 100644 index 0000000..cdc0c23 --- /dev/null +++ b/Resources/VistaManRequireAdministrator.manifest @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Resources/VistaManRequireAdministrator.rc b/Resources/VistaManRequireAdministrator.rc new file mode 100644 index 0000000..62394fc --- /dev/null +++ b/Resources/VistaManRequireAdministrator.rc @@ -0,0 +1 @@ +1 24 "VistaManRequireAdministrator.manifest" \ No newline at end of file diff --git a/VistaManAsInvoker.pas b/VistaManAsInvoker.pas new file mode 100644 index 0000000..d6e7e06 --- /dev/null +++ b/VistaManAsInvoker.pas @@ -0,0 +1,11 @@ +unit VistaManAsInvoker; + +{$WEAKPACKAGEUNIT ON} + +interface + +{$R 'Resources\VistaManAsInvoker.RES'} + +implementation +end. + diff --git a/VistaManHighestAvailable.pas b/VistaManHighestAvailable.pas new file mode 100644 index 0000000..8ab89f2 --- /dev/null +++ b/VistaManHighestAvailable.pas @@ -0,0 +1,11 @@ +unit VistaManHighestAvailable; + +{$WEAKPACKAGEUNIT ON} + +interface + +{$R 'Resources\VistaManHighestAvailable.RES'} + +implementation +end. + diff --git a/VistaManRequireAdministrator.pas b/VistaManRequireAdministrator.pas new file mode 100644 index 0000000..ef8b787 --- /dev/null +++ b/VistaManRequireAdministrator.pas @@ -0,0 +1,11 @@ +unit VistaManRequireAdministrator; + +{$WEAKPACKAGEUNIT ON} + +interface + +{$R 'Resources\VistaManRequireAdministrator.RES'} + +implementation +end. + diff --git a/X2UtApp.pas b/X2UtApp.pas index f9a0903..5406bcf 100644 --- a/X2UtApp.pas +++ b/X2UtApp.pas @@ -452,7 +452,7 @@ end; function TX2App.FormatVersion(const ABuild: Boolean = True; const AProductName: Boolean = False): String; begin - Result := FVersion.FormatVersion(ABuild, AProductName); + Result := Version.FormatVersion(ABuild, AProductName); end; diff --git a/X2UtSingleInstance.pas b/X2UtSingleInstance.pas index f363501..c41ee7c 100644 --- a/X2UtSingleInstance.pas +++ b/X2UtSingleInstance.pas @@ -72,11 +72,13 @@ type FFileMapData: PX2InstanceMapData; FFileMapping: THandle; FObservers: TInterfaceList; + FLocalIfGlobalFails: Boolean; protected function GetCount(): Integer; virtual; + procedure SetActive(const Value: Boolean); virtual; procedure SetApplicationID(const Value: String); 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; @@ -104,11 +106,12 @@ type //:$ Unregisters a previously registered instance. procedure Detach(const ANotifier: IX2InstanceObserver); - property Active: Boolean read FActive write SetActive; - property ApplicationID: String read FApplicationID write SetApplicationID; - property FirstInstance: Boolean read FFirstInstance; - property Global: Boolean read FGlobal write SetGlobal; - property Count: Integer read GetCount; + property Active: Boolean read FActive write SetActive; + property ApplicationID: String read FApplicationID write SetApplicationID; + property FirstInstance: Boolean read FFirstInstance; + property Global: Boolean read FGlobal write SetGlobal; + property LocalIfGlobalFails: Boolean read FLocalIfGlobalFails write SetLocalIfGlobalFails; + property Count: Integer read GetCount; end; { @@ -217,6 +220,7 @@ begin inherited; FObservers := TInterfaceList.Create; + FLocalIfGlobalFails := True; end; destructor TX2Instance.Destroy(); @@ -299,7 +303,15 @@ begin PChar(ScopePrefix[Global] + 'SingleInstance.' + ApplicationID)); if FFileMapping = 0 then - RaiseLastOSError(); + begin + if Global and LocalIfGlobalFails then + begin + FGlobal := False; + Open(); + Exit; + end else + RaiseLastOSError(); + end; FActive := True; try @@ -442,6 +454,11 @@ begin end; +procedure TX2Instance.SetLocalIfGlobalFails(const Value: Boolean); +begin + FLocalIfGlobalFails := Value; +end; + // Copied from System unit because Borland didn't make it public function GetParamStr(P: PChar; var Param: String): PChar;