📄 memplug.cpp
字号:
if(ppe->p.key.wVKey==VK_LEFT)
{
if( COMPILE_FLAG==0)
{
if(g_focusIconIndex>0)
{
g_focusIconIndex--;
}
else
{
bEnd=true;
}
}
else if( COMPILE_FLAG==1)
{
if(g_focusIconIndex>3)
{
g_focusIconIndex--;
}
else
{
bEnd=true;
}
}
else
{
if(g_focusIconIndex>5)
{
g_focusIconIndex--;
}
else
{
bEnd=true;
}
}
}
else
{
if( COMPILE_FLAG==0)
{
if(g_focusIconIndex<2)
{
g_focusIconIndex++;
}
else
{
bEnd=true;
}
}
else if( COMPILE_FLAG==1)
{
if(g_focusIconIndex<4)
{
g_focusIconIndex++;
}
else
{
bEnd=true;
}
}
else
{
if(g_focusIconIndex<7)
{
g_focusIconIndex++;
}
else
{
bEnd=true;
}
}
}
if(!bEnd)
{
index=g_focusIconIndex;
if(ERROR_SUCCESS!=RegOpenKeyEx(
HKEY_CLASSES_ROOT,
TEXT("IndexOfFocusIcon1"),
0,//DWORD ulOptions,
0,//REGSAM samDesired,
&hKey//PHKEY phkResult
))
{
}
if(ERROR_SUCCESS!=RegSetValueEx(hKey, TEXT("Index"), NULL, REG_DWORD, (const BYTE *)&index, sizeof(index)))
{
}
RegCloseKey(hKey);
g_bSecondTurn=false;
g_bFocusChange=true;
g_ballIndex=0;
m_ppe->InvalidatePlugin(m_hPlugin,0);
}
break;
// our plugin has been selected and clicked
case PE_ACTION:
if(g_focusIconIndex==7)
{
if(pi.hProcess!=NULL)
{
TerminateProcess(pi.hProcess, 0);
}
CreateProcess(
progName[g_focusIconIndex],//LPCWSTR lpszImageName,
NULL,//LPCWSTR lpszCmdLine,
NULL,//LPSECURITY_ATTRIBUTES lpsaProcess,
NULL,//LPSECURITY_ATTRIBUTES lpsaThread,
FALSE,//BOOL fInheritHandles,
0,//DWORD fdwCreate,
NULL,//LPVOID lpvEnvironment,
NULL,//LPWSTR lpszCurDir,
NULL,//LPSTARTUPINFOW lpsiStartInfo,
&pi//LPPROCESS_INFORMATION lppiProcInfo
);
}
else
{
SHELLEXECUTEINFO seiUpdateXIP;
WCHAR fileWithDir[100];
// Initialize seiUpdateXIP
memset(&seiUpdateXIP,0,sizeof(seiUpdateXIP));
seiUpdateXIP.cbSize = sizeof(seiUpdateXIP);
seiUpdateXIP.fMask = SEE_MASK_NOCLOSEPROCESS;
seiUpdateXIP.hwnd = 0;
seiUpdateXIP.lpVerb = 0;
wcscpy(fileWithDir,progName[g_focusIconIndex]);
seiUpdateXIP.lpFile = fileWithDir;
seiUpdateXIP.lpDirectory = 0;
if(g_focusIconIndex==3)//game
{
seiUpdateXIP.lpParameters = L"game";
}
else
{
seiUpdateXIP.lpParameters = NULL;
}
seiUpdateXIP.nShow = SW_SHOWNORMAL;
ShellExecuteEx(&seiUpdateXIP);
}
g_bFocusChange=false;
g_ballIndex=0;
m_ppe->SetSingleShotTimer(m_hPlugin,50);
break;
// we've recieved a paint message for our plugin, so we need
// to update and draw the memory usage status bar
case PE_PAINT:
hdc=ppe->p.paint.hdc;
if(ppe->p.paint.fSelected)
{
if(ERROR_SUCCESS!=RegOpenKeyEx(
HKEY_CLASSES_ROOT,
TEXT("IndexOfFocusIcon1"),
0,//DWORD ulOptions,
0,//REGSAM samDesired,
&hKey//PHKEY phkResult
))
{
}
if(ERROR_SUCCESS!=RegQueryValueEx(
hKey,//hKeyIndexOfFocusIcon,//hKeyLayerOfHomeSkin,//HKEY hKey,
TEXT("Index"),//LPCWSTR lpValueName,
NULL,//LPDWORD lpReserved,
&dataType,//LPDWORD lpType,
(BYTE *)&data,//LPBYTE lpData,
&dataSize//LPDWORD lpcbData
))
{
}
if( COMPILE_FLAG==0)
{
if(data>2)
{
if(data==3)
{
g_focusIconIndex=0;
}
else if(data==4)
{
g_focusIconIndex=2;
}
else//go to homescreen again from other place
{
if(data==5)
{
g_focusIconIndex=0;
}
else if(data==6)
{
g_focusIconIndex=1;
}
else if(data==7)
{
g_focusIconIndex=2;
}
else
{
}
}
index=g_focusIconIndex;
g_bSecondTurn=false;
g_bFocusChange=true;
g_ballIndex=0;
if(ERROR_SUCCESS!=RegSetValueEx(hKey, TEXT("Index"), NULL, REG_DWORD, (const BYTE *)&index, sizeof(index)))
{
}
}
}
else if( COMPILE_FLAG==1)
{
if(data<3)
{
if(data==0||data==1)
{
g_focusIconIndex=3;
}
else
{
g_focusIconIndex=4;
}
index=g_focusIconIndex;
g_bSecondTurn=false;
g_bFocusChange=true;
g_ballIndex=0;
if(ERROR_SUCCESS!=RegSetValueEx(hKey, TEXT("Index"), NULL, REG_DWORD, (const BYTE *)&index, sizeof(index)))
{
}
}
else if(data>4)
{
if(data==5||data==6)
{
g_focusIconIndex=3;
}
else
{
g_focusIconIndex=4;
}
index=g_focusIconIndex;
g_bSecondTurn=false;
g_bFocusChange=true;
g_ballIndex=0;
if(ERROR_SUCCESS!=RegSetValueEx(hKey, TEXT("Index"), NULL, REG_DWORD, (const BYTE *)&index, sizeof(index)))
{
}
}
else
{
}
}
else
{
if(data<5)
{
if(data==3)
{
g_focusIconIndex=5;
}
else
{
g_focusIconIndex=7;
}
index=g_focusIconIndex;
g_bSecondTurn=false;
g_bFocusChange=true;
g_ballIndex=0;
if(ERROR_SUCCESS!=RegSetValueEx(hKey, TEXT("Index"), NULL, REG_DWORD, (const BYTE *)&index, sizeof(index)))
{
}
}
}
RegCloseKey(hKey);
if(g_bFocusChange)
{
DrawAllIcons(hdc,(bool)ppe->p.paint.fSelected);
//draw the current local time and date
DrawTimeAndDate(hdc);
if(g_bSecondTurn)
{
g_ballIndex=0;
g_bFocusChange=false;
m_ppe->SetSingleShotTimer(m_hPlugin,5000);
break;
}
else
{
g_ballIndex++;
}
if(g_ballIndex>=TOTALBALLICON)
{
g_ballIndex=0;
g_bSecondTurn=true;
}
m_ppe->SetSingleShotTimer(m_hPlugin,350);
}
else
{
DrawAllIcons(hdc,ppe->p.paint.fSelected);
//draw the current local time and date
DrawTimeAndDate(hdc);
m_ppe->SetSingleShotTimer(m_hPlugin,5000);
}
}
else
{
DrawAllIcons(hdc,ppe->p.paint.fSelected);
//draw the current local time and date
DrawTimeAndDate(hdc);
m_ppe->SetSingleShotTimer(m_hPlugin,5000);
}
break;
case PE_SYSCOLORCHANGE:
m_ppe->InvalidatePlugin(m_hPlugin,0);
DebugOut(TEXT("PluginMem::OnEvent - got event PE_SYSCOLORCHANGE\r\n"));
break;
case PE_TIMER:
m_ppe->InvalidatePlugin(m_hPlugin,0);
DebugOut(TEXT("PluginMem::OnEvent - got event PE_TIMER\r\n"));
break;
case PE_DATACHANGE:
m_ppe->InvalidatePlugin(m_hPlugin,0);
DebugOut(TEXT("PluginMem::OnEvent - got event PE_DATACHANGE\r\n"));
break;
default:
break;
}
return(hr);
}
// **********************************************************************
// Function Name: GetClassID
//
// Purpose: Implementation of the IPersist::GetClassID method
//
HRESULT PluginMem::GetClassID(
CLSID* pClassID
)
{
CreateLogFile_CallStack("GetClassID");
*pClassID = CLSID_PLUGMEM;
return(S_OK);
}
// **********************************************************************
// Function Name: IsDirty
//
// Purpose: Trivial implementation of the IPersistStream::IsDirty
// method.
HRESULT PluginMem::IsDirty(void)
{
CreateLogFile_CallStack("IsDirty");
return(S_OK);
}
// **********************************************************************
// Function Name: Load
//
// Purpose: Called from the home.exe process to load plugin configuration
// data from an intermediate file.
//
// Arguments:
//
// IN IStream * pStm - pointer to the intermediate file's IStream
// interface
//
// Return Values:
//
// HRESULT - S_OK if Read operations succeed, E_FAIL otherwise
//
// Side effects:
// This function provides a quicker/safer method of loading data than
// using the XML DOM every time. It loads the data that was saved by the
// Plugin Manager when the plugin was initially loaded.
//
//
// Description:
//
// Implements IPersistStream's Load method, using the intermediate
// configuration file's IStream interface pointer to read plugin
// configuration data. In this sample, the only data we read is for
// the custom title, specified in the XML as the plugin's "name"
// attribute.
//
// See SDK documentation for more details
HRESULT PluginMem::Load(
IStream* pStm
)
{
CreateLogFile_CallStack("Load");
DebugOut(TEXT("PluginMem::Load - Called\r\n"));
// read the size first
if (FAILED(pStm->Read(&m_cbStrBytes, sizeof(m_cbStrBytes), 0)))
{
return E_FAIL;
}
// using the size in bytes (less one NULL char), allocate a BSTR
m_bstrTitle = SysAllocStringByteLen(NULL, m_cbStrBytes-sizeof(WCHAR));
if (m_bstrTitle == NULL)
{
return E_OUTOFMEMORY;
}
if (FAILED(pStm->Read(m_bstrTitle, m_cbStrBytes, 0)))
{
return E_FAIL;
}
if (FAILED(pStm->Read(&m_hPlugin, sizeof m_hPlugin, 0)))
{
return E_FAIL;
}
return(S_OK);
}
// **********************************************************************
// Function Name: Save
//
// Purpose: Called from the Plugin Manager process to save plugin
// configuration data to an intermediate file.
//
// Arguments:
//
// IN IStream * pStm - pointer to the intermediate file's IStream
// interface
//
// Return Values:
//
// HRESULT - S_OK if Write operations succeed, E_FAIL otherwise
//
// Side effects:
// This function provides a quicker/safer method of persisting data than
// using the XML DOM every time. The DOM data that was parsed from
// Initialize is saved to an intermediate file here, for quicker loading
// later.
//
// Description:
//
// Implements IPersistStream's Save method, using the intermediate file's
// IStream interface to write plugin configuration data. Since the data
// being written is stored as a BSTR, we write the size of the string in
// bytes to the stream first, then the actual string data
//
// See SDK documentation for more details
HRESULT PluginMem::Save(
IStream *pStm,
BOOL fClearDirty
)
{
CreateLogFile_CallStack("Save");
DebugOut(TEXT("PluginMem::Save - Called\r\n"));
// true to BSTR form, write the string length (in bytes) first
if (FAILED(pStm->Write(&m_cbStrBytes, sizeof(m_cbStrBytes), 0)))
{
return E_FAIL;
}
if (FAILED(pStm->Write(m_varTitle.bstrVal, m_cbStrBytes, 0)))
{
return E_FAIL;
}
if (FAILED(pStm->Write(&m_hPlugin, sizeof m_hPlugin, 0)))
{
return E_FAIL;
}
return(S_OK);
}
// **********************************************************************
// Function Name: GetSizeMax
//
// Purpose: Trivial implementation of IPersistStream's GetSizeMax method
HRESULT PluginMem::GetSizeMax(
ULARGE_INTEGER* pcbSize
)
{
CreateLogFile_CallStack("GetSizeMax");
ULONGLONG* pl = (ULONGLONG*)pcbSize;
*pl = 0;
return(S_OK);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -