Ejemplo n.º 1
0
void CSubAction::GetCopyFrom(DWORD nAction,CSubAction& rCopyFrom)
{
	CopyMemory(this,&rCopyFrom,sizeof(CSubAction));

	switch (nAction)
	{
	case CAction::ResultListItems:
		if (m_nResultList==Execute && m_szVerb!=NULL)
			m_szVerb=alloccopy(m_szVerb);
		else if (m_nResultList==ExecuteCommand && m_szCommand!=NULL)
			m_szCommand=alloccopy(m_szCommand);
		break;
	case CAction::Misc:
		if ((m_nMisc==SendMessage || m_nMisc==PostMessage ) &&
			m_pSendMessage!=NULL)
			m_pSendMessage=new SendMessageInfo(*m_pSendMessage);
		else if (m_nMisc==ExecuteCommandMisc && m_szCommand!=NULL)
			m_szCommand=alloccopy(m_szCommand);
		break;
	case CAction::Presets:
	case CAction::ChangeValue:
		if (m_szPreset!=NULL)
			m_szPreset=alloccopy(m_szPreset);
		break;
	}
	
}
Ejemplo n.º 2
0
CSubAction::SendMessageInfo::SendMessageInfo(SendMessageInfo& rCopyFrom)
{
	CopyMemory(this,&rCopyFrom,sizeof(SendMessageInfo));

	if (szWindow!=NULL)
		szWindow=alloccopy(szWindow);
	if (szWParam!=NULL)
		szWParam=alloccopy(szWParam);
	if (szLParam!=NULL)
		szLParam=alloccopy(szLParam);
}
Ejemplo n.º 3
0
CShortcut::CShortcut(CShortcut& rCopyFrom)
{
	CopyMemory(this,&rCopyFrom,sizeof(CShortcut));

	if ((m_dwFlags&sfKeyTypeMask)!=sfLocal)
	{
		if (m_pClass!=NULL && m_pClass!=LPSTR(-1))
			m_pClass=alloccopy(m_pClass);
		if (m_pTitle!=NULL)
			m_pTitle=alloccopy(m_pTitle);
	}

	for (int i=0;i<m_apActions.GetSize();i++)
		m_apActions[i]=new CAction(*m_apActions[i]);
}
Ejemplo n.º 4
0
LPSTR ShellFunctions::StrRetToPtr(STRRET& strret,LPITEMIDLIST lpiil)
{
	LPSTR pRet=NULL;
	switch (strret.uType)
	{
	case STRRET_OFFSET:
		pRet=alloccopy((LPSTR)((LPBYTE)lpiil+strret.uOffset));
		break;
	case STRRET_CSTR:
		pRet=alloccopy(strret.cStr);
		break;
	case STRRET_WSTR:
		pRet=alloccopyWtoA(strret.pOleStr);
		CoTaskMemFree(strret.pOleStr);
		break;
	}	
	return pRet;
}
Ejemplo n.º 5
0
LPITEMIDLIST ShellFunctions::GetIDListForParent(LPCWSTR lpszFileName)
{
	int temp=LastCharIndex(lpszFileName,L'\\');
	LPCWSTR szFolder;
	if (temp==-1)
		szFolder=alloccopy(lpszFileName);
	else
		szFolder=alloccopy(lpszFileName,temp+1);
	
	LPITEMIDLIST pidl=NULL;
	IShellFolder *pDesktop;
	if (FAILED(SHGetDesktopFolder(&pDesktop)))
	{
		delete[] szFolder;
		return NULL;
	}
	
	HRESULT hRes=pDesktop->ParseDisplayName(NULL,NULL,(LPOLESTR)szFolder,NULL,&pidl,NULL);
	pDesktop->Release();
	
	return FAILED(hRes)?NULL:pidl;
}
Ejemplo n.º 6
0
void SetRegKey(int argc,wchar_t* argv[])
{
	CString Branch;

	int i;
	for (i=1;i<argc;i++)
	{
		if (argv[i][0]==L'-' || argv[i][0]==L'/')
		{
			switch (argv[i][1])
			{
	        case L'X':
				if (argv[i][2]==L'\0')
				{
					if (i<argc-1)
						Branch=argv[++i];
				}
				else
	                   Branch=(argv[i]+2);
				break;
			}
		}
	}
	
	
	g_szRegKey=ReadIniFile(&g_szRegFile,Branch.GetPData(),g_bFileIsReg);
	
	if (g_szRegKey!=NULL)
	{
		if (g_szRegFile!=NULL)
			LoadSettingsFromFile(g_szRegKey,g_szRegFile,g_bFileIsReg);
	}
	else
	{
		// Use default
		g_szRegKey=alloccopy("Software\\Update");
	}

}
Ejemplo n.º 7
0
BOOL GetIMAPIBurningDevices(CArray<LPWSTR>& aDevicePaths)
{
	CRegKey RegKey;
	if (RegKey.OpenKey(HKCR,"IMAPI.MSDiscMasterObj\\CLSID",CRegKey::defRead)!=ERROR_SUCCESS)
		return FALSE;

	WCHAR szCLSID[50];
	if (RegKey.QueryValue(L"",szCLSID,50)==0)
		return FALSE;

	CLSID clsid;
	if (CLSIDFromString(szCLSID,&clsid)!=NO_ERROR)
		return FALSE;

	
	HRESULT hRes;
	IDiscMaster* pdm;
	hRes=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER,IID_IDiscMaster,(void**)&pdm);
	if (FAILED(hRes))
		return FALSE;

	hRes=pdm->Open();
	if (FAILED(hRes))
	{
		pdm->Release();
		return FALSE;
	}

	IEnumDiscRecorders* pedr;
	hRes=pdm->EnumDiscRecorders(&pedr);
	if (SUCCEEDED(hRes))
	{
		IDiscRecorder* pdr;
		DWORD dwReturned;
		while ((hRes=pedr->Next(1,&pdr,&dwReturned))==S_OK)
		{
			BSTR bPath;
			hRes=pdr->GetPath(&bPath);
			if (SUCCEEDED(bPath))
			{
				if (bPath[0]=='\\')
				{
					WCHAR szName[MAX_PATH];
					WCHAR szTemp[MAX_PATH]=L"";
					WCHAR drive[]=L" :";
					GetLogicalDriveStringsW(MAX_PATH,szTemp);

					LPWSTR pPtr=szTemp;
					while (*pPtr!='\0')
					{
						*drive=*pPtr;
						if (QueryDosDeviceW(drive, szName,MAX_PATH))
						{
							if (wcscmp(szName,bPath)==0)
								aDevicePaths.Add(alloccopy(pPtr));
						}

						pPtr+=istrlenw(pPtr)+1;
					}
				}
				else
					aDevicePaths.Add(alloccopy(bPath));
			}

			pdr->Release();
		}
		pedr->Release();
	}


	pdm->Close();
	pdm->Release();

	return TRUE;
}
Ejemplo n.º 8
0
int wmain (int argc,wchar_t ** argv)
{
	CAppData::stdfunc();
	
	SetRegKey(argc,argv);

	if (!SetLanguageSpecifigHandles(argv[0]))
		return 1;

	CArrayFP<CDatabase*> aDatabases;
	
	WORD wCurrentThread=0;

	aDatabases.Add(CDatabase::FromDefaults(TRUE));
	aDatabases[0]->SetNamePtr(alloccopy(L"DEFAULTX"));
	aDatabases[0]->SetThreadId(wCurrentThread);

    int i,helps=0;
#ifndef WIN32
    if (getenv("TZ")==NULL)
		fprintf(stderr,"Timezone is not set. Database may contain invalid file times.\nFor example type "SET TZ=GMT+1" for central european time.\n");
#endif
    for (i=1;i<argc;i++)
    {
        if (argv[i][0]=='-' || argv[i][0]=='/')
        {
            switch (argv[i][1])
			{
			case L'X':
				if (argv[i][2]==L'\0')
				{
					if (i<argc-1)
						i++; // RegKeyName already set
				}
				break;
			case 'l':
			case 'L':
				if (wcsncmp(aDatabases.GetLast()->GetName(),L"PARAMX",6)!=0 && 
					wcsncmp(aDatabases.GetLast()->GetName(),L"DEFAULTX",8)!=0)
					wprintf(ID2W(IDS_UPDATEDB32CANNOTCHANGELOADED),aDatabases.GetLast()->GetName());
				else if (argv[i][2]=='1')
				{
					aDatabases.GetLast()->AddLocalRoots();
					aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX"));
				}
				else 
				{
					CStringW* pStr;
					if (argv[i][2]==L'\0' && i+1<argc)
						pStr=new CStringW(argv[++i]);
					else
						pStr=new CStringW(argv[i]+2);
					
					if ((*pStr)[0]==L'\"')
						pStr->DelChar(0);
					if (pStr->LastChar()==L'\"')
						pStr->DelLastChar();
					while (pStr->LastChar()==L'\\')
						pStr->DelLastChar();
					
					if (pStr->GetLength()>1)
					{
						if ((*pStr)[1]==':' && pStr->GetLength()==2)
							aDatabases.GetLast()->AddRoot(pStr->GiveBuffer());
						else if (FileSystem::IsDirectory(*pStr))
							aDatabases.GetLast()->AddRoot(pStr->GiveBuffer());
						else
							fwprintf(stderr,ID2W(IDS_UPDATEDB32DIRECTORYISNOTVALID),(LPCWSTR)*pStr);
					}
					else
						fwprintf(stderr,ID2W(IDS_UPDATEDB32DIRECTORYISNOTVALID),(LPCWSTR)*pStr);
					delete pStr;

					aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX"));
				}
				break;
			case 'e':
				if (wcsncmp(aDatabases.GetLast()->GetName(),L"PARAMX",6)!=0 && 
					wcsncmp(aDatabases.GetLast()->GetName(),L"DEFAULTX",8)!=0)
					wprintf(ID2W(IDS_UPDATEDB32CANNOTCHANGELOADED),aDatabases.GetLast()->GetName());
				else 
				{
					CStringW* pStr;
					if (argv[i][2]=='\0' && i+1<argc)
						pStr=new CStringW(argv[++i]);
					else
						pStr=new CStringW(argv[i]+2);
					
					if ((*pStr)[0]==L'\"')
						pStr->DelChar(0);
					if (pStr->LastChar()==L'\"')
						pStr->DelLastChar();
					while (pStr->LastChar()==L'\\')
						pStr->DelLastChar();
					
					if (pStr->GetLength()>0)
						aDatabases.GetLast()->SetExcludedFiles(*pStr);

					aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX"));
				}
				break;
			case 'E':
				if (wcsncmp(aDatabases.GetLast()->GetName(),L"PARAMX",6)!=0 && 
					wcsncmp(aDatabases.GetLast()->GetName(),L"DEFAULTX",8)!=0)
					wprintf(ID2W(IDS_UPDATEDB32CANNOTCHANGELOADED),aDatabases.GetLast()->GetName());
				else 
				{
					CStringW* pStr;
					if (argv[i][2]=='\0' && i+1<argc)
						pStr=new CStringW(argv[++i]);
					else
						pStr=new CStringW(argv[i]+2);
					
					if ((*pStr)[0]==L'\"')
						pStr->DelChar(0);
					if (pStr->LastChar()==L'\"')
						pStr->DelLastChar();
					while (pStr->LastChar()==L'\\')
						pStr->DelLastChar();
					
					if (pStr->GetLength()>1)
					{
						if (!aDatabases.GetLast()->AddExcludedDirectory(*pStr))
							fwprintf(stderr,ID2W(IDS_UPDATEDB32DIRECTORYISNOTVALID),(LPCWSTR)*pStr);
					}
					else
						fwprintf(stderr,ID2W(IDS_UPDATEDB32DIRECTORYISNOTVALID),(LPCWSTR)*pStr);
					delete pStr;

					aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX"));
				}
				break;
			case 't':
			case 'T':
				if (wcsncmp(aDatabases.GetLast()->GetName(),L"PARAMX",6)!=0 &&
					wcsncmp(aDatabases.GetLast()->GetName(),L"DEFAULTX",8)!=0)
					wprintf(ID2W(IDS_UPDATEDB32CANNOTCHANGELOADED),aDatabases.GetLast()->GetName());
				else if (argv[i][2]==L'c' || argv[i][2]==L'C')
				{
                       if (argv[i][3]==L'\0')
                           aDatabases.GetLast()->SetCreatorPtr(alloccopy(argv[++i]));
                       else
                           aDatabases.GetLast()->SetCreatorPtr(alloccopy(argv[i]+2));

					   aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX"));
				}
				else if (argv[i][2]==L'd' || argv[i][2]==L'D')
				{
                       if (argv[i][3]==L'\0')
                           aDatabases.GetLast()->SetDescriptionPtr(alloccopy(argv[++i]));
                       else
                           aDatabases.GetLast()->SetDescriptionPtr(alloccopy(argv[i]+2));

					   aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX"));
				}
				break;
			case 'i':
			case 'I':
				if (wcsncmp(aDatabases.GetLast()->GetName(),L"PARAMX",6)!=0 &&
					wcsncmp(aDatabases.GetLast()->GetName(),L"DEFAULTX",8)!=0)
					wprintf(ID2W(IDS_UPDATEDB32CANNOTCHANGELOADED),aDatabases.GetLast()->GetName());
				else
				{
                    aDatabases.GetLast()->SetFlag(CDatabase::flagIncrementalUpdate,TRUE);
					aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX"));
				}
				break;
			case 'c':
			case 'C':
				if (wcsncmp(aDatabases.GetLast()->GetName(),L"PARAMX",6)!=0 &&
					wcsncmp(aDatabases.GetLast()->GetName(),L"DEFAULTX",8)!=0)
					wprintf(ID2W(IDS_UPDATEDB32CANNOTCHANGELOADED),aDatabases.GetLast()->GetName());
				else if (argv[i][2]==L'A' || argv[i][2]==L'a')
				{
					aDatabases.GetLast()->SetFlag(CDatabase::flagAnsiCharset,TRUE);
					aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX"));
				}
				else if (argv[i][2]==L'U' || argv[i][2]==L'u')
				{
					aDatabases.GetLast()->SetFlag(CDatabase::flagAnsiCharset,FALSE);
					aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX"));
				}
				
				break;
			case 'N':
			case 'n':
				wCurrentThread++;
				break;
			case 'q':
			case 'Q':
				nQuiet=TRUE;
				break;
			case 'v':
			case 'V':
				printf("%s\n",szVersionStr);
				return 0;
			case 'd':
				{
					// Using database file
					CStringW sFile;
					if (argv[i][2]=='\0')
						sFile=argv[++i];
					else
						sFile=(argv[i]+2);
					
					if (aDatabases.GetSize()==1 && wcscmp(aDatabases[0]->GetName(),L"DEFAULTX")==0)
					{
						aDatabases[0]->SetNamePtr(alloccopy(L"PARAMX"));
						aDatabases[0]->SetArchiveNamePtr(sFile.GiveBuffer());
					}
					else 
					{
						CDatabase* pDatabase=CDatabase::FromFile(sFile,(int)sFile.GetLength());
						if (pDatabase!=NULL)
						{
                            aDatabases.Add(pDatabase);
							pDatabase->SetNamePtr(alloccopy(L"PARAMX"));
							pDatabase->SetThreadId(wCurrentThread);
						}
					}
					

			
				}
				break;
			case 'D':
				{
					// Loading database 'name' from registry, cannot be changed 
					CStringW sName;
					if (argv[i][2]=='\0')
						sName=argv[++i];
					else
						sName=(argv[i]+2);

					if (CDatabase::FindByName(aDatabases,sName,(int)sName.GetLength())==NULL)
					{
						CDatabase* pDatabase=CDatabase::FromName(HKCU,
							CString(g_szRegKey)+"\\Databases",sName);

						if (pDatabase!=NULL)
						{
							pDatabase->SetFlag(CDatabase::flagGlobalUpdate);
							// Is only default loaded
							if (aDatabases.GetSize()==1 && wcscmp(aDatabases[0]->GetName(),L"DEFAULTX")==0)
							{
								delete aDatabases[0];
								aDatabases[0]=pDatabase;
							}
							else
							{
								aDatabases.Add(pDatabase);
								pDatabase->SetThreadId(wCurrentThread);
							}
						}
					}
				}
				break;
			case 'h':
			case 'H':
			case '?':
				helps=1;
				break;
			default:
				helps=1;
				break;
			}
       }
    }
    if (helps==1)
    {
#ifdef WIN32
		fprintf(stdout,"%s\n",szVersionStr);
#else
        fprintf(stdout,"%s\nusage updatedb",szVersionStr);
#endif

		HRSRC hRc=FindResource(GetLanguageSpecificResourceHandle(),MAKEINTRESOURCE(IDR_UPDATEDBHELP),"HELPTEXT");
		HGLOBAL hGlobal=LoadResource(GetLanguageSpecificResourceHandle(),hRc);
		LPCSTR pStr=(LPCSTR)LockResource(hGlobal);

		// Counting length
		int len;
		for (len=0;pStr[len]!='\0';len++)
		{
			if (pStr[len]=='E' && pStr[len+1]=='O' && pStr[len+2]=='F')
				break;
		}


		fwrite(pStr,1,len,stdout);
		
		FreeLibrary(GetLanguageSpecificResourceHandle());
		return 1;
    }

	// Checking databases
	// First, check that there is database 
	if (aDatabases.GetSize()==0)
		CDatabase::LoadFromRegistry(HKCU,CString(g_szRegKey)+"\\Databases",aDatabases);   
	else if (aDatabases.GetSize()==1 && wcsncmp(aDatabases[0]->GetName(),L"DEFAULTX",8)==0)
	{
		aDatabases.RemoveAll();
		CDatabase::LoadFromRegistry(HKCU,CString(g_szRegKey)+"\\Databases",aDatabases);   

		// No registry values?
		if (aDatabases.GetSize()==0)
		{
			aDatabases.Add(CDatabase::FromDefaults(TRUE));
			aDatabases[0]->SetNamePtr(alloccopy(L"DEFAULTX"));
		}
	}
		
		
	CDatabase::CheckValidNames(aDatabases);
	CDatabase::CheckDoubleNames(aDatabases);
	
	
	for (int i=0;i<aDatabases.GetSize();)
	{
		if (!aDatabases[i]->IsGloballyUpdated())
			aDatabases.RemoveAt(i);
		else 
		{
			if ((wcsncmp(aDatabases[i]->GetName(),L"PARAMX",6)==0 ||
				wcsncmp(aDatabases[i]->GetName(),L"DEFAULTX",8)==0))
			{
				BOOL bNameChanged=FALSE;
				if (aDatabases[i]->GetRoots()==0)
				{
					BOOL bFree;
					LPWSTR pFile=aDatabases[i]->GetResolvedArchiveName(bFree);
					CDatabaseInfo* pDatabaseInfo=CDatabaseInfo::GetFromFile(pFile);
					if (bFree)
						delete[] pFile;
					if (pDatabaseInfo!=NULL)
					{
						CDatabase* pDatabase;
						if (!pDatabaseInfo->sExtra2.IsEmpty())
							pDatabase=CDatabase::FromExtraBlock(pDatabaseInfo->sExtra2);
						if (pDatabase==NULL && !pDatabaseInfo->sExtra1.IsEmpty())
							pDatabase=CDatabase::FromExtraBlock(pDatabaseInfo->sExtra1);
						
						wprintf(ID2W(IDS_UPDATEDB32USINGEXISTINGSETTINGS),
							aDatabases[i]->GetArchiveName(),pDatabase->GetName());
						
						pDatabase->SetArchiveType(aDatabases[i]->GetArchiveType());
						pDatabase->SetArchiveName(aDatabases[i]->GetArchiveName());
						
						delete aDatabases[i];
						aDatabases[i]=pDatabase;

						delete pDatabaseInfo;
						bNameChanged=TRUE;
					}
				}

				if (!bNameChanged)
				{
					ULONG_PTR nFirst=LastCharIndex(aDatabases[i]->GetArchiveName(),L'\\')+1;
					int nLength=LastCharIndex(aDatabases[i]->GetArchiveName()+nFirst,L'.');
					if (nLength==-1)
						nLength=istrlenw(aDatabases[i]->GetArchiveName()+nFirst);

					

					aDatabases[i]->SetNamePtr(alloccopy(aDatabases[i]->GetArchiveName()+nFirst,nLength));
				}
			}

			
			i++;
		}
	}

	// Starting to update
	WORD dwTheads=CDatabase::CheckIDs(aDatabases);
    if (dwTheads==0)
	{
		FreeLibrary(GetLanguageSpecificResourceHandle());
		return FALSE;
	}
	if (dwTheads==1)
	{
		CDatabaseUpdater Updater(aDatabases,aDatabases.GetSize(),UpdateProc);
		Updater.Update(FALSE);
	}
	else
	{
		WORD wThread;

		ppUpdaters=new CDatabaseUpdater*[dwTheads+1];

		for (wThread=0;wThread<dwTheads;wThread++)
		{
			ppUpdaters[wThread]=new CDatabaseUpdater(aDatabases,aDatabases.GetSize(),							
				UpdateProc,wThread,(DWORD)0);
		}
		ppUpdaters[dwTheads]=NULL;

		// Starting
		DWORD dwRunning=0;
		UpdateError ueCode;
		for (wThread=0;wThread<dwTheads;wThread++)
		{
			ueCode=ppUpdaters[wThread]->Update(TRUE);
			if (ueCode==ueSuccess)
				dwRunning++;
			else
			{
				delete ppUpdaters[wThread];
				ppUpdaters[wThread]=UPDATER_EXITED(ueCode);
			}
		}
		
		if (dwRunning==0)
			delete ppUpdaters;
		else
		{
			while (ppUpdaters!=NULL)
				Sleep(100);
		}
	}

	FinishRegKey();

	FreeLibrary(GetLanguageSpecificResourceHandle());

	return 1;
}
Ejemplo n.º 9
0
CShortcut::VirtualKeyName* CShortcut::GetVirtualKeyNames()
{
	VirtualKeyName aVirtualKeys[]={
		{VK_BACK,"VK_BACK",IDS_KEYBACKSPACE},
		{VK_ESCAPE,"VK_ESCAPE",IDS_KEYESC},
		{VK_TAB,"VK_TAB",IDS_KEYTAB},
		{VK_CAPITAL,"VK_CAPITAL",IDS_KEYCAPSLOCK},
		{VK_RETURN,"VK_RETURN",IDS_KEYENTER},
		{VK_SPACE,"VK_SPACE",IDS_KEYSPACE},
		{VK_PRIOR,"VK_PRIOR",IDS_KEYPAGEUP},
		{VK_NEXT,"VK_NEXT",IDS_KEYPAGEDOWN},
		{VK_END,"VK_END",IDS_KEYEND},
		{VK_HOME,"VK_HOME",IDS_KEYHOME},
		{VK_LEFT,"VK_LEFT",IDS_KEYLEFT},
		{VK_UP,"VK_UP",IDS_KEYUP},
		{VK_RIGHT,"VK_RIGHT",IDS_KEYRIGHT},
		{VK_DOWN,"VK_DOWN",IDS_KEYDOWN},
		{VK_SNAPSHOT,"VK_SNAPSHOT",IDS_KEYPRINTSCREEN},
		{VK_SCROLL,"VK_SCROLL",IDS_KEYSCROLLLOCK},
		{VK_PAUSE,"VK_PAUSE",IDS_KEYPAUSE},
		{VK_INSERT,"VK_INSERT",IDS_KEYINS},
		{VK_DELETE,"VK_DELETE",IDS_KEYDEL},
		{VK_NUMLOCK,"VK_NUMLOCK",IDS_KEYNUMLOCK},
		{VK_NUMPAD0,"VK_NUMPAD0",IDS_KEYNUM0},
		{VK_NUMPAD1,"VK_NUMPAD1",IDS_KEYNUM1},
		{VK_NUMPAD2,"VK_NUMPAD2",IDS_KEYNUM2},
		{VK_NUMPAD3,"VK_NUMPAD3",IDS_KEYNUM3},
		{VK_NUMPAD4,"VK_NUMPAD4",IDS_KEYNUM4},
		{VK_NUMPAD5,"VK_NUMPAD5",IDS_KEYNUM5},
		{VK_NUMPAD6,"VK_NUMPAD6",IDS_KEYNUM6},
		{VK_NUMPAD7,"VK_NUMPAD7",IDS_KEYNUM7},
		{VK_NUMPAD8,"VK_NUMPAD8",IDS_KEYNUM8},
		{VK_NUMPAD9,"VK_NUMPAD9",IDS_KEYNUM9},
		{VK_MULTIPLY,"VK_MULTIPLY",IDS_KEYNUMMUL},
		{VK_ADD,"VK_ADD",IDS_KEYNUMADD},
		{VK_SEPARATOR,"VK_SEPARATOR",0},
		{VK_SUBTRACT,"VK_SUBTRACT",IDS_KEYNUMSUB},
		{VK_DECIMAL,"VK_DECIMAL",IDS_KEYNUMDECIMAL},
		{VK_DIVIDE,"VK_DIVIDE",IDS_KEYNUMDIV},
		{VK_F1,"VK_F1",IDS_KEYF1},
		{VK_F2,"VK_F2",IDS_KEYF2},
		{VK_F3,"VK_F3",IDS_KEYF3},
		{VK_F4,"VK_F4",IDS_KEYF4},
		{VK_F5,"VK_F5",IDS_KEYF5},
		{VK_F6,"VK_F6",IDS_KEYF6},
		{VK_F7,"VK_F7",IDS_KEYF7},
		{VK_F8,"VK_F8",IDS_KEYF8},
		{VK_F9,"VK_F9",IDS_KEYF9},
		{VK_F10,"VK_F10",IDS_KEYF10},
		{VK_F11,"VK_F11",IDS_KEYF11},
		{VK_F12,"VK_F12",IDS_KEYF12},
		{VK_F13,"VK_F13",IDS_KEYF13},
		{VK_F14,"VK_F14",IDS_KEYF14},
		{VK_F15,"VK_F15",0},
		{VK_F16,"VK_F16",0},
		{VK_F17,"VK_F17",0},
		{VK_F18,"VK_F18",0},
		{VK_F19,"VK_F19",0},
		{VK_F20,"VK_F20",0},
		{VK_F21,"VK_F21",0},
		{VK_F22,"VK_F22",0},
		{VK_F23,"VK_F23",0},
		{VK_F24,"VK_F24",0}
	};

	VirtualKeyName* pRet=new VirtualKeyName[sizeof(aVirtualKeys)/sizeof(VirtualKeyName)+1];

	int i;
	for (i=0;i<sizeof(aVirtualKeys)/sizeof(VirtualKeyName);i++)
	{
		pRet[i].bKey=aVirtualKeys[i].bKey;
		pRet[i].pName=alloccopy(aVirtualKeys[i].pName);
		pRet[i].iFriendlyNameId=aVirtualKeys[i].iFriendlyNameId;
	}
	pRet[i].bKey=0;
	pRet[i].pName=NULL;
	pRet[i].iFriendlyNameId=0;
    return pRet;
}
Ejemplo n.º 10
0
void CSubAction::DoMisc()
{
	if (m_nMisc==ExecuteCommandMisc)
	{
		if (m_szCommand!=NULL)
			CLocateDlg::ExecuteCommand(m_szCommand);
		return;
	}
	else if (m_nMisc==InsertAsterisks)
	{
		CLocateDlg* pLocateDlg=GetLocateDlg();
		if (pLocateDlg==NULL)
			return;

		CStringW Text;
		pLocateDlg->m_NameDlg.m_Name.GetText(Text);
		DWORD dwSelStart=pLocateDlg->m_NameDlg.m_Name.GetEditSel();
		WORD wSelEnd=HIWORD(dwSelStart);
		dwSelStart&=0xFFFF;

		// If asterisks are already at the beginning and the end, replace spaces
		if (Text[0]==L'*' && Text.LastChar()==L'*')
			Text.ReplaceChars(L' ',L'*');
		else 
		{
			if (Text[0]!=L'*')
			{
				Text.InsChar(0,L'*');
				
				// Update selection
				if (dwSelStart==wSelEnd)
				{
					dwSelStart++;
					wSelEnd++;
				}
				else 
				{
					if (dwSelStart>0)
						dwSelStart++;
					wSelEnd++;
				}
			}
			
			if (Text.LastChar()!=L'*')
			{
				// Update selection first
				if (wSelEnd==Text.GetLength())
				{
					if (dwSelStart==wSelEnd)
						dwSelStart++;
					wSelEnd++; 
				}

				Text.Append(L'*');
			}
		}

		pLocateDlg->m_NameDlg.m_Name.SetText(Text);
		pLocateDlg->m_NameDlg.m_Name.SetEditSel(dwSelStart,wSelEnd);
		pLocateDlg->OnFieldChange(CLocateDlg::isNameChanged);
		return;
	}
	

	// Send/Post Message

	BOOL bFreeWParam=FALSE,bFreeLParam=FALSE;
	
	HWND hWnd=NULL;
	WPARAM wParam=NULL,lParam=NULL;

	if (m_pSendMessage->szWindow[0]=='0')
	{
		if (m_pSendMessage->szWindow[1]=='x' || 
			m_pSendMessage->szWindow[1]=='X')
		{
			// Hex value
			LPWSTR szTemp;
			hWnd=(HWND)wcstoul(m_pSendMessage->szWindow+2,&szTemp,16);
		}
	}
	else if (strcasecmp(m_pSendMessage->szWindow,L"HWND_BROADCAST")==0)
		hWnd=HWND_BROADCAST;
	else if (GetLocateDlg()!=NULL && strcasecmp(m_pSendMessage->szWindow,L"LOCATEDLG")==0)
		hWnd=*GetLocateDlg();
	else if (strcasecmp(m_pSendMessage->szWindow,L"LOCATEST")==0)
		hWnd=*GetTrayIconWnd();
	else if (wcsncmp(m_pSendMessage->szWindow,L"Find",4)==0)
	{
		int nIndex=(int)FirstCharIndex(m_pSendMessage->szWindow,L'(');
		if (nIndex!=-1)
		{
			LPCWSTR pText=m_pSendMessage->szWindow+nIndex+1;
			LPWSTR pClassAndWindow[3]={NULL,NULL,NULL};
			
			nIndex=(int)FirstCharIndex(pText,L',');
			if (nIndex==-1)
			{
				nIndex=(int)FirstCharIndex(pText,L')');
				if (nIndex==-1)
					pClassAndWindow[0]=alloccopy(pText);
				else
					pClassAndWindow[0]=alloccopy(pText,nIndex);
			}
			else
			{
				pClassAndWindow[0]=alloccopy(pText,nIndex);
				pText+=nIndex+1;

				nIndex=(int)FirstCharIndex(pText,L')');
				pClassAndWindow[1]=alloccopy(pText,nIndex);
			}

			EnumWindows(WindowEnumProc,LPARAM(pClassAndWindow));

			// Third cell is handle to window
			hWnd=(HWND)pClassAndWindow[2];

			delete[] pClassAndWindow[0];
			if (pClassAndWindow[1])
				delete[] pClassAndWindow[1];
		}
	}
	


	// Parse wParam
	if (m_pSendMessage->szWParam!=NULL)
	{
		if (m_pSendMessage->szWParam[0]=='0')
		{
			if (m_pSendMessage->szWParam[1]=='x' || 
				m_pSendMessage->szWParam[1]=='X')
			{
				// Hex value
				LPWSTR szTemp;
				wParam=(WPARAM)wcstoul(m_pSendMessage->szWParam+2,&szTemp,16);
			}
			else if (m_pSendMessage->szWParam[1]!='\0')
			{
				DWORD dwLength;
				wParam=(WPARAM)dataparser(m_pSendMessage->szWParam,istrlen(m_pSendMessage->szWParam),gmalloc,&dwLength);
				*((BYTE*)wParam+dwLength)=0;
				bFreeWParam=TRUE;
			}
		}
		else if ((wParam=_wtoi(m_pSendMessage->szWParam))==0)
		{
			DWORD dwLength;
			wParam=(WPARAM)dataparser(m_pSendMessage->szWParam,istrlen(m_pSendMessage->szWParam),gmalloc,&dwLength);
			*((BYTE*)wParam+dwLength)=0;
			bFreeWParam=TRUE;
		}
	}

	// Parse lParam
	if (m_pSendMessage->szLParam!=NULL)
	{
		if (m_pSendMessage->szLParam[0]=='0')
		{
			if (m_pSendMessage->szLParam[1]=='x' || 
				m_pSendMessage->szLParam[1]=='X')
			{
				// Hex value
				LPWSTR szTemp;
				lParam=(WPARAM)wcstoul(m_pSendMessage->szLParam+2,&szTemp,16);
			}
			else if (m_pSendMessage->szLParam[1]!='\0')
			{
				DWORD dwLength;
				lParam=(WPARAM)dataparser(m_pSendMessage->szLParam,istrlen(m_pSendMessage->szLParam),gmalloc,&dwLength);
				*((BYTE*)lParam+dwLength)=0;
				bFreeLParam=TRUE;
			}
		}
		else if ((lParam=_wtoi(m_pSendMessage->szLParam))==0)
		{
			DWORD dwLength;
			lParam=(WPARAM)dataparser(m_pSendMessage->szLParam,istrlen(m_pSendMessage->szLParam),gmalloc,&dwLength);
			*((BYTE*)lParam+dwLength)=0;
            bFreeLParam=TRUE;
		}
	}

	if (hWnd!=NULL)
	{
		if (m_nMisc==PostMessage)
			::PostMessage(hWnd,m_pSendMessage->nMessage,wParam,lParam);
		else
			::SendMessage(hWnd,m_pSendMessage->nMessage,wParam,lParam);
	}

	if (bFreeWParam)
		GlobalFree((HANDLE)wParam);
	if (bFreeLParam)
		GlobalFree((HANDLE)lParam);

}
Ejemplo n.º 11
0
void CCheckFileNotificationsThread::UpdateItemsInRoot(LPCWSTR szRoot,CLocateDlg* pLocateDlg)
{
	//BkgDebugFormatMessage("CCheckFileNotificationsThread::UpdateItemsInRoot BEGIN szRoot=%s",szRoot);
	
	if (pLocateDlg->m_pListCtrl==NULL)
		return;
	if (pLocateDlg->m_pListCtrl->GetItemCount()==0)
		return;

	
	// Updating changed items by checking all items
	if (szRoot[1]=='\0')
	{
		//BkgDebugMessage("CCheckFileNotificationsThread::UpdateItemsInRoot 1a");

		WCHAR szDriveLower=szRoot[0];
		WCHAR szDriveUpper=szRoot[0];
		MakeUpper(&szDriveUpper,1);

		//BkgDebugMessage("CCheckFileNotificationsThread::UpdateItemsInRoot 2a");

		int nItem=pLocateDlg->m_pListCtrl->GetNextItem(-1,LVNI_ALL);
		while (nItem!=-1)
		{
			if (m_lFlags&fwStopWhenPossible)
				break;

			CLocatedItem* pItem=(CLocatedItem*)pLocateDlg->m_pListCtrl->GetItemData(nItem);

			if (pItem!=NULL)
			{
				// Checking whether path is in changed volume
				LPCWSTR szPath=pItem->GetPath();
				if ((szPath[0]==szDriveLower || szPath[0]==szDriveUpper) &&
					szPath[1]==L':')
				{
					// Just disabling flags, let background thread do the rest
					if (pItem->RemoveFlagsForChanged())
						pLocateDlg->m_pListCtrl->RedrawItems(nItem,nItem);
					
				}
			}

			nItem=pLocateDlg->m_pListCtrl->GetNextItem(nItem,LVNI_ALL);
		}
	}
	else
	{
		DWORD dwLength=(DWORD)istrlenw(szRoot);

		//BkgDebugMessage("CCheckFileNotificationsThread::UpdateItemsInRoot 1b");

		int nItem=pLocateDlg->m_pListCtrl->GetNextItem(-1,LVNI_ALL);
		while (nItem!=-1)
		{
			if (m_lFlags&fwStopWhenPossible)
				break;

			CLocatedItem* pItem=(CLocatedItem*)pLocateDlg->m_pListCtrl->GetItemData(nItem);

			if (pItem!=NULL)
			{
				if (pItem->GetPathLen()>=dwLength)
				{
					LPWSTR szPath=alloccopy(pItem->GetPath(),pItem->GetPathLen());
					MakeLower(szPath);
		                
					if (wcsncmp(szPath,szRoot,dwLength)==0)
					{
						// Just disabling flags, let background thread do the rest
						if (pItem->RemoveFlagsForChanged())
							pLocateDlg->m_pListCtrl->RedrawItems(nItem,nItem);
						
					}
					delete[] szPath;
				}
			}
			nItem=pLocateDlg->m_pListCtrl->GetNextItem(nItem,LVNI_ALL);
		}
	}

	//DebugMessage("CCheckFileNotificationsThread::UpdateItemsInRoot END");
}
Ejemplo n.º 12
0
STDMETHODIMP CLocateShellExtension::Initialize(LPCITEMIDLIST pIDFolder,
                                   LPDATAOBJECT pDataObj,
                                   HKEY hRegKey)
{
	DebugFormatMessage("CLocateShellExtension::Initialize(%X,%X,%X)",pIDFolder,pDataObj,hRegKey);

	if (pDataObj==NULL)
		return E_INVALIDARG;

	FORMATETC FormatEtc;
	STGMEDIUM med;
	FormatEtc.cfFormat=RegisterClipboardFormat(CFSTR_SHELLIDLIST);
	FormatEtc.ptd=NULL;
	FormatEtc.dwAspect=DVASPECT_CONTENT;
	FormatEtc.lindex=-1;
    FormatEtc.tymed=TYMED_HGLOBAL;
	
	if (pDataObj->GetData(&FormatEtc,&med)==S_OK)
	{
		// May be computer?
		IShellFolder *psf;
		if (!SUCCEEDED(SHGetDesktopFolder(&psf)))
		{
			DebugMessage("No IShellFolder interface");
			return E_FAIL;
		}
		
		// Retrieving data from item id list
		BYTE* pData=(BYTE*)GlobalLock(med.hGlobal);
		
		UINT nFiles=((int*)pData)[0];
		UINT i,nLines=1,nSubIDListLen,nIDListLen;
		WCHAR szPath[_MAX_PATH];

		nSubIDListLen=GetIDListSize((LPITEMIDLIST)(pData+((int*)pData)[1]))-2;
		
		for (i=0;i<nFiles;i++)
		{
			nIDListLen=GetIDListSize((LPITEMIDLIST)(pData+((int*)pData)[2+i]));

			// Constructing IDList from parent item and item
            LPITEMIDLIST pItemIDList=(LPITEMIDLIST)new BYTE[nSubIDListLen+nIDListLen+2];
			CopyMemory((BYTE*)pItemIDList,(LPCSTR)(pData+((int*)pData)[1]),nSubIDListLen);
			CopyMemory((BYTE*)(pItemIDList)+nSubIDListLen,(LPCSTR)(pData+((int*)pData)[2+i]),nIDListLen);
			
			if (SHGetPathFromIDListW(pItemIDList,szPath))
			{
				DebugFormatMessage(L"SHGetPathFromIDListW gives %s",szPath);

				if (IsDirectory(szPath))
				{
					WCHAR szTarget[MAX_PATH];
					switch (GetNethoodTarget(szPath,szTarget,MAX_PATH))
					{
					case 1:
						m_aComputers.Add(alloccopy(szTarget));
						break;
					case 2:
						m_aDirectories.Add(alloccopy(szTarget));
						break;
					case 0:
						m_aDirectories.Add(alloccopy(szPath));
						break;
					}
				}
				else
					m_aFiles.Add(alloccopy(szPath));
			}
			else
			{
				DebugHexDump("idlist",(BYTE*)pItemIDList,nSubIDListLen+nIDListLen);
				
				STRRET str;
				if (SUCCEEDED(psf->GetDisplayNameOf(pItemIDList,SHGDN_NORMAL|SHGDN_FORPARSING,&str)))
				{
					if (SUCCEEDED(StrRetToBufW(&str,pItemIDList,szPath,MAX_PATH)))
					{
						if (szPath[0]!='\\' && szPath[1]!='\\')
							DebugFormatMessage("Cannot add item %s",szPath);
						else
							m_aComputers.Add(alloccopy(szPath));
					}
					else
						DebugMessage("StrRetToStr failed");
				}
				else
					DebugMessage("GetDisplayNameOf failed");

			}
			
			delete[] (BYTE*)pItemIDList;
		}
		
		GlobalUnlock(med.hGlobal);
		if (med.pUnkForRelease==NULL)
            GlobalFree(med.hGlobal);
		else 
			med.pUnkForRelease->Release();
	
		psf->Release();
	}
	else 
	{
		FormatEtc.cfFormat=CF_HDROP;
		if (m_pDataObj->GetData(&FormatEtc,&med)==S_OK)
		{
			LPDROPFILES df=(LPDROPFILES)GlobalLock(med.hGlobal);
			if (df->fWide)
			{
				LPWSTR lpPtr=(LPWSTR)((BYTE*)df+df->pFiles);
				SIZE_T nLen;
				while (nLen=wcslen(lpPtr))
				{
					DebugFormatMessage(L"HDROP contains file %s",(LPCSTR)(lpPtr));
					if (IsDirectory(lpPtr))
					{
						WCHAR szTarget[MAX_PATH];
						switch (GetNethoodTarget(lpPtr,szTarget,MAX_PATH))
						{
						case 1:
							m_aComputers.Add(alloccopy(szTarget));
							break;
						case 2:
							m_aDirectories.Add(alloccopy(szTarget));
							break;
						case 0:
							m_aDirectories.Add(alloccopy(lpPtr,nLen));
							break;
						}
					}
					else
						m_aFiles.Add(alloccopy(lpPtr,nLen));
					
					lpPtr+=nLen+1;
				}
			}
			else
			{
				LPSTR lpPtr=(LPSTR)df+df->pFiles;
				SIZE_T nLen;
				while (nLen=strlen(lpPtr))
				{
					LPWSTR lpFile=alloccopyAtoW(lpPtr,nLen);					

					if (IsDirectory(lpFile))
						m_aDirectories.Add(lpFile);
					else
						m_aFiles.Add(lpFile);

					lpPtr+=nLen+1;
				}
			}	
			
			GlobalUnlock(med.hGlobal);
			
			if (med.pUnkForRelease==NULL)
                GlobalFree(med.hGlobal);
			else 
				med.pUnkForRelease->Release();
		}
	}

	
    // Initialize can be called more than once

    if (m_pDataObj)
        m_pDataObj->Release();

    // duplicate the object pointer and registry handle

    if (pDataObj)
    {
        m_pDataObj = pDataObj;
        pDataObj->AddRef();
    }

    return NOERROR;
}