ctxmenu.cpp
来自「PGP8.0源码 请认真阅读您的文件包然后写出其具体功能」· C++ 代码 · 共 1,608 行 · 第 1/3 页
CPP
1,608 行
{
pTC->ActionCode = PGP_CODE_EDIT_DISK;
}
else
{
pTC->ActionCode = PGP_CODE_WIPE;
}
hr = NOERROR;
break;
case 3:
pTC->ActionCode = PGP_CODE_ENCRYPT_SIGN;
hr = NOERROR;
break;
case 4:
pTC->ActionCode = PGP_CODE_WIPE;
hr = NOERROR;
break;
case 5:
pTC->ActionCode = PGP_CODE_CREATE_SDA;
hr = NOERROR;
break;
}
}
if((hr == NOERROR)&&(pTC->ActionCode!=0)) //We found a good 'un!
{
BOOL bOK;
bOK=TRUE;
pTC->Medium = medium;
if(PGPsc==0)
{
bOK=PGPscInit(NULL,&PGPsc,&PGPtls,
kPGPclEnableNewUserWizard |
kPGPclForceNewUserWizard);
if(!bOK)
{
PGPscDestroy(NULL,&PGPsc,&PGPtls);
PGPsc=NULL;
}
// For getting global windows messages
// g_hwndShell=ShellWindow();
}
if(PGPsc!=0)
{
_beginthread(CallPGPThread, 0, (void *) pTC);
}
else
{
ReleaseSemaphore(pTC->hPGPCTXSemaphore, 1, NULL);
CloseHandle(pTC->hPGPCTXSemaphore);
}
// encrypt
}
#ifdef NONCONCURRENT
}
else /*We only get here on wait timeout.*/
{
MessageBox(NULL,
"You may only perform PGP commands on one file at a "
"time using the PGP shell extension.",
"PGP Busy", MB_OK|MB_SETFOREGROUND|MB_ICONSTOP);
}
}
#endif
}
}
return hr;
}
void CallPGPThread(void *Arg)
{
if (hPGPThreadMutex == NULL)
hPGPThreadMutex = CreateMutex(NULL, TRUE, NULL);
else
WaitForSingleObject(hPGPThreadMutex, 0);
/*Make our own local copy so that when
*our parent expires, our data is still good:*/
PGPTHREADCONTROL *pTC = (PGPTHREADCONTROL *) Arg;
CallPGP(&(pTC->Medium), pTC->ActionCode);
#ifdef NONCONCURRENT
ReleaseSemaphore(pTC->hPGPCTXSemaphore, 1, NULL);
CloseHandle(pTC->hPGPCTXSemaphore);
#endif
free(pTC);
if (hPGPThreadMutex != NULL)
ReleaseMutex(hPGPThreadMutex);
_endthread();
}
//
// FUNCTION: CShellExt::GetCommandString(UINT idCmd,
// UINT uFlags,
// UINT FAR *reserved,
// LPSTR pszName,
// UINT cchMax)
//
// PURPOSE: Called by the shell as the mouse passes over a menu item.
// Displays a help string on the Explorer status bar.
//
STDMETHODIMP CShellExt::GetCommandString(UINT idCmd,
UINT uFlags,
UINT FAR *reserved,
LPSTR pszName,
UINT cchMax)
{
char msg[256];
OSVERSIONINFO Version;
ODS("CShellExt::GetCommandString()\r\n");
ODS("Max message length: ");
ODS(_ltoa(cchMax, msg, 10));
ODS("\r\n");
if(!strcmp(SubMenuType, "Directory"))
{
switch (idCmd)
{
case 0:
break;
case 1:
strcpy(msg, "Encrypt this file.");
break;
case 2:
strcpy(msg,"Sign this file.");
break;
case 3:
strcpy(msg,
"Encrypt this file and sign it with an encrypted signature.");
break;
case 4:
strcpy(msg,
"Decrypt this encrypted file.");
break;
case 5:
strcpy(msg,
"Secure wipe this file.");
break;
case 6:
strcpy(msg,
"Create an SDA with this file.");
break;
}
}
else if(!strcmp(SubMenuType, "Volume"))
{
switch (idCmd)
{
case 0:
break;
case 1:
strcpy(msg, "Encrypt the files on this volume.");
break;
case 2:
strcpy(msg,"Sign the files on this volume.");
break;
case 3:
strcpy(msg,
"Encrypt the files on this volume and sign them with an encrypted signature.");
break;
case 4:
strcpy(msg,
"Decrypt the encrypted files on this volume.");
break;
case 5:
strcpy(msg,
"Wipe the free space on this volume.");
break;
case 6:
strcpy(msg,
"Create an SDA with the files on this volume.");
break;
}
}
else
{
switch (idCmd)
{
case 0:
break;
case 1:
if (!strcmp(SubMenuType, "Encrypted"))
strcpy(msg, "Decrypt this encrypted file.");
else
if (!strcmp(SubMenuType, "Keyfile"))
strcpy(msg,
"Add keys from this file to the default public keyring.");
else
if (!strcmp(SubMenuType, "AddKeys"))
strcpy(msg, "Add the keys in this file to your keyring");
else
if (!strcmp(SubMenuType, "PGPdisk"))
{
if (m_NumFiles > 1)
strcpy(msg, "Mount/Unmount selected PGPdisks");
else if (m_IsMountedDisk)
strcpy(msg, "Unmount this PGPdisk");
else
strcpy(msg, "Mount this PGPdisk");
}
else
{
strcpy(msg, "Encrypt this file.");
}
break;
case 2:
if (!strcmp(SubMenuType, "Plaintext"))
strcpy(msg,
"Sign this file.");
else
if (!strcmp(SubMenuType, "PGPdisk"))
strcpy(msg,
"Edit this PGPdisk");
else
strcpy(msg,
"Secure wipe this file.");
break;
case 3:
strcpy(msg,
"Encrypt this file and sign it with an encrypted signature.");
break;
case 4:
strcpy(msg,
"Secure wipe this file.");
break;
case 5:
strcpy(msg,
"Create an SDA with this file.");
break;
}
}
ODS(msg);
ODS("\r\n");
// return the help string
// get OS type
Version.dwOSVersionInfoSize = (DWORD)(sizeof Version);
GetVersionEx(&Version);
if (Version.dwPlatformId == VER_PLATFORM_WIN32_NT) // if WIN NT
{
// first set empty string
MultiByteToWideChar(CP_ACP, 0, "", -1,
(LPWSTR)pszName, cchMax / 2);
// then convert string
if (cchMax / 2 > strlen(msg)) // if room for message
{
if (!(MultiByteToWideChar(CP_ACP, 0, msg, -1,
(LPWSTR)pszName, cchMax / 2)))
{
#ifdef _DEBUG
char buf1[40];
#endif
ODS("MultiByteToWideChar() failed.\r\n");
ODS("Error Code is: ");
ODS(_ltoa(GetLastError(), buf1, 10));
ODS("\r\n");
}
}
else
ODS("Buffer is not large enough for message.\r\n");
#ifdef _DEBUG
WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)pszName,
-1, msg, sizeof msg, NULL, NULL);
ODS(msg);
ODS("\r\n");
#endif
}
else // WIN 95
{
// make sure the help string isn't too long
// first set empty string
strcpy(pszName, "");
// then copy string if there's room
if (cchMax > strlen(msg)) // if buffer larger than string
strcpy(pszName, msg);
else
ODS("Buffer is not large enough for message.\r\n");
ODS(pszName);
ODS("\r\n");
}
return NOERROR;
}
void CShellExt::CreateEncryptedMenu(UINT idCmdFirst)
{
MENUITEMINFO ItemInfo;
char MText[64];
ItemInfo.cbSize = sizeof ItemInfo;
ItemInfo.fMask = MIIM_TYPE | MIIM_ID;
ItemInfo.fType = MFT_STRING;
ItemInfo.wID = idCmdFirst;
ItemInfo.hSubMenu = NULL;
ItemInfo.hbmpChecked = NULL;
ItemInfo.hbmpUnchecked = NULL;
ItemInfo.dwItemData = 0;
ItemInfo.dwTypeData = MText;
ItemInfo.cch = 0;
strcpy(SubMenuType, "Encrypted");
hSubMenu = CreatePopupMenu();
/*
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE;
ItemInfo.fState = MF_DISABLED; // for title line
strcpy(MText, "Pretty Good Privacy");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_SEPARATOR;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
*/
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID;
ItemInfo.fState = MFS_ENABLED; // for command lines
++ItemInfo.wID;
strcpy(MText, "&Decrypt && Verify");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType=MFT_SEPARATOR ;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_STRING;
++ItemInfo.wID;
strcpy(MText, "&Wipe");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
/*
++ItemInfo.wID;
strcpy(MText, "&Verify");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
*/
SubMenuItems = 3;
}
void CShellExt::CreateVerifyMenu(UINT idCmdFirst)
{
MENUITEMINFO ItemInfo;
char MText[64];
ItemInfo.cbSize = sizeof ItemInfo;
ItemInfo.wID = idCmdFirst;
ItemInfo.hSubMenu = NULL;
ItemInfo.hbmpChecked = NULL;
ItemInfo.hbmpUnchecked = NULL;
ItemInfo.dwItemData = 0;
ItemInfo.dwTypeData = MText;
ItemInfo.cch = 0;
strcpy(SubMenuType, "Verify");
hSubMenu = CreatePopupMenu();
/*
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE;
ItemInfo.fState = MF_DISABLED; // for title line
strcpy(MText, "Pretty Good Privacy");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_SEPARATOR;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
*/
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID;
ItemInfo.fState = MFS_ENABLED; // for command lines
++ItemInfo.wID;
strcpy(MText, "&Verify Signature");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType=MFT_SEPARATOR ;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_STRING;
++ItemInfo.wID;
strcpy(MText, "&Wipe");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
SubMenuItems = 3;
}
void CShellExt::CreateKeyfileMenu(UINT idCmdFirst)
{
MENUITEMINFO ItemInfo;
char MText[64];
ItemInfo.cbSize = sizeof ItemInfo;
ItemInfo.wID = idCmdFirst;
ItemInfo.hSubMenu = NULL;
ItemInfo.hbmpChecked = NULL;
ItemInfo.hbmpUnchecked = NULL;
ItemInfo.dwItemData = 0;
ItemInfo.dwTypeData = MText;
ItemInfo.cch = 0;
strcpy(SubMenuType, "Keyfile");
hSubMenu = CreatePopupMenu();
/*
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE;
ItemInfo.fState = MF_DISABLED; // for title line
strcpy(MText, "Pretty Good Privacy");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_SEPARATOR;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
*/
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID;
ItemInfo.fState = MFS_ENABLED; // for command lines
++ItemInfo.wID;
strcpy(MText, "&Add Keys to Keyring");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType=MFT_SEPARATOR ;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_STRING;
++ItemInfo.wID;
strcpy(MText, "&Wipe");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
SubMenuItems = 3;
}
void CShellExt::CreateViewKeyringMenu(UINT idCmdFirst)
{
MENUITEMINFO ItemInfo;
char MText[64];
ItemInfo.cbSize = sizeof ItemInfo;
ItemInfo.wID = idCmdFirst;
ItemInfo.hSubMenu = NULL;
ItemInfo.hbmpChecked = NULL;
ItemInfo.hbmpUnchecked = NULL;
ItemInfo.dwItemData = 0;
ItemInfo.dwTypeData = MText;
ItemInfo.cch = 0;
strcpy(SubMenuType, "AddKeys");
hSubMenu = CreatePopupMenu();
/*
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE;
ItemInfo.fState = MF_DISABLED; // for title line
strcpy(MText, "Pretty Good Privacy");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_SEPARATOR;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
*/
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID;
ItemInfo.fState = MFS_ENABLED; // for command lines
++ItemInfo.wID;
strcpy(MText, "&Add Keys to Keyring");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType=MFT_SEPARATOR ;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_STRING;
++ItemInfo.wID;
strcpy(MText, "&Wipe");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
SubMenuItems = 3;
}
void CShellExt::CreateDirectoryMenu(UINT idCmdFirst)
{
MENUITEMINFO ItemInfo;
char MText[64];
ItemInfo.cbSize = sizeof ItemInfo;
ItemInfo.wID = idCmdFirst;
ItemInfo.hSubMenu = NULL;
ItemInfo.hbmpChecked = NULL;
ItemInfo.hbmpUnchecked = NULL;
ItemInfo.dwItemData = 0;
ItemInfo.dwTypeData = MText;
ItemInfo.cch = 0;
strcpy(SubMenuType, "Directory");
hSubMenu = CreatePopupMenu();
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID;
ItemInfo.fState = MFS_ENABLED; // for command lines
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?