- implemented RefreshPolicy() and RefreshPolicyEx()
- added missing definitions to userenv.h
Modified: trunk/reactos/lib/userenv/gpolicy.c
Modified: trunk/reactos/lib/userenv/userenv.def
Modified: trunk/reactos/lib/userenv/userenv.xml
Modified: trunk/reactos/w32api/include/userenv.h

Modified: trunk/reactos/lib/userenv/gpolicy.c
--- trunk/reactos/lib/userenv/gpolicy.c	2006-01-12 18:05:35 UTC (rev 20808)
+++ trunk/reactos/lib/userenv/gpolicy.c	2006-01-12 18:50:39 UTC (rev 20809)
@@ -45,8 +45,12 @@
 
 static const WCHAR szLocalGPApplied[] = L"userenv: User Group Policy has been applied";
 static const WCHAR szLocalGPMutex[] = L"userenv: user policy mutex";
+static const WCHAR szLocalGPRefreshEvent[] = L"userenv: user policy refresh event";
+static const WCHAR szLocalGPForceRefreshEvent[] = L"userenv: user policy force refresh event";
 static const WCHAR szMachineGPApplied[] = L"Global\\userenv: Machine Group Policy has been applied";
 static const WCHAR szMachineGPMutex[] = L"Global\\userenv: machine policy mutex";
+static const WCHAR szMachineGPRefreshEvent[] = L"Global\\userenv: machine policy refresh event";
+static const WCHAR szMachineGPForceRefreshEvent[] = L"Global\\userenv: machine policy force refresh event";
 
 static CRITICAL_SECTION GPNotifyLock;
 static PGP_NOTIFY NotificationList = NULL;
@@ -412,6 +416,58 @@
     return Ret;
 }
 
+BOOL WINAPI
+RefreshPolicy(IN BOOL bMachine)
+{
+    HANDLE hEvent;
+    BOOL Ret = TRUE;
+
+    hEvent = OpenEventW(EVENT_MODIFY_STATE,
+                        FALSE,
+                        (bMachine ? szMachineGPRefreshEvent : szLocalGPRefreshEvent));
+    if (hEvent != NULL)
+    {
+        Ret = SetEvent(hEvent);
+        CloseHandle(hEvent);
+    }
+
+    /* return TRUE even if the mutex doesn't exist! */
+    return Ret;
+}
+
+BOOL WINAPI
+RefreshPolicyEx(IN BOOL bMachine,
+                IN DWORD dwOptions)
+{
+    if (dwOptions & ~RP_FORCE)
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+
+    if (dwOptions & RP_FORCE)
+    {
+        HANDLE hEvent;
+        BOOL Ret = TRUE;
+
+        hEvent = OpenEventW(EVENT_MODIFY_STATE,
+                            FALSE,
+                            (bMachine ? szMachineGPForceRefreshEvent : szLocalGPForceRefreshEvent));
+        if (hEvent != NULL)
+        {
+            Ret = SetEvent(hEvent);
+            CloseHandle(hEvent);
+        }
+
+        /* return TRUE even if the mutex doesn't exist! */
+        return Ret;
+    }
+    else
+    {
+        return RefreshPolicy(bMachine);
+    }
+}
+
 HANDLE WINAPI
 EnterCriticalPolicySection(IN BOOL bMachine)
 {

Modified: trunk/reactos/lib/userenv/userenv.def
--- trunk/reactos/lib/userenv/userenv.def	2006-01-12 18:05:35 UTC (rev 20808)
+++ trunk/reactos/lib/userenv/userenv.def	2006-01-12 18:50:39 UTC (rev 20809)
@@ -33,6 +33,8 @@
 LeaveCriticalPolicySection@4
 LoadUserProfileA@8
 LoadUserProfileW@8
+RefreshPolicy@4
+RefreshPolicyEx@8
 RegisterGPNotification@8
 UnloadUserProfile@8
 UnregisterGPNotification@4

Modified: trunk/reactos/lib/userenv/userenv.xml
--- trunk/reactos/lib/userenv/userenv.xml	2006-01-12 18:05:35 UTC (rev 20808)
+++ trunk/reactos/lib/userenv/userenv.xml	2006-01-12 18:50:39 UTC (rev 20809)
@@ -4,6 +4,7 @@
 	<define name="__USE_W32API" />
 	<define name="_WIN32_IE">0x0500</define>
 	<define name="_WIN32_WINNT">0x0600</define>
+	<define name="WINVER">0x0600</define>
 	<library>uuid</library>
 	<library>ntdll</library>
 	<library>kernel32</library>

Modified: trunk/reactos/w32api/include/userenv.h
--- trunk/reactos/w32api/include/userenv.h	2006-01-12 18:05:35 UTC (rev 20808)
+++ trunk/reactos/w32api/include/userenv.h	2006-01-12 18:50:39 UTC (rev 20809)
@@ -12,6 +12,10 @@
 #define PI_NOUI (1)
 #define PI_APPLYPOLICY (2)
 
+#if (WINVER >= 0x0500)
+#define RP_FORCE (1)
+#endif
+
 typedef struct _PROFILEINFOA
 {
   DWORD dwSize;
@@ -70,7 +74,20 @@
 
 BOOL WINAPI CreateEnvironmentBlock(LPVOID*, HANDLE, BOOL);
 BOOL WINAPI DestroyEnvironmentBlock(LPVOID);
+#if (WINVER >= 0x0500)
+BOOL WINAPI ExpandEnvironmentStringsForUserA (HANDLE, LPCSTR, LPSTR, DWORD);
+BOOL WINAPI ExpandEnvironmentStringsForUserW (HANDLE, LPCWSTR, LPWSTR, DWORD);
+#endif
 
+HANDLE WINAPI EnterCriticalPolicySection (BOOL);
+BOOL WINAPI LeaveCriticalPolicySection (HANDLE);
+BOOL WINAPI RefreshPolicy (BOOL);
+#if (WINVER >= 0x0500)
+BOOL WINAPI RefreshPolicyEx (BOOL, DWORD);
+#endif
+BOOL WINAPI RegisterGPNotification (HANDLE, BOOL);
+BOOL WINAPI UnregisterGPNotification (HANDLE);
+
 #ifdef UNICODE
 typedef PROFILEINFOW PROFILEINFO;
 typedef LPPROFILEINFOW LPPROFILEINFO;
@@ -89,6 +106,9 @@
 #define GetDefaultUserProfileDirectory  GetDefaultUserProfileDirectoryW
 #define GetProfilesDirectory  GetProfilesDirectoryW
 #define GetUserProfileDirectory  GetUserProfileDirectoryW
+#if (WINVER >= 0x0500)
+#define ExpandEnvironmentStringsForUser ExpandEnvironmentStringsForUserW
+#endif
 #else
 typedef PROFILEINFOA PROFILEINFO;
 typedef LPPROFILEINFOA LPPROFILEINFO;
@@ -107,7 +127,10 @@
 #define GetDefaultUserProfileDirectory  GetDefaultUserProfileDirectoryA
 #define GetProfilesDirectory  GetProfilesDirectoryA
 #define GetUserProfileDirectory  GetUserProfileDirectoryA
+#if (WINVER >= 0x0500)
+#define ExpandEnvironmentStringsForUser ExpandEnvironmentStringsForUserA
 #endif
+#endif
 
 #ifdef __cplusplus
 }