2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * INCLUDES _________________________________________________________________
17 #include "cpl_interface.h"
19 #include <WINNT/afsreg.h>
20 #include <WINNT/TaLocale.h>
25 * DEFINITIONS _______________________________________________________________
28 #define APP_INSTALL_DIR_REG_KEY AFSREG_SVR_SW_VERSION_KEY
29 #define APP_INSTALL_DIR_REG_VALUE AFSREG_SVR_SW_VERSION_DIR_VALUE
30 #define APP_EXE_PATH "\\usr\\afs\\bin\\afssvrcfg.exe"
35 * VARIABLES _________________________________________________________________
38 static HINSTANCE hinst = 0;
39 static HINSTANCE hinstResources = 0;
44 * STATIC FUNCTIONS ___________________________________________________________
47 static char *LoadResString(UINT uID)
54 static char *GetInstallDir()
59 static char szInstallDir[256];
62 dwSize = sizeof(szInstallDir);
64 nResult = RegOpenKeyAlt(AFSREG_NULL_KEY, APP_INSTALL_DIR_REG_KEY, KEY_READ, FALSE, &hKey, 0);
65 if (nResult == ERROR_SUCCESS) {
66 nResult = RegQueryValueEx(hKey, APP_INSTALL_DIR_REG_VALUE, 0, &dwType, (PBYTE)szInstallDir, &dwSize);
70 if (nResult != ERROR_SUCCESS)
79 * EXPORTED FUNCTIONS _________________________________________________________
82 extern "C" LONG APIENTRY CPlApplet(HWND hwndCPl, UINT uMsg, LONG lParam1, LONG lParam2)
85 LPNEWCPLINFO lpNewCPlInfo;
87 static char szAppName[64];
88 static char szAppPath[MAX_PATH];
94 case CPL_INIT: /* first message, sent once */
95 hinst = GetModuleHandle("afsserver.cpl");
96 hinstResources = TaLocale_LoadCorrespondingModule (hinst);
97 strcpy(szAppName, LoadResString(IDS_APP_NAME));
98 sprintf(szAppPath, "%s%s", GetInstallDir(), APP_EXE_PATH);
101 case CPL_GETCOUNT: /* second message, sent once */
105 case CPL_NEWINQUIRE: /* third message, sent once per app */
106 lpNewCPlInfo = (LPNEWCPLINFO) lParam2;
108 lpNewCPlInfo->dwSize = (DWORD) sizeof(NEWCPLINFO);
109 lpNewCPlInfo->dwFlags = 0;
110 lpNewCPlInfo->dwHelpContext = 0;
111 lpNewCPlInfo->lData = 0;
112 hIcon = TaLocale_LoadIcon(IDI_AFSD);
114 MessageBox(0, LoadResString(IDS_ERROR_LOADING_ICON), szAppName, MB_ICONEXCLAMATION);
115 lpNewCPlInfo->hIcon = hIcon;
116 lpNewCPlInfo->szHelpFile[0] = '\0';
117 strcpy(lpNewCPlInfo->szName, szAppName);
118 strcpy(lpNewCPlInfo->szInfo, LoadResString(IDS_CPA_TITLE));
121 case CPL_SELECT: /* applet icon selected */
124 case CPL_DBLCLK: /* applet icon double-clicked */
125 if (WinExec(szAppPath, SW_SHOW) < 32)
126 MessageBox(0, LoadResString(IDS_EXECUTION_ERROR), szAppName, MB_ICONSTOP);
129 case CPL_STOP: /* sent once per app. before CPL_EXIT */
132 case CPL_EXIT: /* sent once before FreeLibrary called */
134 FreeLibrary (hinstResources);