James Hawkins : advpack: Implement the CheckAdminRights option.

Alexandre Julliard julliard at wine.codeweavers.com
Fri May 5 12:11:09 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 4df237312aee12f645795130b253f1dc38f6787e
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=4df237312aee12f645795130b253f1dc38f6787e

Author: James Hawkins <truiken at gmail.com>
Date:   Fri Apr 28 20:08:35 2006 -0500

advpack: Implement the CheckAdminRights option.

---

 dlls/advpack/install.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/dlls/advpack/install.c b/dlls/advpack/install.c
index 25f6205..2901093 100644
--- a/dlls/advpack/install.c
+++ b/dlls/advpack/install.c
@@ -57,6 +57,9 @@ typedef struct _ADVInfo
 typedef HRESULT (*iterate_fields_func)(HINF hinf, PCWSTR field, void *arg);
 
 /* Advanced INF commands */
+static const WCHAR CheckAdminRights[] = {
+    'C','h','e','c','k','A','d','m','i','n','R','i','g','h','t','s',0
+};
 static const WCHAR PerUserInstall[] = {'P','e','r','U','s','e','r','I','n','s','t','a','l','l',0};
 static const WCHAR RegisterOCXs[] = {'R','e','g','i','s','t','e','r','O','C','X','s',0};
 static const WCHAR RunPreSetupCommands[] = {
@@ -254,6 +257,25 @@ static HRESULT iterate_section_fields(HI
     return hr;
 }
 
+static HRESULT check_admin_rights(ADVInfo *info)
+{
+    INT check;
+    INFCONTEXT context;
+    HRESULT hr = S_OK;
+
+    if (!SetupFindFirstLineW(info->hinf, info->install_sec,
+                             CheckAdminRights, &context))
+        return S_OK;
+
+    if (!SetupGetIntField(&context, 1, &check))
+        return S_OK;
+
+    if (check == 1)
+        hr = IsNTAdmin(0, NULL) ? S_OK : E_FAIL;
+
+    return hr;
+}
+
 /* performs a setupapi-level install of the INF file */
 static HRESULT spapi_install(ADVInfo *info)
 {
@@ -294,6 +316,10 @@ static HRESULT adv_install(ADVInfo *info
 {
     HRESULT hr;
 
+    hr = check_admin_rights(info);
+    if (hr != S_OK)
+        return hr;
+
     hr = iterate_section_fields(info->hinf, info->install_sec, RunPreSetupCommands,
                                 run_setup_commands_callback, info);
     if (hr != S_OK)




More information about the wine-cvs mailing list