// CAfsShlExt
BEGIN_MESSAGE_MAP(CAfsShlExt, CWinApp)
- //{{AFX_MSG_MAP(CAfsShlExt)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- // DO NOT EDIT what you see in these blocks of generated code!
- //}}AFX_MSG_MAP
+ //{{AFX_MSG_MAP(CAfsShlExt)
+ // NOTE - the ClassWizard will add and remove mapping macros here.
+ // DO NOT EDIT what you see in these blocks of generated code!
+ //}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
CAfsShlExt::CAfsShlExt()
{
- /* Start up sockets */
- WSADATA WSAjunk;
- WSAStartup(0x0101, &WSAjunk);
+ /* Start up sockets */
+ WSADATA WSAjunk;
+ WSAStartup(0x0101, &WSAjunk);
}
/////////////////////////////////////////////////////////////////////////////
BOOL CAfsShlExt::InitInstance()
{
- // Load our translated resources
- TaLocale_LoadCorrespondingModuleByName (m_hInstance, TEXT("afs_shl_ext.dll"));
+ // Load our translated resources
+ TaLocale_LoadCorrespondingModuleByName (m_hInstance, TEXT("afs_shl_ext.dll"));
- // Register all OLE server (factories) as running. This enables the
- // OLE libraries to create objects from other applications.
- COleObjectFactory::RegisterAll();
+ // Register all OLE server (factories) as running. This enables the
+ // OLE libraries to create objects from other applications.
+ COleObjectFactory::RegisterAll();
- SetHelpPath(m_pszHelpFilePath);
+ SetHelpPath(m_pszHelpFilePath);
- return TRUE;
+ return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- return AfxDllGetClassObject(rclsid, riid, ppv);
-}
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ return AfxDllGetClassObject(rclsid, riid, ppv);
+}
STDAPI DllCanUnloadNow(void)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
#ifdef COMMENT
// This test is correct and we really do want to allow the extension to be loaded and
// until someone has time to figure out how to debug this.
// Jeffrey Altman - 2 Oct 2005
- if (!nCMRefCount && !nSERefCount && !nICRefCount && !nTPRefCount && !nXPRefCount)
- return S_OK;
+ if (!nCMRefCount && !nSERefCount && !nICRefCount && !nTPRefCount && !nXPRefCount)
+ return S_OK;
#endif
- return S_FALSE;
+ return S_FALSE;
}
int WideCharToLocal(LPTSTR pLocal, LPCWSTR pWide, DWORD dwChars)
{
- *pLocal = 0;
- WideCharToMultiByte( CP_ACP, 0, pWide, -1, pLocal, dwChars, NULL, NULL);
- return lstrlen(pLocal);
+ *pLocal = 0;
+ WideCharToMultiByte( CP_ACP, 0, pWide, -1, pLocal, dwChars, NULL, NULL);
+ return lstrlen(pLocal);
}
LRESULT DoRegCLSID(HKEY hKey,PTCHAR szSubKey,PTCHAR szData,PTCHAR szValue=NULL)
{
- DWORD dwDisp;
- LRESULT lResult;
- HKEY thKey;
- lResult = RegCreateKeyEx(hKey, szSubKey, 0, NULL,
- REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
- &thKey, &dwDisp);
- if(NOERROR == lResult)
- {
- lResult = RegSetValueEx(thKey, szValue, 0, REG_SZ,
- (LPBYTE)szData, (lstrlen(szData) + 1)
- * sizeof(TCHAR));
- RegCloseKey(thKey);
- }
- RegCloseKey(hKey);
- return lResult;
+ DWORD dwDisp;
+ LRESULT lResult;
+ HKEY thKey;
+ lResult = RegCreateKeyEx(hKey, szSubKey, 0, NULL,
+ REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
+ &thKey, &dwDisp);
+ if(NOERROR == lResult)
+ {
+ lResult = RegSetValueEx(thKey, szValue, 0, REG_SZ,
+ (LPBYTE)szData, (lstrlen(szData) + 1)
+ * sizeof(TCHAR));
+ RegCloseKey(thKey);
+ }
+ RegCloseKey(hKey);
+ return lResult;
}
// by exporting DllRegisterServer, you can use regsvr.exe
STDAPI DllRegisterServer(void)
{
- HKEY hKey;
- LRESULT lResult;
- DWORD dwDisp;
- TCHAR szSubKey[MAX_PATH];
- TCHAR szCLSID[MAX_PATH];
+ HKEY hKey;
+ LRESULT lResult;
+ DWORD dwDisp;
+ TCHAR szSubKey[MAX_PATH];
+ TCHAR szCLSID[MAX_PATH];
TCHAR szModule[MAX_PATH];
LPWSTR pwsz;
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- COleObjectFactory::UpdateRegistryAll();
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ COleObjectFactory::UpdateRegistryAll();
- StringFromIID(IID_IShellExt, &pwsz);
- if(pwsz)
+ StringFromIID(IID_IShellExt, &pwsz);
+ if(pwsz)
+ {
+ WideCharToMultiByte( CP_ACP, 0,pwsz, -1, szCLSID, sizeof(szCLSID), NULL, NULL);
+ LPMALLOC pMalloc;
+ CoGetMalloc(1, &pMalloc);
+ if(pMalloc)
{
- WideCharToMultiByte( CP_ACP, 0,pwsz, -1, szCLSID, sizeof(szCLSID), NULL, NULL);
- LPMALLOC pMalloc;
- CoGetMalloc(1, &pMalloc);
- if(pMalloc)
- {
- (pMalloc->Free)(pwsz);
- (pMalloc->Release)();
- }
- } else {
- return E_FAIL;
+ (pMalloc->Free)(pwsz);
+ (pMalloc->Release)();
}
+ } else {
+ return E_FAIL;
+ }
/*
[HKEY_CLASSES_ROOT\CLSID\{$CLSID}\InprocServer32]
"ThreadingModel"="Apartment"
*/
HMODULE hModule=GetModuleHandle("afs_shl_ext.dll");
- DWORD z=GetModuleFileName(hModule,szModule,sizeof(szModule));
- wsprintf(szSubKey, TEXT("CLSID\\%s\\InprocServer32"),szCLSID);
- if ((lResult=DoRegCLSID(HKEY_CLASSES_ROOT,szSubKey,szModule))!=NOERROR)
- return lResult;
+ DWORD z=GetModuleFileName(hModule,szModule,sizeof(szModule));
+ wsprintf(szSubKey, TEXT("CLSID\\%s\\InprocServer32"),szCLSID);
+ if ((lResult=DoRegCLSID(HKEY_CLASSES_ROOT,szSubKey,szModule))!=NOERROR)
+ return lResult;
- wsprintf(szSubKey, TEXT("CLSID\\%s\\InprocServer32"),szCLSID);
- if ((lResult=DoRegCLSID(HKEY_CLASSES_ROOT,szSubKey,"Apartment","ThreadingModel"))!=NOERROR)
- return lResult;
+ wsprintf(szSubKey, TEXT("CLSID\\%s\\InprocServer32"),szCLSID);
+ if ((lResult=DoRegCLSID(HKEY_CLASSES_ROOT,szSubKey,"Apartment","ThreadingModel"))!=NOERROR)
+ return lResult;
/*
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers\AFS Client Shell Extension]
@="{EA3775F2-28BE-11D3-9C8D-00105A24ED29}"
*/
- wsprintf(szSubKey, TEXT("%s\\%s"), STR_REG_PATH, STR_EXT_TITLE);
- if ((lResult=DoRegCLSID(HKEY_LOCAL_MACHINE,szSubKey,szCLSID))!=NOERROR)
- return lResult;
+ wsprintf(szSubKey, TEXT("%s\\%s"), STR_REG_PATH, STR_EXT_TITLE);
+ if ((lResult=DoRegCLSID(HKEY_LOCAL_MACHINE,szSubKey,szCLSID))!=NOERROR)
+ return lResult;
- //If running on NT, register the extension as approved.
+ //If running on NT, register the extension as approved.
/*
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved]
"{$(CLSID)}"="AFS Client Shell Extension"
@="{$(CLSID)}"
*/
- wsprintf(szSubKey, TEXT("Folder\\shellex\\{00021500-0000-0000-C000-000000000046}"));
- if ((lResult=DoRegCLSID(HKEY_CLASSES_ROOT,szSubKey,szCLSID))!=NOERROR)
- return lResult;
+ wsprintf(szSubKey, TEXT("Folder\\shellex\\{00021500-0000-0000-C000-000000000046}"));
+ if ((lResult=DoRegCLSID(HKEY_CLASSES_ROOT,szSubKey,szCLSID))!=NOERROR)
+ return lResult;
- /* Below needs to be merged with above */
-
+ /* Below needs to be merged with above */
wsprintf(szSubKey, TEXT("%s\\%s"), STR_REG_PATH, STR_EXT_TITLE);
- lResult = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
- szSubKey,
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- KEY_WRITE,
- NULL,
- &hKey,
- &dwDisp);
-
- if(NOERROR == lResult)
- {
+ lResult = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
+ szSubKey,
+ 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+ KEY_WRITE,
+ NULL,
+ &hKey,
+ &dwDisp);
+
+ if(NOERROR == lResult)
+ {
//Create the value string.
- lResult = RegSetValueEx( hKey,
- NULL,
- 0,
- REG_SZ,
- (LPBYTE)szCLSID,
- (lstrlen(szCLSID) + 1) * sizeof(TCHAR));
- RegCloseKey(hKey);
- }
- else
- return SELFREG_E_CLASS;
+ lResult = RegSetValueEx( hKey,
+ NULL,
+ 0,
+ REG_SZ,
+ (LPBYTE)szCLSID,
+ (lstrlen(szCLSID) + 1) * sizeof(TCHAR));
+ RegCloseKey(hKey);
+ }
+ else
+ return SELFREG_E_CLASS;
+
+ //If running on NT, register the extension as approved.
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ GetVersionEx(&osvi);
+ if(VER_PLATFORM_WIN32_NT == osvi.dwPlatformId)
+ {
+ lstrcpy( szSubKey, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"));
+
+ lResult = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
+ szSubKey,
+ 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+ KEY_WRITE,
+ NULL,
+ &hKey,
+ &dwDisp);
- //If running on NT, register the extension as approved.
- osvi.dwOSVersionInfoSize = sizeof(osvi);
- GetVersionEx(&osvi);
- if(VER_PLATFORM_WIN32_NT == osvi.dwPlatformId)
+ if(NOERROR == lResult)
{
- lstrcpy( szSubKey, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"));
-
- lResult = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
- szSubKey,
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- KEY_WRITE,
- NULL,
- &hKey,
- &dwDisp);
-
- if(NOERROR == lResult)
- {
- TCHAR szData[MAX_PATH];
-
- //Create the value string.
- lstrcpy(szData, STR_EXT_TITLE);
-
- lResult = RegSetValueEx( hKey,
- szCLSID,
- 0,
- REG_SZ,
- (LPBYTE)szData,
- (lstrlen(szData) + 1) * sizeof(TCHAR));
-
- RegCloseKey(hKey);
- } else
- return SELFREG_E_CLASS;
- }
- return S_OK;
+ TCHAR szData[MAX_PATH];
+
+ //Create the value string.
+ lstrcpy(szData, STR_EXT_TITLE);
+
+ lResult = RegSetValueEx( hKey,
+ szCLSID,
+ 0,
+ REG_SZ,
+ (LPBYTE)szData,
+ (lstrlen(szData) + 1) * sizeof(TCHAR));
+
+ RegCloseKey(hKey);
+ } else
+ return SELFREG_E_CLASS;
+ }
+ return S_OK;
}
//returnValue = RegOpenKeyEx (HKEY_CLASSES_ROOT, keyName, 0, KEY_ALL_ACCESS, ®istryKey);
LRESULT DoValueDelete(HKEY hKey,PTCHAR pszSubKey,PTCHAR szValue=NULL)
{
- LRESULT lResult;
- HKEY thKey;
- if (szValue==NULL) {
- lResult=RegDeleteKey(hKey, pszSubKey);
- return lResult;
- }
- lResult = RegOpenKeyEx( hKey,
- pszSubKey,
- 0,
- KEY_ALL_ACCESS,
- &thKey);
- if(NOERROR == lResult)
- {
- lResult=RegDeleteValue(hKey, szValue);
- RegCloseKey(thKey);
- }
+ LRESULT lResult;
+ HKEY thKey;
+ if (szValue==NULL) {
+ lResult=RegDeleteKey(hKey, pszSubKey);
return lResult;
+ }
+ lResult = RegOpenKeyEx( hKey,
+ pszSubKey,
+ 0,
+ KEY_ALL_ACCESS,
+ &thKey);
+ if(NOERROR == lResult)
+ {
+ lResult=RegDeleteValue(hKey, szValue);
+ RegCloseKey(thKey);
+ }
+ return lResult;
}
STDAPI DllUnregisterServer(void)
{
- TCHAR szSubKey[MAX_PATH];
- TCHAR szCLSID[MAX_PATH];
- LPWSTR pwsz;
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- COleObjectFactory::UpdateRegistryAll(FALSE);
- StringFromIID(IID_IShellExt, &pwsz);
- if(pwsz)
+ TCHAR szSubKey[MAX_PATH];
+ TCHAR szCLSID[MAX_PATH];
+ LPWSTR pwsz;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ COleObjectFactory::UpdateRegistryAll(FALSE);
+ StringFromIID(IID_IShellExt, &pwsz);
+ if(pwsz)
+ {
+ WideCharToMultiByte( CP_ACP, 0,pwsz, -1, szCLSID, sizeof(szCLSID), NULL, NULL);
+ LPMALLOC pMalloc;
+ CoGetMalloc(1, &pMalloc);
+ if(pMalloc)
{
- WideCharToMultiByte( CP_ACP, 0,pwsz, -1, szCLSID, sizeof(szCLSID), NULL, NULL);
- LPMALLOC pMalloc;
- CoGetMalloc(1, &pMalloc);
- if(pMalloc)
- {
- (pMalloc->Free)(pwsz);
- (pMalloc->Release)();
- }
- } else {
- return E_FAIL;
+ (pMalloc->Free)(pwsz);
+ (pMalloc->Release)();
}
- wsprintf(szSubKey, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"));
- DoValueDelete(HKEY_LOCAL_MACHINE,szSubKey,szCLSID);
- wsprintf(szSubKey, TEXT("*\\shellex\\ContextMenuHandlers\\%s"),STR_EXT_TITLE);
- DoValueDelete(HKEY_CLASSES_ROOT, szSubKey);
- wsprintf(szSubKey, TEXT("Folder\\shellex\\{00021500-0000-0000-C000-000000000046}"));
- DoValueDelete(HKEY_CLASSES_ROOT, szSubKey);
- wsprintf(szSubKey, TEXT("Folder\\shellex\\ContextMenuHandlers\\%s"),STR_EXT_TITLE);
- DoValueDelete(HKEY_CLASSES_ROOT, szSubKey);
- wsprintf(szSubKey, TEXT("%s\\%s"), STR_REG_PATH, STR_EXT_TITLE);
- DoValueDelete(HKEY_LOCAL_MACHINE, szSubKey);
- return S_OK;
-}
+ } else {
+ return E_FAIL;
+ }
+ wsprintf(szSubKey, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"));
+ DoValueDelete(HKEY_LOCAL_MACHINE,szSubKey,szCLSID);
+ wsprintf(szSubKey, TEXT("*\\shellex\\ContextMenuHandlers\\%s"),STR_EXT_TITLE);
+ DoValueDelete(HKEY_CLASSES_ROOT, szSubKey);
+ wsprintf(szSubKey, TEXT("Folder\\shellex\\{00021500-0000-0000-C000-000000000046}"));
+ DoValueDelete(HKEY_CLASSES_ROOT, szSubKey);
+ wsprintf(szSubKey, TEXT("Folder\\shellex\\ContextMenuHandlers\\%s"),STR_EXT_TITLE);
+ DoValueDelete(HKEY_CLASSES_ROOT, szSubKey);
+ wsprintf(szSubKey, TEXT("%s\\%s"), STR_REG_PATH, STR_EXT_TITLE);
+ DoValueDelete(HKEY_LOCAL_MACHINE, szSubKey);
+ return S_OK;
+}
/*
- ShowMessageBox:
-
- This function takes three main arguements, the stringtable ID, the button types
- to be displayed (default = MB_OK) and the help table reference (default = 0, no
- help) and then a variable amount of arguements. The variable list does not need
- a special ending flag/character/number. The list is read only as needed, which
- is defined by the string table and the presence of any "%X" characters, where X
- is one of the printf format types. The order of the variable list MUST
- correspond to the order of types in the string table entry. If the string table
- calls for INT INT UINT CHAR* DOUBLE, then the arguement list had better be INT
- INT UINT CHAR* DOUBLE or else there will be serious problems (stack will be
- misread, general protection faults, garbage output, and other errors).
-
- This function takes the arguements passed in the list and inserts them by
- parsing and pszcut/pszpaste the string table entry to add all the arguements passed
- in. This allows for any generic message to be created.
-
- %i,d = Integer
- %u = unsigned int
- %x,X = Hex (takes an integer arguement, pszconverts it)
- %g,f,e = Double
- %s = String (char*)
- %l
- d = Long int
- x = long hex
- %c = character (one)
- %a = String Table Ref. (UINT)
- %o = CString object (prints the string of the object)
- default = prints out string so far, with error message attached at place of error.
-
- Return type is the button pressed in the message box.
+ ShowMessageBox:
+
+ This function takes three main arguements, the stringtable ID, the button types
+ to be displayed (default = MB_OK) and the help table reference (default = 0, no
+ help) and then a variable amount of arguements. The variable list does not need
+ a special ending flag/character/number. The list is read only as needed, which
+ is defined by the string table and the presence of any "%X" characters, where X
+ is one of the printf format types. The order of the variable list MUST
+ correspond to the order of types in the string table entry. If the string table
+ calls for INT INT UINT CHAR* DOUBLE, then the arguement list had better be INT
+ INT UINT CHAR* DOUBLE or else there will be serious problems (stack will be
+ misread, general protection faults, garbage output, and other errors).
+
+ This function takes the arguements passed in the list and inserts them by
+ parsing and pszcut/pszpaste the string table entry to add all the arguements passed
+ in. This allows for any generic message to be created.
+
+ %i,d = Integer
+ %u = unsigned int
+ %x,X = Hex (takes an integer arguement, pszconverts it)
+ %g,f,e = Double
+ %s = String (char*)
+ %l
+ d = Long int
+ x = long hex
+ %c = character (one)
+ %a = String Table Ref. (UINT)
+ %o = CString object (prints the string of the object)
+ default = prints out string so far, with error message attached at place of error.
+
+ Return type is the button pressed in the message box.
*/
UINT ShowMessageBox (UINT Id, UINT Button, UINT Help, ...) {
- CString
- temp;
- char *pszstring,
- *pszpaste,
- *pszcut,
- *pszdone,
- *pszconvert;
- char
- chread;
- va_list
- params;
- int
- x;
-
- pszconvert = new char[255];
- va_start(params, Help);
- LoadString (temp, Id);
- pszstring = temp.GetBuffer(512);
- strcpy(pszstring,pszstring);
- temp.ReleaseBuffer();
- // Look and see - is there a need to insert chars (95% of the time, there won't)
- if (!strstr(pszstring, "%")) {
- delete pszconvert;
- return AfxMessageBox(pszstring, Button, Help);
- }
-
- x = strcspn(pszstring, "%");
- pszdone = new char[512];
- pszcut = new char[512];
- pszpaste = new char[512];
- strcpy(pszcut, &pszstring[x+2]);
- strncpy(pszpaste, pszstring, x);
- pszpaste[x] = '\0';
- chread = pszstring[x+1];
-
- for ( ; ; ) {
-
- switch (chread) {
- case 'i' :
- case 'd' :
- {
- int anint = va_arg(params, int);
- _itoa( anint, pszconvert, 10);
- break;
- }
- case 'u' :
- {
- UINT anuint = va_arg(params, UINT);
- _itoa( anuint, pszconvert, 10);
- break;
- }
-
- case 'x' :
- case 'X' :
- {
- int ahex = va_arg(params, int);
- _itoa( ahex, pszconvert, 16);
- break;
- }
- case 'g' :
- case 'f' :
- case 'e' :
- {
- double adbl = va_arg(params, double);
- _gcvt( adbl, 10, pszconvert);
- break;
- }
- case 's' :
- {
- char *pStr = va_arg(params, char*);
- ASSERT(strlen(pStr) <= 255);
- strcpy(pszconvert, pStr);
- break;
- }
- case 'l' :
- {
- chread = pszdone[x+2];
- switch(chread) {
- case 'x' :
- {
- long int alhex = va_arg(params, long int);
- _ltoa(alhex, pszconvert, 16);
- strcpy(pszcut, &pszcut[1]);
- break;
- }
- case 'd' :
- default :
- {
- long int along = va_arg(params, long int);
- _ltoa( along, pszconvert, 10);
- // For the L, there will be one character after it,
- // so move ahead another letter
- strcpy(pszcut, &pszcut[1]);
- break;
- }
- }
- break;
- }
-
- case 'c' :
- {
- int letter = va_arg(params, int);
- pszconvert[0] = (char)letter;
- pszconvert[1] = '\0';
- break;
- }
- case 'a' :
- {
- CString zeta;
- char* lsc;
- UINT ls = va_arg(params, UINT);
- LoadString (zeta, ls);
- lsc = zeta.GetBuffer(255);
- strcpy(pszconvert, lsc);
- zeta.ReleaseBuffer();
- break;
- }
- case 'o' :
- {
- CString get = va_arg(params, CString);
- char* ex = get.GetBuffer(255);
- strcpy(pszconvert,ex);
- get.ReleaseBuffer();
- break;
- }
- default :
- {
- strcpy(pszconvert, " Could not load message. Invalid %type in string table entry. ");
- delete pszdone;
- pszdone = new char[strlen(pszpaste)+strlen(pszcut)+strlen(pszconvert)+5];
- strcpy(pszdone, pszpaste);
- strcat(pszdone, pszconvert);
- strcat(pszdone, pszcut);
- AfxMessageBox(pszdone, Button, Help);
- delete pszcut;
- delete pszpaste;
- delete pszconvert;
- delete pszdone;
- ASSERT(FALSE);
- return 0;
- }
- } // case
-
- delete pszdone;
- pszdone = new char[strlen(pszpaste)+strlen(pszcut)+strlen(pszconvert)+5];
- strcpy(pszdone, pszpaste);
- strcat(pszdone, pszconvert);
- strcat(pszdone, pszcut);
- // Now pszdone holds the entire message.
- // Check to see if there are more insertions to be made or not
+ CString temp;
+ char *pszstring,
+ *pszpaste,
+ *pszcut,
+ *pszdone,
+ *pszconvert;
+ char chread;
+ va_list params;
+ int x;
+
+ pszconvert = new char[255];
+ va_start(params, Help);
+ LoadString (temp, Id);
+ pszstring = temp.GetBuffer(512);
+ strcpy(pszstring,pszstring);
+ temp.ReleaseBuffer();
+ // Look and see - is there a need to insert chars (95% of the time, there won't)
+ if (!strstr(pszstring, "%")) {
+ delete pszconvert;
+ return AfxMessageBox(pszstring, Button, Help);
+ }
+
+ x = strcspn(pszstring, "%");
+ pszdone = new char[512];
+ pszcut = new char[512];
+ pszpaste = new char[512];
+ strcpy(pszcut, &pszstring[x+2]);
+ strncpy(pszpaste, pszstring, x);
+ pszpaste[x] = '\0';
+ chread = pszstring[x+1];
+
+ for ( ; ; ) {
+
+ switch (chread) {
+ case 'i' :
+ case 'd' :
+ {
+ int anint = va_arg(params, int);
+ _itoa( anint, pszconvert, 10);
+ break;
+ }
+ case 'u' :
+ {
+ UINT anuint = va_arg(params, UINT);
+ _itoa( anuint, pszconvert, 10);
+ break;
+ }
+
+ case 'x' :
+ case 'X' :
+ {
+ int ahex = va_arg(params, int);
+ _itoa( ahex, pszconvert, 16);
+ break;
+ }
+ case 'g' :
+ case 'f' :
+ case 'e' :
+ {
+ double adbl = va_arg(params, double);
+ _gcvt( adbl, 10, pszconvert);
+ break;
+ }
+ case 's' :
+ {
+ char *pStr = va_arg(params, char*);
+ ASSERT(strlen(pStr) <= 255);
+ strcpy(pszconvert, pStr);
+ break;
+ }
+ case 'l' :
+ {
+ chread = pszdone[x+2];
+ switch(chread) {
+ case 'x' :
+ {
+ long int alhex = va_arg(params, long int);
+ _ltoa(alhex, pszconvert, 16);
+ strcpy(pszcut, &pszcut[1]);
+ break;
+ }
+ case 'd' :
+ default :
+ {
+ long int along = va_arg(params, long int);
+ _ltoa( along, pszconvert, 10);
+ // For the L, there will be one character after it,
+ // so move ahead another letter
+ strcpy(pszcut, &pszcut[1]);
+ break;
+ }
+ }
+ break;
+ }
+
+ case 'c' :
+ {
+ int letter = va_arg(params, int);
+ pszconvert[0] = (char)letter;
+ pszconvert[1] = '\0';
+ break;
+ }
+ case 'a' :
+ {
+ CString zeta;
+ char* lsc;
+ UINT ls = va_arg(params, UINT);
+ LoadString (zeta, ls);
+ lsc = zeta.GetBuffer(255);
+ strcpy(pszconvert, lsc);
+ zeta.ReleaseBuffer();
+ break;
+ }
+ case 'o' :
+ {
+ CString get = va_arg(params, CString);
+ char* ex = get.GetBuffer(255);
+ strcpy(pszconvert,ex);
+ get.ReleaseBuffer();
+ break;
+ }
+ default :
+ {
+ strcpy(pszconvert, " Could not load message. Invalid %type in string table entry. ");
+ delete pszdone;
+ pszdone = new char[strlen(pszpaste)+strlen(pszcut)+strlen(pszconvert)+5];
+ strcpy(pszdone, pszpaste);
+ strcat(pszdone, pszconvert);
+ strcat(pszdone, pszcut);
+ AfxMessageBox(pszdone, Button, Help);
+ delete pszcut;
+ delete pszpaste;
+ delete pszconvert;
+ delete pszdone;
+ ASSERT(FALSE);
+ return 0;
+ }
+ } // case
+
+ delete pszdone;
+ pszdone = new char[strlen(pszpaste)+strlen(pszcut)+strlen(pszconvert)+5];
+ strcpy(pszdone, pszpaste);
+ strcat(pszdone, pszconvert);
+ strcat(pszdone, pszcut);
+ // Now pszdone holds the entire message.
+ // Check to see if there are more insertions to be made or not
- if (!strstr(pszdone, "%")) {
- UINT rt_type = AfxMessageBox(pszdone, Button, Help);
- delete pszcut;
- delete pszpaste;
- delete pszconvert;
- delete pszdone;
- return rt_type;
- } // if
-
- // there are more insertions to make, prepare the strings to use.
- x = strcspn(pszdone, "%");
- strcpy(pszcut, &pszdone[x+2]);
- strncpy(pszpaste, pszdone, x);
- pszpaste[x] = '\0';
- chread = pszdone[x+1];
+ if (!strstr(pszdone, "%")) {
+ UINT rt_type = AfxMessageBox(pszdone, Button, Help);
+ delete pszcut;
+ delete pszpaste;
+ delete pszconvert;
+ delete pszdone;
+ return rt_type;
+ } // if
+
+ // there are more insertions to make, prepare the strings to use.
+ x = strcspn(pszdone, "%");
+ strcpy(pszcut, &pszdone[x+2]);
+ strncpy(pszpaste, pszdone, x);
+ pszpaste[x] = '\0';
+ chread = pszdone[x+1];
- } // for
- ASSERT(FALSE);
- return 0;
+ } // for
+ ASSERT(FALSE);
+ return 0;
} // ShowMessageBox
CString GetMessageString(UINT Id, ...)
{
- CString
- temp;
- char *pszstring,
- *pszpaste,
- *pszcut,
- *pszdone,
- *pszconvert;
- char
- chread;
- va_list
- params;
- int
- x;
- CString strMsg;
-
- pszconvert = new char[255];
- va_start(params, Id);
- LoadString (temp, Id);
- pszstring = temp.GetBuffer(512);
- strcpy(pszconvert,pszstring);
- temp.ReleaseBuffer();
-
- // Look and see - is there a need to insert chars (95% of the time, there won't)
- if (!strstr(pszstring, "%")) {
- strMsg = pszconvert;
+ CString temp;
+ char *pszstring,
+ *pszpaste,
+ *pszcut,
+ *pszdone,
+ *pszconvert;
+ char chread;
+ va_list params;
+ int x;
+ CString strMsg;
+
+ pszconvert = new char[255];
+ va_start(params, Id);
+ LoadString (temp, Id);
+ pszstring = temp.GetBuffer(512);
+ strcpy(pszconvert,pszstring);
+ temp.ReleaseBuffer();
+
+ // Look and see - is there a need to insert chars (95% of the time, there won't)
+ if (!strstr(pszstring, "%")) {
+ strMsg = pszconvert;
+ delete pszconvert;
+ return strMsg;
+ }
+
+ x = strcspn(pszstring, "%");
+ pszdone = new char[512];
+ pszcut = new char[512];
+ pszpaste = new char[512];
+ strcpy(pszcut, &pszstring[x+2]);
+ strncpy(pszpaste, pszstring, x);
+ pszpaste[x] = '\0';
+ chread = pszstring[x+1];
+
+ for ( ; ; ) {
+
+ switch (chread) {
+ case 'i' :
+ case 'd' :
+ {
+ int anint = va_arg(params, int);
+ _itoa( anint, pszconvert, 10);
+ break;
+ }
+ case 'u' :
+ {
+ UINT anuint = va_arg(params, UINT);
+ _itoa( anuint, pszconvert, 10);
+ break;
+ }
+
+ case 'x' :
+ case 'X' :
+ {
+ int ahex = va_arg(params, int);
+ _itoa( ahex, pszconvert, 16);
+ break;
+ }
+ case 'g' :
+ case 'f' :
+ case 'e' :
+ {
+ double adbl = va_arg(params, double);
+ _gcvt( adbl, 10, pszconvert);
+ break;
+ }
+ case 's' :
+ {
+ char *pStr = va_arg(params, char*);
+ ASSERT(strlen(pStr) <= 255);
+ strcpy(pszconvert, pStr);
+ break;
+ }
+ case 'l' :
+ {
+ chread = pszdone[x+2];
+ switch(chread) {
+ case 'x' :
+ {
+ long int alhex = va_arg(params, long int);
+ _ltoa(alhex, pszconvert, 16);
+ strcpy(pszcut, &pszcut[1]);
+ break;
+ }
+ case 'd' :
+ default :
+ {
+ long int along = va_arg(params, long int);
+ _ltoa( along, pszconvert, 10);
+ // For the L, there will be one character after it,
+ // so move ahead another letter
+ strcpy(pszcut, &pszcut[1]);
+ break;
+ }
+ }
+ break;
+ }
+
+ case 'c' :
+ {
+ int letter = va_arg(params, int);
+ pszconvert[0] = (char)letter;
+ pszconvert[1] = '\0';
+ break;
+ }
+ case 'a' :
+ {
+ CString zeta;
+ char* lsc;
+ UINT ls = va_arg(params, UINT);
+ LoadString (zeta, ls);
+ lsc = zeta.GetBuffer(255);
+ strcpy(pszconvert, lsc);
+ zeta.ReleaseBuffer();
+ break;
+ }
+ case 'o' :
+ {
+ CString get = va_arg(params, CString);
+ char* ex = get.GetBuffer(255);
+ strcpy(pszconvert,ex);
+ get.ReleaseBuffer();
+ break;
+ }
+ default:
+ {
+ strcpy(pszconvert, " Could not load message. Invalid %type in string table entry. ");
+ delete pszdone;
+ pszdone = new char[strlen(pszpaste)+strlen(pszcut)+strlen(pszconvert)+5];
+ strcpy(pszdone, pszpaste);
+ strcat(pszdone, pszconvert);
+ strcat(pszdone, pszcut);
+ strMsg = pszdone;
+ delete pszcut;
+ delete pszpaste;
delete pszconvert;
+ delete pszdone;
+ ASSERT(FALSE);
return strMsg;
- }
-
- x = strcspn(pszstring, "%");
- pszdone = new char[512];
- pszcut = new char[512];
- pszpaste = new char[512];
- strcpy(pszcut, &pszstring[x+2]);
- strncpy(pszpaste, pszstring, x);
- pszpaste[x] = '\0';
- chread = pszstring[x+1];
-
- for ( ; ; ) {
-
- switch (chread) {
- case 'i' :
- case 'd' :
- {
- int anint = va_arg(params, int);
- _itoa( anint, pszconvert, 10);
- break;
- }
- case 'u' :
- {
- UINT anuint = va_arg(params, UINT);
- _itoa( anuint, pszconvert, 10);
- break;
- }
-
- case 'x' :
- case 'X' :
- {
- int ahex = va_arg(params, int);
- _itoa( ahex, pszconvert, 16);
- break;
- }
- case 'g' :
- case 'f' :
- case 'e' :
- {
- double adbl = va_arg(params, double);
- _gcvt( adbl, 10, pszconvert);
- break;
- }
- case 's' :
- {
- char *pStr = va_arg(params, char*);
- ASSERT(strlen(pStr) <= 255);
- strcpy(pszconvert, pStr);
- break;
- }
- case 'l' :
- {
- chread = pszdone[x+2];
- switch(chread) {
- case 'x' :
- {
- long int alhex = va_arg(params, long int);
- _ltoa(alhex, pszconvert, 16);
- strcpy(pszcut, &pszcut[1]);
- break;
- }
- case 'd' :
- default :
- {
- long int along = va_arg(params, long int);
- _ltoa( along, pszconvert, 10);
- // For the L, there will be one character after it,
- // so move ahead another letter
- strcpy(pszcut, &pszcut[1]);
- break;
- }
- }
- break;
- }
-
- case 'c' :
- {
- int letter = va_arg(params, int);
- pszconvert[0] = (char)letter;
- pszconvert[1] = '\0';
- break;
- }
- case 'a' :
- {
- CString zeta;
- char* lsc;
- UINT ls = va_arg(params, UINT);
- LoadString (zeta, ls);
- lsc = zeta.GetBuffer(255);
- strcpy(pszconvert, lsc);
- zeta.ReleaseBuffer();
- break;
- }
- case 'o' :
- {
- CString get = va_arg(params, CString);
- char* ex = get.GetBuffer(255);
- strcpy(pszconvert,ex);
- get.ReleaseBuffer();
- break;
- }
- default :
- {
- strcpy(pszconvert, " Could not load message. Invalid %type in string table entry. ");
- delete pszdone;
- pszdone = new char[strlen(pszpaste)+strlen(pszcut)+strlen(pszconvert)+5];
- strcpy(pszdone, pszpaste);
- strcat(pszdone, pszconvert);
- strcat(pszdone, pszcut);
- strMsg = pszdone;
- delete pszcut;
- delete pszpaste;
- delete pszconvert;
- delete pszdone;
- ASSERT(FALSE);
- return strMsg;
- }
- } // case
-
- delete pszdone;
- pszdone = new char[strlen(pszpaste)+strlen(pszcut)+strlen(pszconvert)+5];
- strcpy(pszdone, pszpaste);
- strcat(pszdone, pszconvert);
- strcat(pszdone, pszcut);
- // Now pszdone holds the entire message.
- // Check to see if there are more insertions to be made or not
+ }
+ } // case
+
+ delete pszdone;
+ pszdone = new char[strlen(pszpaste)+strlen(pszcut)+strlen(pszconvert)+5];
+ strcpy(pszdone, pszpaste);
+ strcat(pszdone, pszconvert);
+ strcat(pszdone, pszcut);
+ // Now pszdone holds the entire message.
+ // Check to see if there are more insertions to be made or not
- if (!strstr(pszdone, "%")) {
- strMsg = pszdone;
- delete pszcut;
- delete pszpaste;
- delete pszconvert;
- delete pszdone;
- return strMsg;
- } // if
-
- // there are more insertions to make, prepare the strings to use.
- x = strcspn(pszdone, "%");
- strcpy(pszcut, &pszdone[x+2]);
- strncpy(pszpaste, pszdone, x);
- pszpaste[x] = '\0';
- chread = pszdone[x+1];
+ if (!strstr(pszdone, "%")) {
+ strMsg = pszdone;
+ delete pszcut;
+ delete pszpaste;
+ delete pszconvert;
+ delete pszdone;
+ return strMsg;
+ } // if
+
+ // there are more insertions to make, prepare the strings to use.
+ x = strcspn(pszdone, "%");
+ strcpy(pszcut, &pszdone[x+2]);
+ strncpy(pszpaste, pszdone, x);
+ pszpaste[x] = '\0';
+ chread = pszdone[x+1];
- } // for
- ASSERT(FALSE);
- return strMsg;
+ } // for
+ ASSERT(FALSE);
+ return strMsg;
}
void LoadString (CString &Str, UINT id)
{
- TCHAR szString[ 256 ];
- GetString (szString, id);
- Str = szString;
+ TCHAR szString[ 256 ];
+ GetString (szString, id);
+ Str = szString;
}
CResultsDlg::CResultsDlg(DWORD nHelpID, CWnd* pParent /*=NULL*/)
: CDialog()
{
- InitModalIndirect (TaLocale_GetDialogResource (CResultsDlg::IDD), pParent);
+ InitModalIndirect (TaLocale_GetDialogResource (CResultsDlg::IDD), pParent);
- //{{AFX_DATA_INIT(CResultsDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
+ //{{AFX_DATA_INIT(CResultsDlg)
+ // NOTE: the ClassWizard will add member initialization here
+ //}}AFX_DATA_INIT
- m_nHelpID = nHelpID;
+ m_nHelpID = nHelpID;
}
void CResultsDlg::DoDataExchange(CDataExchange* pDX)
{
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CResultsDlg)
- DDX_Control(pDX, IDC_RESULTS_LABEL, m_ResultsLabel);
- DDX_Control(pDX, IDC_LIST, m_List);
- //}}AFX_DATA_MAP
+ CDialog::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CResultsDlg)
+ DDX_Control(pDX, IDC_RESULTS_LABEL, m_ResultsLabel);
+ DDX_Control(pDX, IDC_LIST, m_List);
+ //}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CResultsDlg, CDialog)
- //{{AFX_MSG_MAP(CResultsDlg)
- ON_BN_CLICKED(IDHELP, OnHelp)
- //}}AFX_MSG_MAP
+ //{{AFX_MSG_MAP(CResultsDlg)
+ ON_BN_CLICKED(IDHELP, OnHelp)
+ //}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
BOOL CResultsDlg::OnInitDialog()
{
- CDialog::OnInitDialog();
+ CDialog::OnInitDialog();
- SetWindowText(m_strDlgTitle);
- m_ResultsLabel.SetWindowText(m_strResultsTitle);
+ SetWindowText(m_strDlgTitle);
+ m_ResultsLabel.SetWindowText(m_strResultsTitle);
- ASSERT(m_Files.GetSize() == m_Results.GetSize());
+ ASSERT(m_Files.GetSize() == m_Results.GetSize());
- m_List.SetTabStops(118);
+ m_List.SetTabStops(118);
- for (int i = 0; i < m_Files.GetSize(); i++) {
- CString strItem = m_Files[i] + "\t" + m_Results[i];
- m_List.AddString(strItem);
- }
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ for (int i = 0; i < m_Files.GetSize(); i++) {
+ CString strItem = m_Files[i] + "\t" + m_Results[i];
+ m_List.AddString(strItem);
+ }
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CResultsDlg::SetContents(const CString& strDlgTitle, const CString& strResultsTitle, const CStringArray& files, const CStringArray& results)
{
- m_strDlgTitle = strDlgTitle;
- m_strResultsTitle = strResultsTitle;
+ m_strDlgTitle = strDlgTitle;
+ m_strResultsTitle = strResultsTitle;
- m_Files.RemoveAll();
- m_Files.Copy(files);
+ m_Files.RemoveAll();
+ m_Files.Copy(files);
- m_Results.RemoveAll();
- m_Results.Copy(results);
+ m_Results.RemoveAll();
+ m_Results.Copy(results);
}
void CResultsDlg::OnHelp()
{
- ShowHelp(m_hWnd, m_nHelpID);
+ ShowHelp(m_hWnd, m_nHelpID);
}
static BOOL IsADir(const CString& strName)
{
- struct _stat statbuf;
+ struct _stat statbuf;
- if (_stat(strName, &statbuf) < 0)
- return FALSE;
+ if (_stat(strName, &statbuf) < 0)
+ return FALSE;
- return statbuf.st_mode & _S_IFDIR;
+ return statbuf.st_mode & _S_IFDIR;
}
/////////////////////////////////////////////////////////////////////////////
CShellExt::CShellExt()
{
- HKEY NPKey;
- EnableAutomation();
- nCMRefCount++;
- HRESULT hr;
- UINT code;
- DWORD ShellOption,LSPsize,LSPtype;
- hr = SHGetMalloc(&m_pAlloc);
- m_bIsOverlayEnabled=FALSE;
- if (FAILED(hr))
- m_pAlloc = NULL;
- RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY,0, KEY_QUERY_VALUE, &NPKey);
- LSPsize=sizeof(ShellOption);
- code=RegQueryValueEx(NPKey, "ShellOption", NULL,
- &LSPtype, (LPBYTE)&ShellOption, &LSPsize);
- RegCloseKey (NPKey);
- m_bIsOverlayEnabled=((code==0) && (LSPtype==REG_DWORD) && ((ShellOption & OVERLAYENABLED)!=0));
- TRACE("Create CShellExt, Ref count %d/n",nCMRefCount);
+ HKEY NPKey;
+ EnableAutomation();
+ nCMRefCount++;
+ HRESULT hr;
+ UINT code;
+ DWORD ShellOption,LSPsize,LSPtype;
+ hr = SHGetMalloc(&m_pAlloc);
+ m_bIsOverlayEnabled=FALSE;
+ if (FAILED(hr))
+ m_pAlloc = NULL;
+ RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY,0, KEY_QUERY_VALUE, &NPKey);
+ LSPsize=sizeof(ShellOption);
+ code=RegQueryValueEx(NPKey, "ShellOption", NULL,
+ &LSPtype, (LPBYTE)&ShellOption, &LSPsize);
+ RegCloseKey (NPKey);
+ m_bIsOverlayEnabled=((code==0) && (LSPtype==REG_DWORD) && ((ShellOption & OVERLAYENABLED)!=0));
+ TRACE("Create CShellExt, Ref count %d/n",nCMRefCount);
}
CShellExt::~CShellExt()
{
- if(m_pAlloc) m_pAlloc->Release();
- nCMRefCount--;
- TRACE("Destroy CShellExt, Ref count %d/n",nCMRefCount);
+ if(m_pAlloc)
+ m_pAlloc->Release();
+ nCMRefCount--;
+ TRACE("Destroy CShellExt, Ref count %d/n",nCMRefCount);
}
void CShellExt::OnFinalRelease()
{
- // When the last reference for an automation object is released
- // OnFinalRelease is called. The base class will automatically
- // deletes the object. Add additional cleanup required for your
- // object before calling the base class.
+ // When the last reference for an automation object is released
+ // OnFinalRelease is called. The base class will automatically
+ // deletes the object. Add additional cleanup required for your
+ // object before calling the base class.
- CCmdTarget::OnFinalRelease();
-}
+ CCmdTarget::OnFinalRelease();
+}
BEGIN_MESSAGE_MAP(CShellExt, CCmdTarget)
- //{{AFX_MSG_MAP(CShellExt)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- //}}AFX_MSG_MAP
+ //{{AFX_MSG_MAP(CShellExt)
+ // NOTE - the ClassWizard will add and remove mapping macros here.
+ //}}AFX_MSG_MAP
END_MESSAGE_MAP()
BEGIN_DISPATCH_MAP(CShellExt, CCmdTarget)
- //{{AFX_DISPATCH_MAP(CShellExt)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- //}}AFX_DISPATCH_MAP
+ //{{AFX_DISPATCH_MAP(CShellExt)
+ // NOTE - the ClassWizard will add and remove mapping macros here.
+ //}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()
// Note: we add support for IID_IShellExt to support typesafe binding
#endif
BEGIN_INTERFACE_MAP(CShellExt, CCmdTarget)
- INTERFACE_PART(CShellExt, IID_IShellExt, Dispatch)
+ INTERFACE_PART(CShellExt, IID_IShellExt, Dispatch)
INTERFACE_PART(CShellExt, IID_IContextMenu, MenuExt)
INTERFACE_PART(CShellExt, IID_IShellExtInit, ShellInit)
- INTERFACE_PART(CShellExt, IID_IShellIconOverlayIdentifier, IconExt)
- INTERFACE_PART(CShellExt, IID_IQueryInfo , ToolTipExt)
- INTERFACE_PART(CShellExt, IID_IPersistFile , PersistFileExt)
+ INTERFACE_PART(CShellExt, IID_IShellIconOverlayIdentifier, IconExt)
+ INTERFACE_PART(CShellExt, IID_IQueryInfo , ToolTipExt)
+ INTERFACE_PART(CShellExt, IID_IPersistFile , PersistFileExt)
END_INTERFACE_MAP()
#ifndef _WIN64
STDMETHODIMP_(ULONG) CShellExt::XMenuExt::AddRef(void)
{
- return ++nCMRefCount;
+ return ++nCMRefCount;
}
STDMETHODIMP_(ULONG) CShellExt::XMenuExt::Release(void)
{
- if (nCMRefCount > 0)
- nCMRefCount--;
+ if (nCMRefCount > 0)
+ nCMRefCount--;
- return nCMRefCount;
+ return nCMRefCount;
}
/////////////////////////////////////////////////////////////////////////////
{
METHOD_PROLOGUE(CShellExt, MenuExt);
- // Don't add any menu items if we're being asked to deal with this file as a shortcut.
- if (uFlags & CMF_VERBSONLY)
- return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, (USHORT)0);
-
- // Check to see if there's already an AFS menu here; if so, remove it
- int nItemsNow = GetMenuItemCount (hMenu);
- CString strAfsItemText = GetMessageString(IDS_AFS_ITEM);
- LPCTSTR pszAfsItemText = (LPCTSTR)strAfsItemText;
- for (int iItem = 0; iItem < nItemsNow; iItem++) {
- TCHAR szItemText[256];
- if (!GetMenuString (hMenu, iItem, szItemText, 256, MF_BYPOSITION))
- continue;
- if (!lstrcmp (szItemText, pszAfsItemText)) {
- DeleteMenu (hMenu, iItem, MF_BYPOSITION);
- continue;
- }
- if ((!lstrcmp(szItemText,"&Delete"))&&(pThis->m_bIsSymlink)) { /*this is a symlink - don't present a delete menu!*/
- DeleteMenu (hMenu, iItem, MF_BYPOSITION);
- continue;
- }
- if ((!lstrcmp(szItemText,"Cu&t"))&&(pThis->m_bIsSymlink)) { /*same for cut*/
- DeleteMenu (hMenu, iItem, MF_BYPOSITION);
- continue;
- }
+ // Don't add any menu items if we're being asked to deal with this file as a shortcut.
+ if (uFlags & CMF_VERBSONLY)
+ return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, (USHORT)0);
+
+ // Check to see if there's already an AFS menu here; if so, remove it
+ int nItemsNow = GetMenuItemCount (hMenu);
+ CString strAfsItemText = GetMessageString(IDS_AFS_ITEM);
+ LPCTSTR pszAfsItemText = (LPCTSTR)strAfsItemText;
+ for (int iItem = 0; iItem < nItemsNow; iItem++) {
+ TCHAR szItemText[256];
+ if (!GetMenuString (hMenu, iItem, szItemText, 256, MF_BYPOSITION))
+ continue;
+ if (!lstrcmp (szItemText, pszAfsItemText)) {
+ DeleteMenu (hMenu, iItem, MF_BYPOSITION);
+ continue;
}
- int indexShellMenu = 0;
-
- // Create the AFS submenu using the allowed ID's.
- HMENU hAfsMenu = CreatePopupMenu();
- int indexAfsMenu = 0;
+ if ((!lstrcmp(szItemText,"&Delete"))&&(pThis->m_bIsSymlink)) { /*this is a symlink - don't present a delete menu!*/
+ DeleteMenu (hMenu, iItem, MF_BYPOSITION);
+ continue;
+ }
+ if ((!lstrcmp(szItemText,"Cu&t"))&&(pThis->m_bIsSymlink)) { /*same for cut*/
+ DeleteMenu (hMenu, iItem, MF_BYPOSITION);
+ continue;
+ }
+ }
+ int indexShellMenu = 0;
+
+ // Create the AFS submenu using the allowed ID's.
+ HMENU hAfsMenu = CreatePopupMenu();
+ int indexAfsMenu = 0;
+
+ // The Authentication item has been removed from the AFS menu because
+ // there is now a tray icon to handle authentication.
+ //
+ //::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_AUTHENTICATION, GetMessageString(IDS_AUTHENTICATION_ITEM));
+
+ // Only enable the ACL menu item if a single directory is selected
+ int nSingleDirOnly = MF_GRAYED;
+ if (pThis->m_bDirSelected && (pThis->m_astrFileNames.GetSize() == 1))
+ nSingleDirOnly = MF_ENABLED;
+ ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION | nSingleDirOnly, idCmdFirst + IDM_ACL_SET, GetMessageString(IDS_ACLS_ITEM));
+
+ // Volume/Partition submenu of the AFS submenu
+ HMENU hVolPartMenu = CreatePopupMenu();
+ int indexVolPartMenu = 0;
+ ::InsertMenu(hVolPartMenu, indexVolPartMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_VOLUME_PROPERTIES, GetMessageString(IDS_VOL_PART_PROPS_ITEM));
+ ::InsertMenu(hVolPartMenu, indexVolPartMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_VOLUMEPARTITION_UPDATENAMEIDTABLE, GetMessageString(IDS_VOL_PART_REFRESH_ITEM));
+ ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION | MF_POPUP, (UINT)hVolPartMenu, GetMessageString(IDS_VOL_PART_ITEM));
+
+ // Mount Point submenu of the AFS submenu
+ HMENU hMountPointMenu = CreatePopupMenu();
+ int indexMountPointMenu = 0;
+ int nMountPointSelected = MF_GRAYED;
+ for (int n = pThis->m_astrFileNames.GetSize() - 1 ; n >= 0; n--) {
+ if ( IsMountPoint(pThis->m_astrFileNames[n]) ) {
+ nMountPointSelected = MF_ENABLED;
+ break;
+ }
+ }
+ ::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_MOUNTPOINT_SHOW, GetMessageString(IDS_MP_SHOW_ITEM));
+ ::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION | nMountPointSelected, idCmdFirst + IDM_MOUNTPOINT_REMOVE, GetMessageString(IDS_MP_REMOVE_ITEM));
+ ::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_MOUNTPOINT_MAKE, GetMessageString(IDS_MP_MAKE_ITEM));
+ ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION | MF_POPUP, (UINT)hMountPointMenu, GetMessageString(IDS_MOUNT_POINT_ITEM));
- // The Authentication item has been removed from the AFS menu because
- // there is now a tray icon to handle authentication.
- //
- //::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_AUTHENTICATION, GetMessageString(IDS_AUTHENTICATION_ITEM));
-
- // Only enable the ACL menu item if a single directory is selected
- int nSingleDirOnly = MF_GRAYED;
- if (pThis->m_bDirSelected && (pThis->m_astrFileNames.GetSize() == 1))
- nSingleDirOnly = MF_ENABLED;
- ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION | nSingleDirOnly, idCmdFirst + IDM_ACL_SET, GetMessageString(IDS_ACLS_ITEM));
-
- // Volume/Partition submenu of the AFS submenu
- HMENU hVolPartMenu = CreatePopupMenu();
- int indexVolPartMenu = 0;
- ::InsertMenu(hVolPartMenu, indexVolPartMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_VOLUME_PROPERTIES, GetMessageString(IDS_VOL_PART_PROPS_ITEM));
- ::InsertMenu(hVolPartMenu, indexVolPartMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_VOLUMEPARTITION_UPDATENAMEIDTABLE, GetMessageString(IDS_VOL_PART_REFRESH_ITEM));
- ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION | MF_POPUP, (UINT)hVolPartMenu, GetMessageString(IDS_VOL_PART_ITEM));
-
- // Mount Point submenu of the AFS submenu
- HMENU hMountPointMenu = CreatePopupMenu();
- int indexMountPointMenu = 0;
- int nMountPointSelected = MF_GRAYED;
- for (int n = pThis->m_astrFileNames.GetSize() - 1 ; n >= 0; n--) {
- if ( IsMountPoint(pThis->m_astrFileNames[n]) ) {
- nMountPointSelected = MF_ENABLED;
- break;
- }
- }
- ::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_MOUNTPOINT_SHOW, GetMessageString(IDS_MP_SHOW_ITEM));
- ::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION | nMountPointSelected, idCmdFirst + IDM_MOUNTPOINT_REMOVE, GetMessageString(IDS_MP_REMOVE_ITEM));
- ::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_MOUNTPOINT_MAKE, GetMessageString(IDS_MP_MAKE_ITEM));
- ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION | MF_POPUP, (UINT)hMountPointMenu, GetMessageString(IDS_MOUNT_POINT_ITEM));
-
- ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_FLUSH, GetMessageString(IDS_FLUSH_FILE_DIR_ITEM));
- ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_FLUSH_VOLUME, GetMessageString(IDS_FLUSH_VOLUME_ITEM));
- ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SHOW_SERVER, GetMessageString(IDS_SHOW_FILE_SERVERS_ITEM));
- ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SHOWCELL, GetMessageString(IDS_SHOW_CELL_ITEM));
- ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SERVER_STATUS, GetMessageString(IDS_SHOW_SERVER_STATUS_ITEM));
+ ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_FLUSH, GetMessageString(IDS_FLUSH_FILE_DIR_ITEM));
+ ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_FLUSH_VOLUME, GetMessageString(IDS_FLUSH_VOLUME_ITEM));
+ ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SHOW_SERVER, GetMessageString(IDS_SHOW_FILE_SERVERS_ITEM));
+ ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SHOWCELL, GetMessageString(IDS_SHOW_CELL_ITEM));
+ ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SERVER_STATUS, GetMessageString(IDS_SHOW_SERVER_STATUS_ITEM));
HMENU hSymbolicMenu = CreatePopupMenu();
- int indexSymbolicMenu = 0;
+ int indexSymbolicMenu = 0;
::InsertMenu(hSymbolicMenu, indexSymbolicMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SYMBOLICLINK_ADD, GetMessageString(IDS_SYMBOLICLINK_ADD));
// ::InsertMenu(hSymbolicMenu, indexSymbolicMenu, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SYMBOLICLINK_EDIT, GetMessageString(IDS_SYMBOLICLINK_EDIT));
- // ::EnableMenuItem(hSymbolicMenu,indexSymbolicMenu++,((pThis->m_bIsSymlink)?MF_ENABLED:MF_GRAYED)|MF_BYPOSITION);
- ::InsertMenu(hSymbolicMenu, indexSymbolicMenu, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SYMBOLICLINK_REMOVE, GetMessageString(IDS_SYMBOLICLINK_REMOVE));
- ::EnableMenuItem(hSymbolicMenu,indexSymbolicMenu++,((pThis->m_bIsSymlink)?MF_ENABLED:MF_GRAYED)|MF_BYPOSITION);
- ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION | MF_POPUP, (UINT)hSymbolicMenu, GetMessageString(IDS_SYMBOLIC_LINK_ITEM));
-
- // The Submounts menu has been removed because the AFS tray icon
- // and control panel now support mapping drives directly to an AFS
- // path.
- //
- // HMENU hSubmountMenu = CreatePopupMenu();
- // int indexSubmountMenu = 0;
- // ::InsertMenu(hSubmountMenu, indexSubmountMenu++, MF_STRING | MF_BYPOSITION | nSingleDirOnly, idCmdFirst + IDM_SUBMOUNTS_CREATE, GetMessageString(IDS_SUBMOUNTS_CREATE_ITEM));
- // ::InsertMenu(hSubmountMenu, indexSubmountMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SUBMOUNTS_EDIT, GetMessageString(IDS_SUBMOUNTS_EDIT_ITEM));
- // ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION | MF_POPUP, (UINT)hSubmountMenu, GetMessageString(IDS_SUBMOUNTS_ITEM));
-
- // Add a separator
- ::InsertMenu (hMenu, indexMenu + indexShellMenu++, MF_STRING | MF_BYPOSITION | MF_SEPARATOR, 0, TEXT(""));
-
- // Add the AFS submenu to the shell's menu
- ::InsertMenu(hMenu, indexMenu + indexShellMenu++, MF_STRING | MF_BYPOSITION | MF_POPUP, (UINT)hAfsMenu, GetMessageString(IDS_AFS_ITEM));
-
- // Add a separator after us
- ::InsertMenu (hMenu, indexMenu + indexShellMenu++, MF_STRING | MF_BYPOSITION | MF_SEPARATOR, 0, TEXT(""));
-
+ // ::EnableMenuItem(hSymbolicMenu,indexSymbolicMenu++,((pThis->m_bIsSymlink)?MF_ENABLED:MF_GRAYED)|MF_BYPOSITION);
+ ::InsertMenu(hSymbolicMenu, indexSymbolicMenu, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SYMBOLICLINK_REMOVE, GetMessageString(IDS_SYMBOLICLINK_REMOVE));
+ ::EnableMenuItem(hSymbolicMenu,indexSymbolicMenu++,((pThis->m_bIsSymlink)?MF_ENABLED:MF_GRAYED)|MF_BYPOSITION);
+ ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION | MF_POPUP, (UINT)hSymbolicMenu, GetMessageString(IDS_SYMBOLIC_LINK_ITEM));
+
+ // The Submounts menu has been removed because the AFS tray icon
+ // and control panel now support mapping drives directly to an AFS
+ // path.
+ //
+ // HMENU hSubmountMenu = CreatePopupMenu();
+ // int indexSubmountMenu = 0;
+ // ::InsertMenu(hSubmountMenu, indexSubmountMenu++, MF_STRING | MF_BYPOSITION | nSingleDirOnly, idCmdFirst + IDM_SUBMOUNTS_CREATE, GetMessageString(IDS_SUBMOUNTS_CREATE_ITEM));
+ // ::InsertMenu(hSubmountMenu, indexSubmountMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SUBMOUNTS_EDIT, GetMessageString(IDS_SUBMOUNTS_EDIT_ITEM));
+ // ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION | MF_POPUP, (UINT)hSubmountMenu, GetMessageString(IDS_SUBMOUNTS_ITEM));
+
+ // Add a separator
+ ::InsertMenu (hMenu, indexMenu + indexShellMenu++, MF_STRING | MF_BYPOSITION | MF_SEPARATOR, 0, TEXT(""));
+
+ // Add the AFS submenu to the shell's menu
+ ::InsertMenu(hMenu, indexMenu + indexShellMenu++, MF_STRING | MF_BYPOSITION | MF_POPUP, (UINT)hAfsMenu, GetMessageString(IDS_AFS_ITEM));
+
+ // Add a separator after us
+ ::InsertMenu (hMenu, indexMenu + indexShellMenu++, MF_STRING | MF_BYPOSITION | MF_SEPARATOR, 0, TEXT(""));
+
return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL,
- (USHORT)indexAfsMenu + indexVolPartMenu + indexMountPointMenu + indexShellMenu + indexSymbolicMenu);
-}
+ (USHORT)indexAfsMenu + indexVolPartMenu + indexMountPointMenu + indexShellMenu + indexSymbolicMenu);
+}
STDMETHODIMP CShellExt::XMenuExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
{
if (HIWORD(lpici->lpVerb ))
return E_FAIL;
- AddRef();
+ AddRef();
- CStringArray &files = pThis->m_astrFileNames;
+ CStringArray &files = pThis->m_astrFileNames;
- switch (LOWORD(lpici->lpVerb))
- {
- case IDM_AUTHENTICATION: {
- CAuthDlg dlg;
- dlg.DoModal();
- break;
- }
-
- case IDM_ACL_SET: {
- CSetAfsAcl dlg;
- ASSERT(files.GetSize() == 1);
- dlg.SetDir(files[0]);
- dlg.DoModal();
- }
- break;
-
- case IDM_VOLUME_PROPERTIES: {
- CVolumeInfo dlg;
- dlg.SetFiles(files);
- dlg.DoModal();
- }
- break;
-
- case IDM_VOLUMEPARTITION_UPDATENAMEIDTABLE: CheckVolumes();
- break;
-
- case IDM_MOUNTPOINT_SHOW: ListMount(files);
- break;
-
- case IDM_MOUNTPOINT_REMOVE: {
- int nChoice = ShowMessageBox(IDS_REALLY_DEL_MOUNT_POINTS, MB_ICONQUESTION | MB_YESNO, IDS_REALLY_DEL_MOUNT_POINTS);
- if (nChoice == IDYES)
- RemoveMount(files);
- }
- break;
-
- case IDM_MOUNTPOINT_MAKE: {
- CMakeMountPointDlg dlg;
- ASSERT(files.GetSize() == 1);
- dlg.SetDir(files[0]);
- dlg.DoModal();
- }
- break;
+ switch (LOWORD(lpici->lpVerb))
+ {
+ case IDM_AUTHENTICATION: {
+ CAuthDlg dlg;
+ dlg.DoModal();
+ break;
+ }
+ case IDM_ACL_SET: {
+ CSetAfsAcl dlg;
+ ASSERT(files.GetSize() == 1);
+ dlg.SetDir(files[0]);
+ dlg.DoModal();
+ break;
+ }
- case IDM_FLUSH: Flush(files);
- break;
-
- case IDM_FLUSH_VOLUME: FlushVolume(files);
- break;
+ case IDM_VOLUME_PROPERTIES: {
+ CVolumeInfo dlg;
+ dlg.SetFiles(files);
+ dlg.DoModal();
+ break;
+ }
- case IDM_SHOW_SERVER: WhereIs(files);
- break;
-
- case IDM_SHOWCELL: WhichCell(files);
- break;
+ case IDM_VOLUMEPARTITION_UPDATENAMEIDTABLE:
+ CheckVolumes();
+ break;
- case IDM_SERVER_STATUS: {
- CServerStatusDlg dlg;
- dlg.DoModal();
- }
- break;
+ case IDM_MOUNTPOINT_SHOW:
+ ListMount(files);
+ break;
- /*
- case IDM_SUBMOUNTS_EDIT: {
- CSubmountsDlg dlg;
- dlg.DoModal();
- }
- break;
-
- case IDM_SUBMOUNTS_CREATE: {
- ASSERT(files.GetSize() == 1);
- CSubmountsDlg dlg;
- dlg.SetAddOnlyMode(files[0]);
- dlg.DoModal();
- }
- break;
- */
- case IDM_SYMBOLICLINK_REMOVE: {
- if (files.GetSize()>1)
- break;
- CString msg=files.GetAt(0);
- int i;
- if ((i=msg.ReverseFind('\\'))>0)
- msg=msg.Left(i+1);
- else if ((i=msg.ReverseFind(':'))>0)
- msg=msg.Left(i+1)+"\\";
- if (!SetCurrentDirectory(msg))
- {
- MessageBeep((UINT)-1);
- ShowMessageBox(IDS_UNABLE_TO_SET_CURRENT_DIRECTORY,MB_OK,IDS_UNABLE_TO_SET_CURRENT_DIRECTORY);
- break;
- }
- msg=files.GetAt(0);
- if ((i=msg.ReverseFind('\\'))>0||((i=msg.ReverseFind(':'))>0))
- msg=msg.Right(msg.GetLength()-i-1);
- int nChoice = ShowMessageBox(IDS_REALLY_REMOVE_SYMLINK, MB_ICONQUESTION | MB_YESNO, IDS_REALLY_REMOVE_SYMLINK,msg);
- if (nChoice == IDYES)
- RemoveSymlink(files.GetAt(0));
- }
- break;
+ case IDM_MOUNTPOINT_REMOVE: {
+ int nChoice = ShowMessageBox(IDS_REALLY_DEL_MOUNT_POINTS, MB_ICONQUESTION | MB_YESNO, IDS_REALLY_DEL_MOUNT_POINTS);
+ if (nChoice == IDYES)
+ RemoveMount(files);
+ break;
+ }
+
+ case IDM_MOUNTPOINT_MAKE: {
+ CMakeMountPointDlg dlg;
+ ASSERT(files.GetSize() == 1);
+ dlg.SetDir(files[0]);
+ dlg.DoModal();
+ break;
+ }
+
+ case IDM_FLUSH:
+ Flush(files);
+ break;
+
+ case IDM_FLUSH_VOLUME:
+ FlushVolume(files);
+ break;
- case IDM_SYMBOLICLINK_ADD: {
- CString msg=files.GetAt(0);
- int i;
- if ((i=msg.ReverseFind('\\'))>0)
- msg=msg.Left(i+1);
- else if ((i=msg.ReverseFind(':'))>0)
- msg=msg.Left(i+1)+"\\";
- CMakeSymbolicLinkDlg dlg;
- dlg.Setbase(msg);
- dlg.DoModal();
+ case IDM_SHOW_SERVER:
+ WhereIs(files);
+ break;
+
+ case IDM_SHOWCELL:
+ WhichCell(files);
+ break;
+
+ case IDM_SERVER_STATUS: {
+ CServerStatusDlg dlg;
+ dlg.DoModal();
+ break;
+ }
+
+ /*
+ case IDM_SUBMOUNTS_EDIT: {
+ CSubmountsDlg dlg;
+ dlg.DoModal();
+ break;
}
- break;
-
- case IDM_REMOVE_SYMLINK: {
- if (files.GetSize()>1)
- break;
- int nChoice = ShowMessageBox(IDS_REALLY_REMOVE_SYMLINK, MB_ICONQUESTION | MB_YESNO, IDS_REALLY_REMOVE_SYMLINK);
- if (nChoice == IDYES)
- RemoveSymlink(files.GetAt(0));
+ case IDM_SUBMOUNTS_CREATE: {
+ ASSERT(files.GetSize() == 1);
+ CSubmountsDlg dlg;
+ dlg.SetAddOnlyMode(files[0]);
+ dlg.DoModal();
+ break;
}
- break;
- default:
- ASSERT(FALSE);
- Release();
- return E_INVALIDARG;
+ */
+ case IDM_SYMBOLICLINK_REMOVE: {
+ if (files.GetSize()>1)
+ break;
+ CString msg=files.GetAt(0);
+ int i;
+ if ((i=msg.ReverseFind('\\'))>0)
+ msg=msg.Left(i+1);
+ else if ((i=msg.ReverseFind(':'))>0)
+ msg=msg.Left(i+1)+"\\";
+ if (!SetCurrentDirectory(msg))
+ {
+ MessageBeep((UINT)-1);
+ ShowMessageBox(IDS_UNABLE_TO_SET_CURRENT_DIRECTORY,MB_OK,IDS_UNABLE_TO_SET_CURRENT_DIRECTORY);
+ break;
}
+ msg=files.GetAt(0);
+ if ((i=msg.ReverseFind('\\'))>0||((i=msg.ReverseFind(':'))>0))
+ msg=msg.Right(msg.GetLength()-i-1);
+ int nChoice = ShowMessageBox(IDS_REALLY_REMOVE_SYMLINK, MB_ICONQUESTION | MB_YESNO, IDS_REALLY_REMOVE_SYMLINK,msg);
+ if (nChoice == IDYES)
+ RemoveSymlink(files.GetAt(0));
+ break;
+ }
+ case IDM_SYMBOLICLINK_ADD: {
+ CString msg=files.GetAt(0);
+ int i;
+ if ((i=msg.ReverseFind('\\'))>0)
+ msg=msg.Left(i+1);
+ else if ((i=msg.ReverseFind(':'))>0)
+ msg=msg.Left(i+1)+"\\";
+ CMakeSymbolicLinkDlg dlg;
+ dlg.Setbase(msg);
+ dlg.DoModal();
+ break;
+ }
+
+ case IDM_REMOVE_SYMLINK: {
+ if (files.GetSize()>1)
+ break;
+ int nChoice = ShowMessageBox(IDS_REALLY_REMOVE_SYMLINK, MB_ICONQUESTION | MB_YESNO, IDS_REALLY_REMOVE_SYMLINK);
+ if (nChoice == IDYES)
+ RemoveSymlink(files.GetAt(0));
+ }
+ break;
+ default:
+ ASSERT(FALSE);
Release();
+ return E_INVALIDARG;
+ }
+
+ Release();
return NOERROR;
-}
+}
STDMETHODIMP CShellExt::XMenuExt::GetCommandString(UINT_PTR idCmd, UINT uType,
UINT* pwReserved, LPSTR pszName, UINT cchMax)
{
- if (uType != GCS_HELPTEXT)
- return NOERROR; // ?????????????????????????????????????????????????
+ if (uType != GCS_HELPTEXT)
+ return NOERROR; // ?????????????????????????????????????????????????
- UINT nCmdStrID;
+ UINT nCmdStrID;
AfxSetResourceHandle(theApp.m_hInstance);
switch (idCmd)
- {
- case IDM_AUTHENTICATION: nCmdStrID = ID_AUTHENTICATE;
- break;
-
- case IDM_ACL_SET: nCmdStrID = ID_ACL_SET;
- break;
+ {
+ case IDM_AUTHENTICATION:
+ nCmdStrID = ID_AUTHENTICATE;
+ break;
+
+ case IDM_ACL_SET:
+ nCmdStrID = ID_ACL_SET;
+ break;
+
+ case IDM_VOLUME_PROPERTIES:
+ nCmdStrID = ID_VOLUME_PROPERTIES;
+ break;
+
+ case IDM_VOLUMEPARTITION_UPDATENAMEIDTABLE:
+ nCmdStrID = ID_VOLUMEPARTITION_UPDATENAMEIDTABLE;
+ break;
+
+ case IDM_MOUNTPOINT_SHOW:
+ nCmdStrID = ID_MOUNTPOINT_SHOW;
+ break;
+
+ case IDM_MOUNTPOINT_REMOVE:
+ nCmdStrID = ID_MOUNTPOINT_REMOVE;
+ break;
- case IDM_VOLUME_PROPERTIES: nCmdStrID = ID_VOLUME_PROPERTIES;
- break;
+ case IDM_MOUNTPOINT_MAKE:
+ nCmdStrID = ID_MOUNTPOINT_MAKE;
+ break;
- case IDM_VOLUMEPARTITION_UPDATENAMEIDTABLE: nCmdStrID = ID_VOLUMEPARTITION_UPDATENAMEIDTABLE;
- break;
+ case IDM_FLUSH:
+ nCmdStrID = ID_FLUSH;
+ break;
- case IDM_MOUNTPOINT_SHOW: nCmdStrID = ID_MOUNTPOINT_SHOW;
- break;
+ case IDM_FLUSH_VOLUME:
+ nCmdStrID = ID_VOLUME_FLUSH;
+ break;
- case IDM_MOUNTPOINT_REMOVE: nCmdStrID = ID_MOUNTPOINT_REMOVE;
- break;
-
- case IDM_MOUNTPOINT_MAKE: nCmdStrID = ID_MOUNTPOINT_MAKE;
- break;
+ case IDM_SHOW_SERVER:
+ nCmdStrID = ID_WHEREIS;
+ break;
- case IDM_FLUSH: nCmdStrID = ID_FLUSH;
- break;
-
- case IDM_FLUSH_VOLUME: nCmdStrID = ID_VOLUME_FLUSH;
- break;
+ case IDM_SHOWCELL:
+ nCmdStrID = ID_SHOWCELL;
+ break;
- case IDM_SHOW_SERVER: nCmdStrID = ID_WHEREIS;
- break;
-
- case IDM_SHOWCELL: nCmdStrID = ID_SHOWCELL;
- break;
+ case IDM_SERVER_STATUS:
+ nCmdStrID = ID_SERVER_STATUS;
+ break;
- case IDM_SERVER_STATUS: nCmdStrID = ID_SERVER_STATUS;
- break;
-
- case IDM_SYMBOLICLINK_ADD: nCmdStrID = ID_SYMBOLICLINK_ADD;
- break;
+ case IDM_SYMBOLICLINK_ADD:
+ nCmdStrID = ID_SYMBOLICLINK_ADD;
+ break;
- case IDM_SYMBOLICLINK_REMOVE: nCmdStrID = ID_SYMBOLICLINK_REMOVE;
- break;
+ case IDM_SYMBOLICLINK_REMOVE:
+ nCmdStrID = ID_SYMBOLICLINK_REMOVE;
+ break;
- case IDM_REMOVE_SYMLINK: nCmdStrID= ID_REMOVE_SYMLINK;
- break;
+ case IDM_REMOVE_SYMLINK:
+ nCmdStrID= ID_REMOVE_SYMLINK;
+ break;
- default:
- ASSERT(FALSE);
- Release();
- return E_INVALIDARG;
- }
+ default:
+ ASSERT(FALSE);
+ Release();
+ return E_INVALIDARG;
+ }
CString strMsg;
LoadString (strMsg, nCmdStrID);
STDMETHODIMP_(ULONG) CShellExt::XShellInit::AddRef(void)
{
- return ++nSERefCount;
+ return ++nSERefCount;
}
STDMETHODIMP_(ULONG) CShellExt::XShellInit::Release(void)
{
- if (nSERefCount > 0)
- nSERefCount--;
+ if (nSERefCount > 0)
+ nSERefCount--;
- return nSERefCount;
+ return nSERefCount;
}
/////////////////////////////////////////////////////////////////////////////
FORMATETC fmte = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
STGMEDIUM medium;
- // We must have a data object
+ // We must have a data object
if (pdobj == NULL)
return E_FAIL;
// Use the given IDataObject to get a list of filenames (CF_HDROP)
hres = pdobj->GetData(&fmte, &medium);
if (FAILED(hres)) {
- return E_FAIL;
+ return E_FAIL;
}
int nNumFiles = DragQueryFile((HDROP)medium.hGlobal, 0xFFFFFFFF, NULL, 0);
- if (nNumFiles == 0)
- hres = E_FAIL;
- else {
- pThis->m_bDirSelected = FALSE;
-
- for (int ii = 0; ii < nNumFiles; ii++) {
- CString strFileName;
-
- // Get the size of the file name string
- int nNameLen = DragQueryFile((HDROP)medium.hGlobal, ii, 0, 0);
-
- // Make room for it in our string object
- LPTSTR pszFileNameBuf = strFileName.GetBuffer(nNameLen + 1); // +1 for the terminating NULL
- ASSERT(pszFileNameBuf);
-
- // Get the file name
- DragQueryFile((HDROP)medium.hGlobal, ii, pszFileNameBuf, nNameLen + 1);
-
- strFileName.ReleaseBuffer();
-
- if (!IsPathInAfs(strFileName)) {
- pThis->m_astrFileNames.RemoveAll();
- break;
- } else {
- pThis->m_bIsSymlink=IsSymlink(strFileName);
- }
-
- if (IsADir(strFileName))
- pThis->m_bDirSelected = TRUE;
-
- pThis->m_astrFileNames.Add(strFileName);
- }
-
- if (pThis->m_astrFileNames.GetSize() > 0)
- hres = NOERROR;
- else
- hres = E_FAIL;
+ if (nNumFiles == 0)
+ hres = E_FAIL;
+ else {
+ pThis->m_bDirSelected = FALSE;
+
+ for (int ii = 0; ii < nNumFiles; ii++) {
+ CString strFileName;
+
+ // Get the size of the file name string
+ int nNameLen = DragQueryFile((HDROP)medium.hGlobal, ii, 0, 0);
+
+ // Make room for it in our string object
+ LPTSTR pszFileNameBuf = strFileName.GetBuffer(nNameLen + 1); // +1 for the terminating NULL
+ ASSERT(pszFileNameBuf);
+
+ // Get the file name
+ DragQueryFile((HDROP)medium.hGlobal, ii, pszFileNameBuf, nNameLen + 1);
+
+ strFileName.ReleaseBuffer();
+
+ if (!IsPathInAfs(strFileName)) {
+ pThis->m_astrFileNames.RemoveAll();
+ break;
+ } else {
+ pThis->m_bIsSymlink=IsSymlink(strFileName);
+ }
+
+ if (IsADir(strFileName))
+ pThis->m_bDirSelected = TRUE;
+
+ pThis->m_astrFileNames.Add(strFileName);
+ }
+
+ if (pThis->m_astrFileNames.GetSize() > 0)
+ hres = NOERROR;
+ else
+ hres = E_FAIL;
}
// Release the data
STDMETHODIMP_(ULONG) CShellExt::XIconExt::AddRef(void)
{
- return ++nICRefCount;
+ return ++nICRefCount;
}
STDMETHODIMP_(ULONG) CShellExt::XIconExt::Release(void)
{
- if (nICRefCount > 0)
- nICRefCount--;
+ if (nICRefCount > 0)
+ nICRefCount--;
- return nICRefCount;
-}
+ return nICRefCount;
+}
/////////////////////////////////////////////////////////////////////////////
STDMETHODIMP CShellExt::XIconExt::GetOverlayInfo(LPWSTR pwszIconFile
,int cchMax,int* pIndex,DWORD* pdwFlags)
{
- if(IsBadWritePtr(pIndex, sizeof(int)))
- return E_INVALIDARG;
- if(IsBadWritePtr(pdwFlags, sizeof(DWORD)))
- return E_INVALIDARG;
-
- HMODULE hModule=GetModuleHandle("shell32.dll");
- TCHAR szModule[MAX_PATH];
- DWORD z=GetModuleFileName(hModule,szModule,sizeof(szModule));
- MultiByteToWideChar( CP_ACP,0,szModule,-1,pwszIconFile,cchMax);
- *pIndex = 30;
- *pdwFlags = ISIOI_ICONFILE | ISIOI_ICONINDEX;
- return S_OK;
+ if(IsBadWritePtr(pIndex, sizeof(int)))
+ return E_INVALIDARG;
+ if(IsBadWritePtr(pdwFlags, sizeof(DWORD)))
+ return E_INVALIDARG;
+
+ HMODULE hModule=GetModuleHandle("shell32.dll");
+ TCHAR szModule[MAX_PATH];
+ DWORD z=GetModuleFileName(hModule,szModule,sizeof(szModule));
+ MultiByteToWideChar( CP_ACP,0,szModule,-1,pwszIconFile,cchMax);
+ *pIndex = 30;
+ *pdwFlags = ISIOI_ICONFILE | ISIOI_ICONINDEX;
+ return S_OK;
}
STDMETHODIMP CShellExt::XIconExt::GetPriority(int* pPriority)
{
- if(IsBadWritePtr(pPriority, sizeof(int)))
- return E_INVALIDARG;
- *pPriority = 0;
- return S_OK;
+ if(IsBadWritePtr(pPriority, sizeof(int)))
+ return E_INVALIDARG;
+ *pPriority = 0;
+ return S_OK;
}
STDMETHODIMP CShellExt::XIconExt::IsMemberOf(LPCWSTR pwszPath,DWORD dwAttrib)
{
- TCHAR szPath[MAX_PATH];
- WideCharToMultiByte( CP_ACP,0,pwszPath,-1,szPath,MAX_PATH,NULL,NULL);
- if (IsSymlink(szPath))
- return S_OK;
- return S_FALSE;
-}
+ TCHAR szPath[MAX_PATH];
+ WideCharToMultiByte( CP_ACP,0,pwszPath,-1,szPath,MAX_PATH,NULL,NULL);
+ if (IsSymlink(szPath))
+ return S_OK;
+ return S_FALSE;
+}
-/* TOOL TIP INFO IMPLIMENTION */
+/* TOOL TIP INFO IMPLIMENTION */
STDMETHODIMP CShellExt::XToolTipExt::QueryInterface(REFIID riid, void** ppv)
{
STDMETHODIMP_(ULONG) CShellExt::XToolTipExt::AddRef(void)
{
- return ++nTPRefCount;
+ return ++nTPRefCount;
}
STDMETHODIMP_(ULONG) CShellExt::XToolTipExt::Release(void)
{
- if (nTPRefCount> 0)
- nTPRefCount--;
+ if (nTPRefCount> 0)
+ nTPRefCount--;
- return nTPRefCount;
+ return nTPRefCount;
}
STDMETHODIMP CShellExt::XToolTipExt::GetInfoTip(DWORD dwFlags, LPWSTR *ppwszTip)
{
METHOD_PROLOGUE(CShellExt, ToolTipExt);
- if (!IsSymlink(pThis->m_szFile))
- {
- ppwszTip=NULL;
- return S_OK;
- }
- USES_CONVERSION;
- // dwFlags is currently unused.
- *ppwszTip = (WCHAR*) (pThis->m_pAlloc)->Alloc((1+lstrlen(pThis->m_szFile))*sizeof(WCHAR));
- if (*ppwszTip)
- {
- wcscpy(*ppwszTip, (WCHAR*)T2OLE(pThis->m_szFile));
- }
-
+ if (!IsSymlink(pThis->m_szFile))
+ {
+ ppwszTip=NULL;
return S_OK;
+ }
+ USES_CONVERSION;
+ // dwFlags is currently unused.
+ *ppwszTip = (WCHAR*) (pThis->m_pAlloc)->Alloc((1+lstrlen(pThis->m_szFile))*sizeof(WCHAR));
+ if (*ppwszTip)
+ {
+ wcscpy(*ppwszTip, (WCHAR*)T2OLE(pThis->m_szFile));
+ }
+
+ return S_OK;
}
STDMETHODIMP CShellExt::XToolTipExt::GetInfoFlags(LPDWORD pdwFlags)
{
- return S_OK;
+ return S_OK;
}
////////// IPersistFile
STDMETHODIMP_(ULONG) CShellExt::XPersistFileExt::AddRef(void)
{
- return ++nXPRefCount;
+ return ++nXPRefCount;
}
STDMETHODIMP_(ULONG) CShellExt::XPersistFileExt::Release(void)
{
- if (nXPRefCount> 0)
- nXPRefCount--;
+ if (nXPRefCount> 0)
+ nXPRefCount--;
- return nXPRefCount;
+ return nXPRefCount;
}
STDMETHODIMP CShellExt::XPersistFileExt::Load(LPCOLESTR wszFile, DWORD dwMode)
{
METHOD_PROLOGUE(CShellExt, PersistFileExt);
- USES_CONVERSION;
- _tcscpy(pThis->m_szFile, OLE2T((WCHAR*)wszFile));
- return S_OK;
+ USES_CONVERSION;
+ _tcscpy(pThis->m_szFile, OLE2T((WCHAR*)wszFile));
+ return S_OK;
}
STDMETHODIMP CShellExt::XPersistFileExt::GetClassID(LPCLSID)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CShellExt::XPersistFileExt::IsDirty(VOID)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CShellExt::XPersistFileExt::Save(LPCOLESTR, BOOL)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CShellExt::XPersistFileExt::SaveCompleted(LPCOLESTR)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CShellExt::XPersistFileExt::GetCurFile(LPOLESTR FAR*)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
class CShellExt : public CCmdTarget
{
- DECLARE_DYNCREATE(CShellExt)
+ DECLARE_DYNCREATE(CShellExt)
- BOOL m_bDirSelected;
- BOOL m_bIsSymlink; // is symbolic link!
- TCHAR m_szFile[MAX_PATH];
- BOOL m_bIsOverlayEnabled;
- BOOL IsOverlayEnabled(){return m_bIsOverlayEnabled;}
+ BOOL m_bDirSelected;
+ BOOL m_bIsSymlink; // is symbolic link!
+ TCHAR m_szFile[MAX_PATH];
+ BOOL m_bIsOverlayEnabled;
+ BOOL IsOverlayEnabled(){return m_bIsOverlayEnabled;}
CStringArray m_astrFileNames;
- CShellExt(); // protected constructor used by dynamic creation
- LPMALLOC m_pAlloc;
+ CShellExt(); // protected constructor used by dynamic creation
+ LPMALLOC m_pAlloc;
// Attributes
public:
public:
// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CShellExt)
- public:
- virtual void OnFinalRelease();
- //}}AFX_VIRTUAL
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CShellExt)
+ public:
+ virtual void OnFinalRelease();
+ //}}AFX_VIRTUAL
// Implementation
protected:
- virtual ~CShellExt();
-
- // Generated message map functions
- //{{AFX_MSG(CShellExt)
- // NOTE - the ClassWizard will add and remove member functions here.
- //}}AFX_MSG
-
- DECLARE_MESSAGE_MAP()
- // Generated OLE dispatch map functions
- //{{AFX_DISPATCH(CShellExt)
- // NOTE - the ClassWizard will add and remove member functions here.
- //}}AFX_DISPATCH
- DECLARE_DISPATCH_MAP()
+ virtual ~CShellExt();
+
+ // Generated message map functions
+ //{{AFX_MSG(CShellExt)
+ // NOTE - the ClassWizard will add and remove member functions here.
+ //}}AFX_MSG
+
+ DECLARE_MESSAGE_MAP()
+ // Generated OLE dispatch map functions
+ //{{AFX_DISPATCH(CShellExt)
+ // NOTE - the ClassWizard will add and remove member functions here.
+ //}}AFX_DISPATCH
+ DECLARE_DISPATCH_MAP()
- DECLARE_OLECREATE(CShellExt)
+ DECLARE_OLECREATE(CShellExt)
// IFileViewer interface
BEGIN_INTERFACE_PART(MenuExt, IContextMenu)
- STDMETHOD(QueryContextMenu)( HMENU hmenu,UINT indexMenu,UINT idCmdFirst,
- UINT idCmdLast,UINT uFlags);
+ STDMETHOD(QueryContextMenu)( HMENU hmenu,UINT indexMenu,UINT idCmdFirst,
+ UINT idCmdLast,UINT uFlags);
STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO lpici);
STDMETHOD(GetCommandString)(UINT_PTR idCmd,UINT uType,UINT* pwReserved,LPSTR pszName,
- UINT cchMax);
+ UINT cchMax);
END_INTERFACE_PART(MenuExt)
// IShellExtInit interface
STDMETHOD(IsMemberOf)(LPCWSTR pwszPath,DWORD dwAttrib);
END_INTERFACE_PART(IconExt)
- BEGIN_INTERFACE_PART(ToolTipExt, IQueryInfo)
- STDMETHOD(GetInfoTip)(DWORD dwFlags, LPWSTR *ppwszTip);
- STDMETHOD(GetInfoFlags)(LPDWORD pdwFlags);
+ BEGIN_INTERFACE_PART(ToolTipExt, IQueryInfo)
+ STDMETHOD(GetInfoTip)(DWORD dwFlags, LPWSTR *ppwszTip);
+ STDMETHOD(GetInfoFlags)(LPDWORD pdwFlags);
END_INTERFACE_PART(ToolTipExt)
- BEGIN_INTERFACE_PART(PersistFileExt, IPersistFile)
- STDMETHOD(Load)(LPCOLESTR wszFile, DWORD dwMode);
- STDMETHOD(GetClassID)(LPCLSID);
- STDMETHOD(IsDirty)(VOID);
- STDMETHOD(Save)(LPCOLESTR, BOOL);
- STDMETHOD(SaveCompleted)(LPCOLESTR);
- STDMETHOD(GetCurFile)(LPOLESTR FAR*);
+ BEGIN_INTERFACE_PART(PersistFileExt, IPersistFile)
+ STDMETHOD(Load)(LPCOLESTR wszFile, DWORD dwMode);
+ STDMETHOD(GetClassID)(LPCLSID);
+ STDMETHOD(IsDirty)(VOID);
+ STDMETHOD(Save)(LPCOLESTR, BOOL);
+ STDMETHOD(SaveCompleted)(LPCOLESTR);
+ STDMETHOD(GetCurFile)(LPOLESTR FAR*);
END_INTERFACE_PART(PersistFileExt)
- DECLARE_INTERFACE_MAP()
+ DECLARE_INTERFACE_MAP()
};
/////////////////////////////////////////////////////////////////////////////