csc.c
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 1k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. #include "stdafx.h"
  2. #include "systray.h"
  3. #include <cscuiext.h>
  4. ///////////////////////////////////////////////////////////////////////////////
  5. // CSC_CheckEnable
  6. typedef BOOL (WINAPI* PFNCSCMSGPROCESS)(LPMSG);
  7. static HWND g_hWndCSC = NULL;
  8. static HMODULE g_hCSCUIDll = NULL;
  9. static PFNCSCMSGPROCESS g_pfnMsgProcess = NULL;
  10. BOOL CSC_CheckEnable(HWND hWnd, BOOL bSvcEnabled)
  11. {
  12.     if ((g_hWndCSC && IsWindow(g_hWndCSC) && !bSvcEnabled) ||
  13.         (((!g_hWndCSC) || !IsWindow(g_hWndCSC)) && bSvcEnabled))
  14.     
  15.     {
  16.         if (!g_hCSCUIDll)
  17.             g_hCSCUIDll = LoadLibrary(TEXT("cscui.dll"));
  18.             
  19.         if (g_hCSCUIDll)
  20.         {
  21.             PFNCSCUIINITIALIZE pfn = (PFNCSCUIINITIALIZE)GetProcAddress(g_hCSCUIDll, "CSCUIInitialize");
  22.             g_pfnMsgProcess = (PFNCSCMSGPROCESS)GetProcAddress(g_hCSCUIDll, "CSCUIMsgProcess");
  23.             if (pfn)
  24.             {
  25.                 DWORD dwFlags = CI_INITIALIZE | CI_CREATEWINDOW;
  26.                 if (!bSvcEnabled)
  27.                     dwFlags = CI_TERMINATE | CI_DESTROYWINDOW;
  28.                     
  29.                 g_hWndCSC = (*pfn)(NULL, dwFlags);
  30.             }    
  31.         }
  32.         if (g_hCSCUIDll && !bSvcEnabled)
  33.         {
  34.             FreeLibrary(g_hCSCUIDll);
  35.             g_hCSCUIDll = NULL;
  36.             g_pfnMsgProcess = NULL;
  37.         }
  38.     }        
  39.     return(TRUE);
  40. }
  41. BOOL CSC_MsgProcess(LPMSG pMsg)
  42. {
  43.     if (g_pfnMsgProcess)
  44.         return (*g_pfnMsgProcess)(pMsg);
  45.     return FALSE;
  46. }