Exemplo n.º 1
0
static char * 
myspell_checker_get_open_office_dicts_dir(void)
{
    WCHAR* wszDirectory;
    char* open_office_dir, * open_office_dicts_dir;

    /*start by trying current user*/
    wszDirectory = GetRegistryValue (HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\soffice.exe", L"Path");
    if(wszDirectory == NULL)
    {
        /*next try local machine*/
        wszDirectory = GetRegistryValue (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\soffice.exe", L"Path");
    }

    if(wszDirectory == NULL)
    {
        return NULL;
    }

    else {
       	open_office_dir = g_utf16_to_utf8 ((gunichar2*)wszDirectory, -1, NULL, NULL, NULL);
		open_office_dicts_dir = g_build_filename(open_office_dir, "share", "dict", "ooo", NULL);
        g_free(wszDirectory);
        g_free(open_office_dir);
        return open_office_dicts_dir;
    }
}
Exemplo n.º 2
0
// 获得迅雷的下载目录
BOOL bigfilehelper::GetXunLeiDownloadDirs(std::vector<CString>& vDirs)
{
    BOOL bRet = TRUE;
    TCHAR szLongPathBuffer[MAX_PATH] = { 0 };
    DWORD len = sizeof(szLongPathBuffer);

    WCHAR szAppDataPath[MAX_PATH] = {0};
    szAppDataPath[0] = GetSystemDrive();
    wcscat(szAppDataPath,L":\\TDDownload");
    vDirs.push_back(szAppDataPath);

    GetRegistryValue(HKEY_CURRENT_USER,
        L"Software\\Thunder Network\\Thunder",
        L"DefaultPath",
        NULL,
        (LPBYTE)szLongPathBuffer,
        &len
        );
    if(wcslen(szLongPathBuffer) == 0)
        bRet = FALSE;
    else 
    {
        if(szLongPathBuffer[0]==GetSystemDrive()||szLongPathBuffer[0]==GetSystemDrive()-32||szLongPathBuffer[0]==GetSystemDrive()+32)
            vDirs.push_back(szLongPathBuffer);
        else bRet = FALSE;

    }
    return bRet;
}
bool CDROM_Interface_Aspi::ScanRegistryFindKey(HKEY& hKeyBase)
// hKey has to be open
{
	FILETIME	time;
	ULONG		result,newKeyResult;
	char		subKey[256];
	char		buffer[256];
	ULONG		bufferSize = 256;
	ULONG		subKeySize = 256;
	HKEY		hNewKey;
	
	ULONG index = 0;
	do {
		result = RegEnumKeyEx (hKeyBase,index,&subKey[0],&subKeySize,NULL,NULL,0,&time);
		if (result==ERROR_SUCCESS) {
			// Open Key...
			newKeyResult = RegOpenKeyEx (hKeyBase,subKey,0,KEY_READ,&hNewKey);
			if (newKeyResult==ERROR_SUCCESS) {
				if (GetRegistryValue(hNewKey,"CurrentDriveLetterAssignment",buffer,256)) {
					LOG(LOG_MISC,LOG_NORMAL)("SCSI: Drive Letter found: %s",buffer);					
					// aha, something suspicious...
					if (buffer[0]==letter) {
						char hardwareID[256];
						// found it... lets see if we can get the scsi values				
						bool v1 = GetRegistryValue(hNewKey,"SCSILUN",buffer,256);
						LOG(LOG_MISC,LOG_NORMAL)("SCSI: SCSILUN found: %s",buffer);					
						lun		= buffer[0]-'0';
						bool v2 = GetRegistryValue(hNewKey,"SCSITargetID",buffer,256);
						LOG(LOG_MISC,LOG_NORMAL)("SCSI: SCSITargetID found: %s",buffer);					
						target  = buffer[0]-'0';
						bool v3 = GetRegistryValue(hNewKey,"HardwareID",hardwareID,256);
						RegCloseKey(hNewKey);
						if (v1 && v2 && v3) {	
							haId = GetHostAdapter(hardwareID);
							return true;
						};
					}
				};
			};
			RegCloseKey(hNewKey);
		};
		index++;
	} while ((result==ERROR_SUCCESS) || (result==ERROR_MORE_DATA));
	return false;
};
Exemplo n.º 4
0
void configure_enchant_provider(EnchantProvider * me, const char *dir_name)
{
#if defined(_WIN32)
    const WCHAR* aspell_module_name = L"aspell-15.dll";
    HMODULE aspell_module = NULL;
    char* szModule;

    /* first try load from registry path */
    szModule = enchant_get_registry_value ("Aspell", "Module");
    if(szModule)
    {
        WCHAR* wszModule;

        wszModule = g_utf8_to_utf16 (szModule, -1, NULL, NULL, NULL);
        aspell_module = LoadLibrary(wszModule);
        g_free(wszModule);
    }

    if (aspell_module == NULL)
    {
        /* next try load from aspell registry path */
        WCHAR* wszDirectory = GetRegistryValue (HKEY_LOCAL_MACHINE, L"Software\\Aspell", L"Path");
        if(wszDirectory)
        {
            aspell_module = LoadLibraryFromPath(wszDirectory, aspell_module_name);
            g_free(wszDirectory);
        }
    }

    if (aspell_module == NULL)
    {
        /* then try from same directory as provider */
        WCHAR* wszDirectory = GetDirectoryOfThisLibrary();
        if(wszDirectory)
        {
            aspell_module = LoadLibraryFromPath(wszDirectory, aspell_module_name);
            g_free(wszDirectory);
        }
    }

    if (aspell_module == NULL)
    {
        /* then try default lookup */
        aspell_module = LoadLibrary(aspell_module_name);
    }

    if (aspell_module == NULL)
    {
        /* we can't seem to load aspell. Avoid late binding problems later */
        g_warning("Unable to load library aspell-15.dll.");
        me->request_dict = NULL;
        me->dispose_dict = NULL;
        me->list_dicts = NULL;
    }
#endif

}
Exemplo n.º 5
0
void CGitExtensionsShellEx::RunGitEx(const TCHAR * command)
{
    CString szFile = m_szFile;
    CString szCommandName = command;
    CString args;

    args += command;
    args += " \"";
    args += m_szFile;
    args += "\"";

    CString dir = "";

    if (dir.GetLength() == 0)
        dir = GetRegistryValue(HKEY_CURRENT_USER, L"SOFTWARE\\GitExtensions\\GitExtensions", L"InstallDir");
    if (dir.GetLength() == 0)
        dir = GetRegistryValue(HKEY_USERS, L"SOFTWARE\\GitExtensions\\GitExtensions", L"InstallDir");
    if (dir.GetLength() == 0)
        dir = GetRegistryValue(HKEY_LOCAL_MACHINE, L"SOFTWARE\\GitExtensions\\GitExtensions", L"InstallDir");

    ShellExecute(NULL, L"open", L"GitExtensions.exe", args, dir, SW_SHOWNORMAL); 
}
Exemplo n.º 6
0
//
// Get startup directory as saved in the registry by the launcher
// Used in the Win32 Client only
//
SString SharedUtil::GetMTASABaseDir ( void )
{
    static SString strInstallRoot;
    if ( strInstallRoot.empty () )
    {
        strInstallRoot = GetRegistryValue ( "", "Last Run Location" );
        if ( strInstallRoot.empty () )
        {
            MessageBox ( 0, "Multi Theft Auto has not been installed properly, please reinstall.", "Error", MB_OK );
            TerminateProcess ( GetCurrentProcess (), 9 );
        }
    }
    return strInstallRoot;
}
Exemplo n.º 7
0
/////////////////////////////////////////////////////////////////////
// 
// Function:    IsUpgrading
//
// Description: 
//
/////////////////////////////////////////////////////////////////////
BOOL BOINCCABase::IsUpgrading()
{
    tstring strCurrentProductVersion;
    tstring strRegistryProductVersion;
    UINT    uiReturnValue = 0;

    uiReturnValue = GetProperty( _T("ProductVersion"), strCurrentProductVersion );
    if ( uiReturnValue ) return FALSE;

    uiReturnValue = GetRegistryValue( _T("UpgradingTo"), strRegistryProductVersion );
    if ( uiReturnValue ) return FALSE;

    return IsVersionNewer(strRegistryProductVersion, strCurrentProductVersion);
}
Exemplo n.º 8
0
void active_wma()
{
	GetRegistryValue("/CONFIG/MUSIC", "wma_play", &value);

	if (value == 1)
	{
		oslDrawStringf(10,210, "WMA is already activated.");
	}
	else
	{
		SetRegistryValue("/CONFIG/MUSIC", "wma_play", 1);
		oslDrawStringf(10,210, "WMA activated.");
	}
}
Exemplo n.º 9
0
void CSimpleShlExt::RunGitEx(const char * command)
{
	CString szFile = m_szFile;
	CString szCommandName = command;
	CString args;

	args += command;
	args += " \"";
	args += m_szFile;
	args += "\"";

	CString dir = "";

	if (dir.GetLength() == 0)
		dir = GetRegistryValue(HKEY_CURRENT_USER, "SOFTWARE\\GitExtensions\\GitExtensions\\1.0.0.0", "InstallDir");
	if (dir.GetLength() == 0)
		dir = GetRegistryValue(HKEY_USERS, "SOFTWARE\\GitExtensions\\GitExtensions\\1.0.0.0", "InstallDir");
	if (dir.GetLength() == 0)
		dir = GetRegistryValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\GitExtensions\\GitExtensions\\1.0.0.0", "InstallDir");

	ShellExecute(NULL, "open", "GitExtensions.exe", args, dir, SW_SHOWNORMAL); 
	//system(szMsg);
}
Exemplo n.º 10
0
gboolean load_library(EnchantProvider * me, const char *dir_name, const WCHAR *aspell_module_name)
{
    HMODULE aspell_module = NULL;
    char* szModule;

    /* first try load from registry path */
   	szModule = enchant_get_registry_value ("Aspell", "Module");
    if(szModule)
    {
        WCHAR* wszModule;

	    wszModule = g_utf8_to_utf16 (szModule, -1, NULL, NULL, NULL);
        aspell_module = LoadLibraryW(wszModule);
        g_free(wszModule);
    }

    if (aspell_module == NULL)
        {
            /* next try load from aspell registry path */
            WCHAR* wszDirectory = GetRegistryValue (HKEY_LOCAL_MACHINE, L"Software\\Aspell", L"Path");
            if(wszDirectory)
                {
                    aspell_module = LoadLibraryFromPath(wszDirectory, aspell_module_name);
                    g_free(wszDirectory);
                }
        }

    if (aspell_module == NULL)
        {
            /* then try from same directory as provider */
            WCHAR* wszDirectory = GetDirectoryOfThisLibrary();
            if(wszDirectory)
                {
                    aspell_module = LoadLibraryFromPath(wszDirectory, aspell_module_name);
                    g_free(wszDirectory);
                }
        }

    if (aspell_module == NULL) 
        {
            /* then try default lookup */
            aspell_module = LoadLibraryW(aspell_module_name);
        }

    if (aspell_module == NULL) 
        {
	        return FALSE;
        }
    return TRUE;
}
Exemplo n.º 11
0
//Registry Func
void swap_buttons()
{
	GetRegistryValue("/CONFIG/SYSTEM/XMB", "button_assign", &value);
	value = !value;
    SetRegistryValue("/CONFIG/SYSTEM/XMB", "button_assign", value); 

    if(value) 
    {
        oslDrawStringf(10,210, "Done!, Enter button is now X");		
	} 
	else 
	{
        oslDrawStringf(10,210, "Done!, Enter button is now O");	
    }
}
Exemplo n.º 12
0
void active_flash()
{
	GetRegistryValue("/CONFIG/BROWSER", "flash_activated", &value);

	if(value == 1)
	{
		oslDrawStringf(10,210, "Flash player is already activated.");
	}
	else
	{
		SetRegistryValue("/CONFIG/BROWSER", "flash_activated", 1);
        SetRegistryValue("/CONFIG/BROWSER", "flash_play", 1);
	    oslDrawStringf(10,210, "Flash player activated.");
	}
}
STDMETHODIMP CGitExtensionsShellEx::QueryContextMenu  (
    HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd,
    UINT uidLastCmd, UINT uFlags )
{
    // If the flags include CMF_DEFAULTONLY then we shouldn't do anything.
    if ( uFlags & CMF_DEFAULTONLY )
        return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, 0 );

    //InsertMenu (hmenu, uMenuIndex, MF_BYPOSITION, uidFirstCmd, _T("GitEx") );

    int id = 0;

    CString szCascadeContextMenu = GetRegistryValue(HKEY_CURRENT_USER, "SOFTWARE\\GitExtensions\\GitExtensions", "ShellCascadeContextMenu");

    CascadeContextMenu = !(szCascadeContextMenu == "False");

    if (CascadeContextMenu)
    {
        // show context menu cascaded in submenu
        HMENU popupMenu = CreateMenu();

        id = PopulateMenu(popupMenu, uidFirstCmd + id, true);

        //InsertMenu(hmenu, uMenuIndex++, MF_STRING | MF_BYPOSITION | MF_POPUP, (int)popupMenu, "Git Extensions");
        MENUITEMINFO info;

        info.cbSize = sizeof( MENUITEMINFO );
        info.fMask = MIIM_ID | MIIM_TYPE | MIIM_SUBMENU;
        info.fType = MFT_STRING;
        info.wID = uidFirstCmd + 1;
        info.dwTypeData = _T("Git Extensions");
        info.hSubMenu = popupMenu;
        InsertMenuItem(hmenu, 0, true, &info);
    }
    else
    {
        // show menu items directly
        id = PopulateMenu(hmenu, uidFirstCmd + id, false);
    }

    return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, id-uidFirstCmd );
}
Exemplo n.º 14
0
STDMETHODIMP CGitExtensionsShellEx::QueryContextMenu  (
    HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd,
    UINT uidLastCmd, UINT uFlags )
{
    // If the flags include CMF_DEFAULTONLY then we shouldn't do anything.
    if ( uFlags & CMF_DEFAULTONLY )
        return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, 0 );

    int id = 0;

    CString szCascadeContextMenu = GetRegistryValue(HKEY_CURRENT_USER, "SOFTWARE\\GitExtensions\\GitExtensions", "ShellCascadeContextMenu");

    CascadeContextMenu = !(szCascadeContextMenu == "False");

    if (CascadeContextMenu)
    {
        // show context menu cascaded in submenu
        HMENU popupMenu = CreateMenu();

        id = PopulateMenu(popupMenu, uidFirstCmd, id, true);

        MENUITEMINFO info;

        info.cbSize = sizeof( MENUITEMINFO );
        info.fMask = MIIM_STRING | MIIM_ID | MIIM_BITMAP | MIIM_SUBMENU;
        info.wID = uidFirstCmd + 1;
        info.hbmpItem = IsVistaOrLater() ? IconToBitmapPARGB32(IDI_GITEXTENSIONS) : HBMMENU_CALLBACK;
        myIDMap[1] = IDI_GITEXTENSIONS;
        myIDMap[uidFirstCmd + 1] = IDI_GITEXTENSIONS;
        info.dwTypeData = _T("Git Extensions");
        info.hSubMenu = popupMenu;
        InsertMenuItem(hmenu, 0, true, &info);
    }
    else
    {
        // show menu items directly
        id = PopulateMenu(hmenu, uidFirstCmd, id, false);
    }

    return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, id );
}
Exemplo n.º 15
0
void SlimItem::_GetWallpaperFilterPath(CString& strPath)
{
    TCHAR temp[MAX_PATH * 2] = {0};
    TCHAR szLongPathBuffer[MAX_PATH * 2] = { 0 };
    DWORD len = sizeof(szLongPathBuffer);
    CString strValueName;

    if (KGetWinVersion() == WINVERSION_WIN7)
    {
        strValueName = L"WallpaperSource";
    }
    else
    {
        strValueName = L"Wallpaper";
    }

    // 过滤 当前壁纸
    GetRegistryValue(HKEY_CURRENT_USER,
        L"Software\\Microsoft\\Internet Explorer\\Desktop\\General",
        strValueName,
        NULL,
        (LPBYTE)szLongPathBuffer,
        &len
        );

    if (ExpandEnvironmentStrings(szLongPathBuffer, temp, MAX_PATH * 2))
    {
        strPath = temp;
    }
    else
    {
        strPath = szLongPathBuffer;
    }

    if (strPath.IsEmpty())
    {
        strPath = L"NULL";
    }
}
Exemplo n.º 16
0
static BOOL 
GetLaunchOnStartup()
{
	
    WCHAR regPath[MAX_PATH], exePath[MAX_PATH];	
    BOOL result = FALSE;
    HKEY regkey;

    if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_READ, &regkey) == ERROR_SUCCESS) {

        if (GetRegistryValue(regkey, L"OpenVPN-GUI", regPath, MAX_PATH) &&
            GetModuleFileNameW(NULL, exePath, MAX_PATH)) {
            if (_wcsicmp(regPath, exePath) == 0)
                result = TRUE;
        }

        RegCloseKey(regkey);

    }
	
    return result;

}
Exemplo n.º 17
0
//
// What to do on next restart
//
bool SharedUtil::GetOnRestartCommand ( SString& strOperation, SString& strFile, SString& strParameters, SString& strDirectory, SString& strShowCmd )
{
    SString strOnRestartCommand = GetRegistryValue ( "", "OnRestartCommand" );
    SetOnRestartCommand ( "" );

    std::vector < SString > vecParts;
    strOnRestartCommand.Split ( "\t", vecParts );
    if ( vecParts.size () > 5 && vecParts[0].length () )
    {
        SString strVersion ( "%d.%d.%d-%d.%05d", MTASA_VERSION_MAJOR, MTASA_VERSION_MINOR, MTASA_VERSION_MAINTENANCE, MTASA_VERSION_TYPE, MTASA_VERSION_BUILD );
        if ( vecParts[5] == strVersion )
        {
            strOperation = vecParts[0];
            strFile = vecParts[1];
            strParameters = vecParts[2];
            strDirectory = vecParts[3];
            strShowCmd = vecParts[4];
            return true;
        }
        AddReportLog( 4000, SString ( "OnRestartCommand disregarded due to version change %s -> %s", vecParts[5].c_str (), strVersion.c_str () ) );
    }
    return false;
}
Exemplo n.º 18
0
void
GetProxyRegistrySettings()
{
    LONG status;
    HKEY regkey;
    TCHAR proxy_source_string[2] = _T("0");
    TCHAR proxy_type_string[2] = _T("0");

    /* Open Registry for reading */
    status = RegOpenKeyEx(HKEY_CURRENT_USER, GUI_REGKEY_HKCU, 0, KEY_READ, &regkey);
    if (status != ERROR_SUCCESS)
        return;

    /* get registry settings */
    GetRegistryValue(regkey, _T("proxy_http_address"), o.proxy_http_address, _countof(o.proxy_http_address));
    GetRegistryValue(regkey, _T("proxy_http_port"), o.proxy_http_port, _countof(o.proxy_http_port));
    GetRegistryValue(regkey, _T("proxy_socks_address"), o.proxy_socks_address, _countof(o.proxy_socks_address));
    GetRegistryValue(regkey, _T("proxy_socks_port"), o.proxy_socks_port, _countof(o.proxy_socks_port));
    GetRegistryValue(regkey, _T("proxy_source"), proxy_source_string, _countof(proxy_source_string));
    GetRegistryValue(regkey, _T("proxy_type"), proxy_type_string, _countof(proxy_type_string));

    if (proxy_source_string[0] == _T('0'))
    {
        o.proxy_source = config;
    }
    else if (proxy_source_string[0] == _T('1'))
    {
        o.proxy_source = windows;
    }
    else if (proxy_source_string[0] == _T('2'))
    {
        o.proxy_source = manual;
    }

    o.proxy_type = (proxy_type_string[0] == _T('0') ? http : socks);

    RegCloseKey(regkey);
}
Exemplo n.º 19
0
/////////////////////////////////////////////////////////////////////
// 
// Function:    
//
// Description: 
//
/////////////////////////////////////////////////////////////////////
UINT CARestoreSetupState::OnExecution()
{
    tstring     strInstallDirectory;
    tstring     strDataDirectory;
    tstring     strLaunchProgram;
    tstring     strEnableLaunchAtLogon;
    tstring     strEnableScreensaver;
    tstring     strEnableProtectedApplicationExecution;
    tstring     strEnableUseByAllUsers;
    tstring     strOverrideInstallDirectory;
    tstring     strOverrideDataDirectory;
    tstring     strOverrideLaunchProgram;
    tstring     strOverrideEnableLaunchAtLogon;
    tstring     strOverrideEnableScreensaver;
    tstring     strOverrideEnableProtectedApplicationExecution;
    tstring     strOverrideEnableUseByAllUsers;

    tstring     strSetupStateStored;

    GetRegistryValue( _T("SETUPSTATESTORED"), strSetupStateStored );
    if (strSetupStateStored == _T("TRUE")) {

        GetProperty( _T("OVERRIDE_INSTALLDIR"), strOverrideInstallDirectory );
        GetProperty( _T("OVERRIDE_DATADIR"), strOverrideDataDirectory );
        GetProperty( _T("OVERRIDE_LAUNCHPROGRAM"), strOverrideLaunchProgram );
        GetProperty( _T("OVERRIDE_ENABLELAUNCHATLOGON"), strOverrideEnableLaunchAtLogon );
        GetProperty( _T("OVERRIDE_ENABLESCREENSAVER"), strOverrideEnableScreensaver );
        GetProperty( _T("OVERRIDE_ENABLEPROTECTEDAPPLICATIONEXECUTION3"), strOverrideEnableProtectedApplicationExecution );
        GetProperty( _T("OVERRIDE_ENABLEUSEBYALLUSERS"), strOverrideEnableUseByAllUsers );

        GetRegistryValue( _T("INSTALLDIR"), strInstallDirectory );
        GetRegistryValue( _T("DATADIR"), strDataDirectory );
        GetRegistryValue( _T("LAUNCHPROGRAM"), strLaunchProgram );
        GetRegistryValue( _T("ENABLELAUNCHATLOGON"), strEnableLaunchAtLogon );
        GetRegistryValue( _T("ENABLESCREENSAVER"), strEnableScreensaver );
        GetRegistryValue( _T("ENABLEPROTECTEDAPPLICATIONEXECUTION3"), strEnableProtectedApplicationExecution );
        GetRegistryValue( _T("ENABLEUSEBYALLUSERS"), strEnableUseByAllUsers );

        if (strOverrideInstallDirectory.empty()) {
            SetProperty( _T("INSTALLDIR"), strInstallDirectory );
        } else {
            SetProperty( _T("INSTALLDIR"), strOverrideInstallDirectory );
        }

        if (strOverrideDataDirectory.empty()) {
            SetProperty( _T("DATADIR"), strDataDirectory );
        } else {
            SetProperty( _T("DATADIR"), strOverrideDataDirectory );
        }

        if (strOverrideLaunchProgram.empty()) {
            if ((_T("1") == strLaunchProgram) || (strLaunchProgram.size() == 0)) {
                SetProperty( _T("LAUNCHPROGRAM"), _T("1") );
            } else {
                SetProperty( _T("LAUNCHPROGRAM"), _T("") );
            }
        } else {
            SetProperty( _T("LAUNCHPROGRAM"), strOverrideLaunchProgram );
        }

        if (strOverrideEnableLaunchAtLogon.empty()) {
            if (_T("1") == strEnableLaunchAtLogon) {
                SetProperty( _T("ENABLELAUNCHATLOGON"), _T("1") );
            } else {
                SetProperty( _T("ENABLELAUNCHATLOGON"), _T("") );
            }
        } else {
            SetProperty( _T("ENABLELAUNCHATLOGON"), strOverrideEnableLaunchAtLogon );
        }

        if (strOverrideEnableScreensaver.empty()) {
            if (_T("1") == strEnableScreensaver) {
                SetProperty( _T("ENABLESCREENSAVER"), _T("1") );
            } else {
                SetProperty( _T("ENABLESCREENSAVER"), _T("") );
            }
        } else {
            SetProperty( _T("ENABLESCREENSAVER"), strOverrideEnableScreensaver );
        }

        if (strOverrideEnableProtectedApplicationExecution.empty()) {
            if (_T("1") == strEnableProtectedApplicationExecution) {
                SetProperty( _T("ENABLEPROTECTEDAPPLICATIONEXECUTION3"), _T("1") );
            } else {
                SetProperty( _T("ENABLEPROTECTEDAPPLICATIONEXECUTION3"), _T("") );
            }
        } else {
            SetProperty( _T("ENABLEPROTECTEDAPPLICATIONEXECUTION3"), strOverrideEnableProtectedApplicationExecution );
        }

        if (strOverrideEnableUseByAllUsers.empty()) {
            if (_T("1") == strEnableUseByAllUsers) {
                SetProperty( _T("ENABLEUSEBYALLUSERS"), _T("1") );
            } else {
                SetProperty( _T("ENABLEUSEBYALLUSERS"), _T("") );
            }
        } else {
            SetProperty( _T("ENABLEUSEBYALLUSERS"), strOverrideEnableUseByAllUsers );
        }
    }

    // If the Data Directory entry is empty then that means we need
    //   to populate it with the default value.
    GetProperty( _T("DATADIR"), strDataDirectory );
    if (strDataDirectory.empty()) {
        tstring strCommonApplicationDataFolder;

        // MSI already has this figured out, so lets get it.
        GetProperty( _T("CommonAppDataFolder"), strCommonApplicationDataFolder );

        // Construct the default value
        strDataDirectory = strCommonApplicationDataFolder + _T("BOINC\\");

        SetProperty( _T("DATADIR"), strDataDirectory );
    }

    return ERROR_SUCCESS;
}
Exemplo n.º 20
0
void GetProxyRegistrySettings()
{
  LONG status;
  HKEY regkey;
  char proxy_source_string[2]="0";
  char proxy_type_string[2]="0";
  char proxy_http_auth_string[2]="0";
  char temp_path[100];

  /* Construct Authfile path */
  if (!GetTempPath(sizeof(temp_path) - 1, temp_path))
    {
      /* Error getting TempPath - using C:\ */
      ShowLocalizedMsg(GUI_NAME, ERR_GET_TEMP_PATH, "");
      strcpy(temp_path, "C:\\");
    }
  strncat(temp_path, "openvpn_authfile.txt", 
          sizeof(temp_path) - strlen(temp_path) - 1); 
  strncpy(o.proxy_authfile, temp_path, sizeof(o.proxy_authfile));

  /* Open Registry for reading */
  status = RegOpenKeyEx(HKEY_CURRENT_USER,
                       GUI_REGKEY_HKCU,
                       0,
                       KEY_READ,
                       &regkey);

  /* Return if can't open the registry key */
  if (status != ERROR_SUCCESS) return;
      

  /* get registry settings */
  GetRegistryValue(regkey, "proxy_http_address", o.proxy_http_address, 
                   sizeof(o.proxy_http_address));
  GetRegistryValue(regkey, "proxy_http_port", o.proxy_http_port, 
                   sizeof(o.proxy_http_port));
  GetRegistryValue(regkey, "proxy_socks_address", o.proxy_socks_address, 
                   sizeof(o.proxy_socks_address));
  GetRegistryValue(regkey, "proxy_socks_port", o.proxy_socks_port, 
                   sizeof(o.proxy_socks_port));
  GetRegistryValue(regkey, "proxy_source", proxy_source_string, 
                   sizeof(proxy_source_string));
  GetRegistryValue(regkey, "proxy_type", proxy_type_string, 
                   sizeof(proxy_type_string));
  GetRegistryValue(regkey, "proxy_http_auth", proxy_http_auth_string, 
                   sizeof(proxy_http_auth_string));

  if (proxy_source_string[0] == '1')
    o.proxy_source=1;
  if (proxy_source_string[0] == '2')
    o.proxy_source=2;
  if (proxy_source_string[0] == '3')
    o.proxy_source=3;

  if (proxy_type_string[0] == '1')
    o.proxy_type=1;

  if (proxy_http_auth_string[0] == '1')
    o.proxy_http_auth=1;

  RegCloseKey(regkey);
  return;  
}
/////////////////////////////////////////////////////////////////////
// 
// Function:    
//
// Description: 
//
/////////////////////////////////////////////////////////////////////
UINT CAMigrateBOINCData::OnExecution()
{
    tstring      strCustomActionData;
    tstring      strCurrentInstallDirectory;
    tstring      strFutureInstallDirectory;
    tstring      strCurrentDataDirectory;
    tstring      strFutureDataDirectory;
    tstring      strMigration;
    tstring      strMigrationVersion;
    tstring      strMigrationDirectory;
    tstring      strDestinationClientStateFile;
    tstring      strRemove;
    tstring      strProductVersion;
    tstring      strWindowsDirectory;
    tstring      strWindowsSystemDirectory;
    tstring      strProgramFilesDirectory;
    tstring      strSystemDrive;
    tstring      strVersionWindows64;
    struct _stat buf;
    ULONGLONG    ullFileSize = 0;
    ULONGLONG    ullDirectorySize = 0;
    ULONGLONG    ullFreeDiskSpace = 0;
    UINT         uiReturnValue = -1;

    LogMessage(
        INSTALLMESSAGE_INFO,
        NULL, 
        NULL,
        NULL,
        NULL,
        _T("CAMigrateBOINCData::OnExecution -- Function Begin")
    );


    GetRegistryValue( _T("INSTALLDIR"), strCurrentInstallDirectory );

    uiReturnValue = GetProperty( _T("INSTALLDIR"), strFutureInstallDirectory );
    if ( uiReturnValue ) return uiReturnValue;

    uiReturnValue = GetProperty( _T("DATADIR"), strFutureDataDirectory );
    if ( uiReturnValue ) return uiReturnValue;

    uiReturnValue = GetRegistryValue( _T("MIGRATION"), strMigration );
    uiReturnValue = GetRegistryValue( _T("MIGRATIONVERSION"), strMigrationVersion );
    uiReturnValue = GetRegistryValue( _T("MIGRATIONDIR"), strMigrationDirectory );

    uiReturnValue = GetProperty( _T("REMOVE"), strRemove );
    if ( uiReturnValue ) return uiReturnValue;

    uiReturnValue = GetProperty( _T("ProductVersion"), strProductVersion );
    if ( uiReturnValue ) return uiReturnValue;

    uiReturnValue = GetProperty( _T("VersionNT64"), strVersionWindows64 );
    if ( uiReturnValue ) return uiReturnValue;

    uiReturnValue = GetProperty( _T("WindowsFolder"), strWindowsDirectory );
    if ( uiReturnValue ) return uiReturnValue;

    uiReturnValue = GetProperty( _T("WindowsVolume"), strSystemDrive );
    if ( uiReturnValue ) return uiReturnValue;

    if (strVersionWindows64.length() > 0)
    {
        uiReturnValue = GetProperty( _T("System64Folder"), strWindowsSystemDirectory );
        if ( uiReturnValue ) return uiReturnValue;

        uiReturnValue = GetProperty( _T("ProgramFiles64Folder"), strProgramFilesDirectory );
        if ( uiReturnValue ) return uiReturnValue;
    }
    else
    {
        uiReturnValue = GetProperty( _T("SystemFolder"), strWindowsSystemDirectory );
        if ( uiReturnValue ) return uiReturnValue;

        uiReturnValue = GetProperty( _T("ProgramFilesFolder"), strProgramFilesDirectory );
        if ( uiReturnValue ) return uiReturnValue;
    }


    // If the REMOVE property is specified, then we are uninstalling BOINC
    if (strRemove.length())
    {
        // If we successfully migrated, and the user is now uninstalling, they
        //   are probably going back to a 6.x client, so don't migrate the
        //   data back to the 5.x location.
        //
        strMigration = _T("FALSE");
        strCustomActionData += strMigration + _T("|");
        strCustomActionData += strMigrationDirectory + _T("|");
        strCustomActionData += strFutureDataDirectory;
    }
    else
    {
        strDestinationClientStateFile = strFutureDataDirectory + _T("\\client_state.xml");

        // Perform some basic sanity tests to see if we need to migrate
        //   anything.
        BOOL bClientStateExists =
            (BOOL)(0 == _stat(strDestinationClientStateFile.c_str(), &buf));
        BOOL bInstallDataSameDirectory = 
            (BOOL)(strFutureInstallDirectory == strFutureDataDirectory);
        BOOL bDataDirExistsWithinInstallDir = 
            (BOOL)(tstring::npos != strFutureDataDirectory.find(strFutureInstallDirectory));
        BOOL bInstallDirWindowsDirSame = 
            (BOOL)(strFutureInstallDirectory == strWindowsDirectory);
        BOOL bDataDirWindowsDirSame = 
            (BOOL)(strFutureDataDirectory == strWindowsDirectory);
        BOOL bInstallDirSystemDriveSame = 
            (BOOL)(strFutureInstallDirectory == strSystemDrive);
        BOOL bDataDirSystemDriveSame = 
            (BOOL)(strFutureDataDirectory == strSystemDrive);
        BOOL bInstallDirWindowsSystemDirSame = 
            (BOOL)(strFutureInstallDirectory == strWindowsSystemDirectory);
        BOOL bDataDirWindowsSystemDirSame = 
            (BOOL)(strFutureDataDirectory == strWindowsSystemDirectory);
        BOOL bInstallDirProgramFilesDirSame = 
            (BOOL)(strFutureInstallDirectory == strProgramFilesDirectory);
        BOOL bDataDirProgramFilesDirSame = 
            (BOOL)(strFutureDataDirectory == strProgramFilesDirectory);

        if      ( bClientStateExists )
        {
            strMigration = _T("FALSE");
            LogMessage(
                INSTALLMESSAGE_INFO,
                NULL, 
                NULL,
                NULL,
                NULL,
                _T("Data files already exists, skipping migration.")
            );
        }
        else if ( bInstallDataSameDirectory ) 
        {
            strMigration = _T("FALSE");
            LogMessage(
                INSTALLMESSAGE_INFO,
                NULL, 
                NULL,
                NULL,
                NULL,
                _T("Install directory and data directory are the same, skipping migration.")
            );
        }
        else if ( bDataDirExistsWithinInstallDir )
        {
            strMigration = _T("FALSE");
            LogMessage(
                INSTALLMESSAGE_INFO,
                NULL, 
                NULL,
                NULL,
                NULL,
                _T("Data drectory exists within the install directory, skipping migration.")
            );
        }
        else if ( bInstallDirWindowsDirSame )
        {
            strMigration = _T("FALSE");
            LogMessage(
                INSTALLMESSAGE_INFO,
                NULL, 
                NULL,
                NULL,
                NULL,
                _T("Install directory is the same as the Windows directory, skipping migration.")
            );
        }
        else if ( bDataDirWindowsDirSame )
        {
            strMigration = _T("FALSE");
            LogMessage(
                INSTALLMESSAGE_INFO,
                NULL, 
                NULL,
                NULL,
                NULL,
                _T("Data directory is the same as the Windows directory, skipping migration.")
            );
        }
        else if ( bInstallDirSystemDriveSame )
        {
            strMigration = _T("FALSE");
            LogMessage(
                INSTALLMESSAGE_INFO,
                NULL, 
                NULL,
                NULL,
                NULL,
                _T("Install directory is the same as the system drive, skipping migration.")
            );
        }
        else if ( bDataDirSystemDriveSame )
        {
            strMigration = _T("FALSE");
            LogMessage(
                INSTALLMESSAGE_INFO,
                NULL, 
                NULL,
                NULL,
                NULL,
                _T("Data directory is the same as the system drive, skipping migration.")
            );
        }
        else if ( bInstallDirWindowsSystemDirSame )
        {
            strMigration = _T("FALSE");
            LogMessage(
                INSTALLMESSAGE_INFO,
                NULL, 
                NULL,
                NULL,
                NULL,
                _T("Install directory is the same as the Windows system directory, skipping migration.")
            );
        }
        else if ( bDataDirWindowsSystemDirSame )
        {
            strMigration = _T("FALSE");
            LogMessage(
                INSTALLMESSAGE_INFO,
                NULL, 
                NULL,
                NULL,
                NULL,
                _T("Data directory is the same as the Windows system directory, skipping migration.")
            );
        }
        else if ( bInstallDirProgramFilesDirSame )
        {
            strMigration = _T("FALSE");
            LogMessage(
                INSTALLMESSAGE_INFO,
                NULL, 
                NULL,
                NULL,
                NULL,
                _T("Install directory is the same as the program files directory, skipping migration.")
            );
        }
        else if ( bDataDirProgramFilesDirSame )
        {
            strMigration = _T("FALSE");
            LogMessage(
                INSTALLMESSAGE_INFO,
                NULL, 
                NULL,
                NULL,
                NULL,
                _T("Data directory is the same as the program files directory, skipping migration.")
            );
        }
        else
        {
            strMigration = _T("TRUE");
            LogMessage(
                INSTALLMESSAGE_INFO,
                NULL, 
                NULL,
                NULL,
                NULL,
                _T("Data files do NOT exist, performing migration.")
            );

            strMigrationDirectory = strCurrentInstallDirectory + _T("\\client_state.xml");
            if (0 == _stat(strMigrationDirectory.c_str(), &buf)) {
                strMigrationDirectory = strCurrentInstallDirectory;
            } else {
                strMigrationDirectory = strFutureInstallDirectory;
            }

            if ( GetFileDirectorySizes( strMigrationDirectory, ullFileSize, ullDirectorySize ) )
            {
                // The total amount of disk space required depends on whether or not
                //   the files in the original location are on the same volume as the
                //   destination. So do a quick check to see if we have enough disk
                //   space.
                if (!GetFreeDiskSpace(strFutureDataDirectory, ullFreeDiskSpace))
                {
                    // If the destination directory doesn't exist, try the parent
                    //   directory
                    tstring strBuffer = tstring(strFutureDataDirectory + _T("..\\"));
                    if (!GetFreeDiskSpace(strBuffer, ullFreeDiskSpace))
                    {
                        // If the parent directory doesn't exist, just choose
                        //   the default volume. Something is better than nothing
                        GetFreeDiskSpace(tstring(""), ullFreeDiskSpace);
                    }
                }


                // Are we on the same volume?
                if (strMigrationDirectory.substr(0, 2) == strFutureDataDirectory.substr(0, 2))
                {
                    // We only need the amount of free space as the largest file
                    //   that is going to be transfered.
                    if (ullFileSize > ullFreeDiskSpace)
                    {
                        LogMessage(
                            INSTALLMESSAGE_INFO,
                            NULL, 
                            NULL,
                            NULL,
                            NULL,
                            _T("Not enough free disk space is available to migrate BOINC's data files to\n"
                               "the new data directory. Please free up some disk space or migrate the files\n"
                               "manually. (ullFileSize > ullFreeDiskSpace)")
                        );
                        return ERROR_INSTALL_FAILURE;
                    }
                }
                else
                {
                    // We only need the amount of free space of the directory
                    //   that is going to be transfered.
                    if (ullDirectorySize > ullFreeDiskSpace)
                    {
                        LogMessage(
                            INSTALLMESSAGE_INFO,
                            NULL, 
                            NULL,
                            NULL,
                            NULL,
                            _T("Not enough free disk space is available to migrate BOINC's data files to\n"
                               "the new data directory. Please free up some disk space or migrate the files\n"
                               "manually. (ullDirectorySize > ullFreeDiskSpace)")
                        );
                        return ERROR_INSTALL_FAILURE;
                    }
                }
            }
        }

        // Contruct a '|' delimited string to pass along to the install script
        //   and rollback script parts of this custom action.
        strCustomActionData += strMigration + _T("|");
        strCustomActionData += strMigrationDirectory + _T("|");
        strCustomActionData += strFutureDataDirectory;
    }

    SetRegistryValue( _T("MIGRATION"), strMigration );
    SetRegistryValue( _T("MIGRATIONDIR"), strMigrationDirectory );
    SetProperty( _T("CAMigrateBOINCDataInstall"), strCustomActionData );
    SetProperty( _T("CAMigrateBOINCDataRollback"), strCustomActionData );

    LogMessage(
        INSTALLMESSAGE_INFO,
        NULL, 
        NULL,
        NULL,
        NULL,
        _T("CAMigrateBOINCData::OnExecution -- Function End")
    );

    return ERROR_SUCCESS;
}
Exemplo n.º 22
0
STDMETHODIMP CGitExtensionsShellEx::QueryContextMenu  (
    HMENU hMenu, UINT menuIndex, UINT uidFirstCmd,
    UINT uidLastCmd, UINT uFlags )
{
    // If the flags include CMF_DEFAULTONLY then we shouldn't do anything.
    if ( uFlags & CMF_DEFAULTONLY )
        return S_OK;

    CString szCascadeShellMenuItems = GetRegistryValue(HKEY_CURRENT_USER, L"SOFTWARE\\GitExtensions\\GitExtensions", L"CascadeShellMenuItems");
    if (szCascadeShellMenuItems.IsEmpty())
        szCascadeShellMenuItems = "110111000111111111";
    bool CascadeContextMenu = szCascadeShellMenuItems.Find('1') != -1;
    HMENU popupMenu = NULL;
    if (CascadeContextMenu)
        popupMenu = CreateMenu();

    bool isValidDir = IsValidGitDir(m_szFile);
    bool isFile = IsFileExists(m_szFile);

    // preset values, if not used
    commandsId.clear();

    UINT submenuIndex = 0;
    int id = 0;
    int cmdid;
    bool isSubMenu;

    if (isValidDir)
    {
        if (!isFile)
        {
            isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcBrowse);
            cmdid = AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Browse", IDI_ICONBROWSEFILEEXPLORER, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
            commandsId[cmdid]=gcBrowse;

            isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcCommit);
            cmdid = AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Commit", IDI_ICONCOMMIT, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
            commandsId[cmdid]=gcCommit;

            isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcPull);
            cmdid = AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Pull", IDI_ICONPULL, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
            commandsId[cmdid]=gcPull;

            isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcPush);
            cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Push", IDI_ICONPUSH, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
            commandsId[cmdid]=gcPush;

            isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcStash);
            cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"View stash", IDI_ICONSTASH, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
            commandsId[cmdid]=gcStash;

            isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcViewDiff);
            cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"View changes", IDI_ICONVIEWCHANGES, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
            commandsId[cmdid]=gcViewDiff;

            isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcCheckoutBranch);
            if (isSubMenu && submenuIndex > 0) {
                InsertMenu(popupMenu, submenuIndex++, MF_SEPARATOR|MF_BYPOSITION, 0, NULL); ++id;
            }
            cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Checkout branch", IDI_ICONBRANCHCHECKOUT, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
            commandsId[cmdid]=gcCheckoutBranch;

            isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcCheckoutRevision);
            cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Checkout revision", IDI_ICONREVISIONCHECKOUT, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
            commandsId[cmdid]=gcCheckoutRevision;

            isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcCreateBranch);
            cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Create branch", IDI_ICONBRANCHCREATE, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
            commandsId[cmdid]=gcCreateBranch;
        }

        isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcDiffTool);
        if (isSubMenu && submenuIndex > 0) {
            InsertMenu(popupMenu, submenuIndex++, MF_SEPARATOR|MF_BYPOSITION, 0, NULL); ++id;
        }
        cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Open with difftool", IDI_ICONVIEWCHANGES, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
        commandsId[cmdid]=gcDiffTool;

        isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcFileHistory);
        cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"File history", IDI_ICONFILEHISTORY, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
        commandsId[cmdid]=gcFileHistory;

        isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcResetFileChanges);
        cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Reset file changes", IDI_ICONTRESETFILETO, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
        commandsId[cmdid]=gcResetFileChanges;

        isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcAddFiles);
        cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Add files", IDI_ICONADDED, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
        commandsId[cmdid]=gcAddFiles;

        isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcApplyPatch);
        cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Apply patch", 0, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
        commandsId[cmdid]=gcApplyPatch;
    }
    else 
    {
        isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcClone);
        cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Clone", IDI_ICONCLONEREPOGIT, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
        commandsId[cmdid]=gcClone;

        isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcCreateRepository);
        cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Create new repository", IDI_ICONCREATEREPOSITORY, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
        commandsId[cmdid]=gcCreateRepository;
    }

    isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcSettings);
    if (isSubMenu && submenuIndex > 0) {
        InsertMenu(popupMenu, submenuIndex++, MF_SEPARATOR|MF_BYPOSITION, 0, NULL); ++id;
    }
    cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Settings", IDI_ICONSETTINGS, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
    commandsId[cmdid]=gcSettings;

    ++id;

    if (CascadeContextMenu)
    {
        MENUITEMINFO info;
        info.cbSize = sizeof( MENUITEMINFO );
        info.fMask = MIIM_STRING | MIIM_ID | MIIM_BITMAP | MIIM_SUBMENU;
        info.wID = uidFirstCmd + 1;
        info.hbmpItem = IsVistaOrLater() ? IconToBitmapPARGB32(IDI_GITEXTENSIONS) : HBMMENU_CALLBACK;
        myIDMap[1] = IDI_GITEXTENSIONS;
        myIDMap[uidFirstCmd + 1] = IDI_GITEXTENSIONS;
        info.dwTypeData = _T("Git Extensions");
        info.hSubMenu = popupMenu;
        InsertMenuItem(hMenu, menuIndex, true, &info);
    }

    return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, id);
}
Exemplo n.º 23
0
int CGitExtensionsShellEx::PopulateMenu(HMENU hMenu, int firstId, int id, bool isSubMenu)
{
    CString szShellVisibleMenuItems = GetRegistryValue(HKEY_CURRENT_USER, "SOFTWARE\\GitExtensions\\GitExtensions", "ShellVisibleMenuItems");

    // preset values, if not used
    AddFilesId = -1;
    ApplyPatchId = -1;
    BrowseId = -1;
    CreateBranchId = -1;
    CheckoutBranchId = -1;
    CheckoutRevisionId = -1;
    CloneId = -1;
    CommitId = -1;
    FileHistoryId = -1;
    PullId = -1;
    PushId = -1;
    SettingsId = -1;
    ViewDiffId = -1;
    ResetFileChangesId = -1;

    int pos = 0;

    if (isSubMenu)
    {
        if (IsMenuItemVisible(szShellVisibleMenuItems, 0))
            AddMenuItem(hMenu, "Add files", IDI_ICONADDED, firstId, ++id, AddFilesId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 1))
            AddMenuItem(hMenu, "Apply patch", 0, firstId, ++id, ApplyPatchId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 2))
            AddMenuItem(hMenu, "Browse", IDI_ICONBROWSEFILEEXPLORER, firstId, ++id, BrowseId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 3))
            AddMenuItem(hMenu, "Create branch", IDI_ICONBRANCHCREATE, firstId, ++id, CreateBranchId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 4))
            AddMenuItem(hMenu, "Checkout branch", IDI_ICONBRANCHCHECKOUT, firstId, ++id, CheckoutBranchId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 5))
            AddMenuItem(hMenu, "Checkout revision", IDI_ICONREVISIONCHECKOUT, firstId, ++id, CheckoutRevisionId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 6))
            AddMenuItem(hMenu, "Clone", IDI_ICONCLONEREPOGIT, firstId, ++id, CloneId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 7))
            AddMenuItem(hMenu, "Commit", IDI_ICONCOMMIT, firstId, ++id, CommitId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 8))
            AddMenuItem(hMenu, "File history", IDI_ICONFILEHISTORY, firstId, ++id, FileHistoryId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 9))
            AddMenuItem(hMenu, "Reset file changes", IDI_ICONTRESETFILETO, firstId, ++id, ResetFileChangesId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 10))
            AddMenuItem(hMenu, "Pull", IDI_ICONPULL, firstId, ++id, PullId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 11))
            AddMenuItem(hMenu, "Push", IDI_ICONPUSH, firstId, ++id, PushId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 12))
            AddMenuItem(hMenu, "Settings", IDI_ICONSETTINGS, firstId, ++id, SettingsId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 13))
            AddMenuItem(hMenu, "View diff", IDI_ICONDIFF, firstId, ++id, ViewDiffId=pos++);
    }
    else
    {
        if (IsMenuItemVisible(szShellVisibleMenuItems, 0))
            AddMenuItem(hMenu, "GitEx Add files", IDI_ICONADDED, firstId, ++id, AddFilesId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 1))
            AddMenuItem(hMenu, "GitEx Apply patch", 0, firstId, ++id, ApplyPatchId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 2))
            AddMenuItem(hMenu, "GitEx Browse", IDI_ICONBROWSEFILEEXPLORER, firstId, ++id, BrowseId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 3))
            AddMenuItem(hMenu, "GitEx Create branch", IDI_ICONBRANCHCREATE, firstId, ++id, CreateBranchId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 4))
            AddMenuItem(hMenu, "GitEx Checkout branch", IDI_ICONBRANCHCHECKOUT, firstId, ++id, CheckoutBranchId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 5))
            AddMenuItem(hMenu, "GitEx Checkout revision", IDI_ICONREVISIONCHECKOUT, firstId, ++id, CheckoutRevisionId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 6))
            AddMenuItem(hMenu, "GitEx Clone", IDI_ICONCLONEREPOGIT, firstId, ++id, CloneId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 7))
            AddMenuItem(hMenu, "GitEx Commit", IDI_ICONCOMMIT, firstId, ++id, CommitId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 8))
            AddMenuItem(hMenu, "GitEx File history", IDI_ICONFILEHISTORY, firstId, ++id, FileHistoryId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 9))
            AddMenuItem(hMenu, "GitEx Reset file changes", IDI_ICONTRESETFILETO, firstId, ++id, ResetFileChangesId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 10))
            AddMenuItem(hMenu, "GitEx Pull", IDI_ICONPULL, firstId, ++id, PullId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 11))
            AddMenuItem(hMenu, "GitEx Push", IDI_ICONPUSH, firstId, ++id, PushId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 12))
            AddMenuItem(hMenu, "GitEx Settings", IDI_ICONSETTINGS, firstId, ++id, SettingsId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 13))
            AddMenuItem(hMenu, "GitEx View diff", IDI_ICONDIFF, firstId, ++id, ViewDiffId=pos++);
    }

    ++id;
    return id;
}
Exemplo n.º 24
0
// 获得FlashGet的下载目录
BOOL bigfilehelper::GetFlashGetDownloadDirs(std::vector<CString>& vDirs)
{
    WinVersion  winver = KGetWinVersion();
    IniEditor IniEdit;
    BOOL bRet = TRUE;
    WCHAR szAppDataPath[MAX_PATH] = { 0 };

    WCHAR szAppPath[MAX_PATH] = {0};
    szAppPath[0] = GetSystemDrive();
    wcscat(szAppPath,L":\\Downloads");
    vDirs.push_back(szAppPath);

    if(WINVERSION_WIN7 == winver)
    {
        CString tmpStrPath = L"";
        bRet = SHGetSpecialFolderPath(NULL, szAppDataPath, CSIDL_APPDATA, FALSE);
        if (!bRet)
            goto clean0;
        tmpStrPath += szAppDataPath;
        tmpStrPath += L"\\FlashGet\\v3\\dat\\Appsetting.cfg";
        IniEdit.SetFile(tmpStrPath.GetBuffer());
        std::wstring UserPath = IniEdit.ReadString(L"FlashGet3 Setting Value",L"UserPath");
        if(UserPath.length()==0)
            bRet = FALSE;
        else 
        {


            if(UserPath[0]==GetSystemDrive()||UserPath[0]==GetSystemDrive()-32||UserPath[0]==GetSystemDrive()+32)
                vDirs.push_back(UserPath.c_str());
            else bRet = FALSE;
        }
    }
    else
    {
        TCHAR szLongPathBuffer[MAX_PATH] = { 0 };
        DWORD len = sizeof(szLongPathBuffer);
        GetRegistryValue(HKEY_LOCAL_MACHINE,
            L"SOFTWARE\\FlashGet Network\\FlashGet 3",
            L"Path",
            NULL,
            (LPBYTE)szLongPathBuffer,
            &len
            );
        if(wcslen(szLongPathBuffer) == 0)
            bRet = FALSE;
        else 
        {
            ::PathAppend(szLongPathBuffer,L"dat\\Appsetting.cfg");
            IniEdit.SetFile(szLongPathBuffer);
            std::wstring UserPath = IniEdit.ReadString(L"FlashGet3 Setting Value",L"UserPath");
            if(UserPath.length()==0)
                bRet = FALSE;
            else 
            {
                if(UserPath.at(0)==GetSystemDrive()||UserPath[0]==GetSystemDrive()-32||UserPath[0]==GetSystemDrive()+32)
                    vDirs.push_back(UserPath.c_str());
                else bRet = FALSE;
            }

        }
    }
clean0:
    return bRet;
}
Exemplo n.º 25
0
void getregdef(qMailOpts *popts)
{
// read qmail registry - defaults
	if (gAppKey = GetAppRegistryKey())
	{
		CStr sBuf;
		DWORD dwBuf;
		if ( GetRegistryValue(gAppKey, "Timeout", dwBuf))
			popts->timeout = (float) (dwBuf / 1000.0f);
		else if (popts->timeout == 0.0f)
			popts->timeout = Q_MINTIMEOUT;

		if (GetRegistryValue(gAppKey, "Smtp", sBuf))
			popts->host = sBuf;

		if (GetRegistryValue(gAppKey, "From", sBuf))
			popts->from = sBuf;
	}

// read microsoft preferences
	if (!popts->host.Length() || !popts->from) {
		HKEY hk1; CStr str; DWORD dw;
		CStr host;
		if (RegOpenKeyEx(HKEY_CURRENT_USER, 
			"software\\microsoft\\office\\8.0\\outlook\\internet account manager", 0, KEY_READ, &hk1) == ERROR_SUCCESS) 
		{
			if (GetRegistryValue(hk1, "default mail account", str)) {
				HKEY hk2;
				str = "accounts\\" << str;
				if (RegOpenKeyEx(hk1, (const char *) str, 0, KEY_QUERY_VALUE, &hk2) == ERROR_SUCCESS) {
					if (!popts->host.Length()) {
				 		if (GetRegistryValue(hk2, "POP3 User Name", str)) {
							host = str;
							host += '@';
						}
						if (GetRegistryValue(hk2, "SMTP Server", str)) {
							host += str;
						}
						if (GetRegistryValue(hk2, "SMTP Port", dw)) {
							host += ':';
							host += (int) dw;
						}
						popts->host = host;
					}
					
					if (popts->timeout == 0) {
						if (GetRegistryValue(hk2, "SMTP Timeout", dw))
							popts->timeout = (float) dw;
					}

					if (!popts->from.Length()) {
						if (GetRegistryValue(hk2, "SMTP Display Name", str))
							popts->from = str;
						if (GetRegistryValue(hk2, "SMTP Email Address", str)) {
							if (popts->from) {
								popts->from += '<';
								popts->from += str;
								popts->from += '>';
							} else 
								popts->from = str;
						}
					}
					RegCloseKey(hk2);
				}
			}
			RegCloseKey(hk1);
		}
	}
}
Exemplo n.º 26
0
CString CGetEnvPath::GetEnvVariable(LPCTSTR pszName)
{
    CString strResult;
	WCHAR wcsTemp[MAX_PATH] = {0}; 
    
    TCHAR szBuffer[MAX_PATH] = { 0 };
    TCHAR szLongPathBuffer[MAX_PATH] = { 0 };

    if ( CString("systemdrive").CompareNoCase(pszName) == 0 )
    {
        //UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);
        //strResult = GetDrive(_T(""));
        UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);

        if (uResult > 3 && szBuffer[1] == TEXT(':') && szBuffer[2] == TEXT('\\'))
        {
            szBuffer[2] = TEXT('\0');
            strResult = szBuffer;
            goto Exit0;         
        }
    }
    else if ( CString("program").CompareNoCase(pszName) == 0 )
    {
        //UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);
        //strResult = GetDrive(_T(""));
        UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);

        if (uResult > 3 && szBuffer[1] == TEXT(':') && szBuffer[2] == TEXT('\\'))
        {
            szBuffer[3] = TEXT('\0');
            strResult = szBuffer;
            strResult += L"program files";
            goto Exit0;         
        }
    }
    else if ( CString("boot").CompareNoCase(pszName) == 0 )
    {
        //UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);
        //strResult = GetDrive(_T(""));
        UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);

        if (uResult > 3 && szBuffer[1] == TEXT(':') && szBuffer[2] == TEXT('\\'))
        {
            szBuffer[3] = TEXT('\0');
            strResult = szBuffer;
            strResult += L"boot";
            goto Exit0;         
        }
    }
    else if ( CString("recovery").CompareNoCase(pszName) == 0 )
    {
        //UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);
        //strResult = GetDrive(_T(""));
        UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);

        if (uResult > 3 && szBuffer[1] == TEXT(':') && szBuffer[2] == TEXT('\\'))
        {
            szBuffer[3] = TEXT('\0');
            strResult = szBuffer;
            strResult += L"recovery";
            goto Exit0;         
        }
    }
    else if ( CString("systemroot").CompareNoCase(pszName) == 0 )
    {
       
        UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);

        if (uResult > 0)
        {
            strResult = szBuffer;
            goto Exit0;         
        }
    }
    else if(CString("windir").CompareNoCase(pszName) == 0)
    {
        UINT uResult = GetWindowsDirectory(szBuffer, MAX_PATH);

        if(szBuffer[wcslen(szBuffer)-1] == _T('\\'))
            szBuffer[wcslen(szBuffer)-1] = _T('\0');

        strResult = szBuffer;
        goto Exit0;
    }
    else if ( CString("systemrecycled").CompareNoCase(pszName) == 0 )
    {
        SYSTEM_VERSION     m_eSysVer;
        KAEGetSystemVersion(&m_eSysVer);
        CString StrSuffix;
        if(m_eSysVer == enumSystem_Win_7)
        {
            StrSuffix = _T("\\$RECYCLE.BIN");
        }
        else
            StrSuffix = _T("\\Recycled");
        strResult = GetDrive(StrSuffix);

        goto Exit0;
    }
	else if ( CString("minidump").CompareNoCase(pszName) == 0 )
	{
		DWORD len = sizeof(szLongPathBuffer);
		GetRegistryValue(HKEY_LOCAL_MACHINE,
			L"SYSTEM\\CurrentControlSet\\Control\\CrashControl",
			L"MinidumpDir",
			NULL,
			(LPBYTE)szLongPathBuffer,
			&len
			);
		if(wcslen(szLongPathBuffer) == 0)
			strResult = L"%minidump%";
		else
		{
			int nFirstPos  = 0; 
			int nSecondPos = 0;
			BOOL bFind = FALSE;
			bFind = FindEnvironmentPos(szLongPathBuffer, nFirstPos, nSecondPos);
			if(bFind)
			{
				CString strLeft       ;
				CString strRight      ;
				CString strEnvName    ;
				CString strEnvVariable;
				
				strResult = szLongPathBuffer;
				strLeft    = strResult.Left(nFirstPos);
				strRight   = strResult.Mid (nSecondPos + 1);
				strEnvName = strResult.Mid(nFirstPos + 1, nSecondPos - nFirstPos - 1);
				TCHAR szTempBuf[MAX_PATH];
				DWORD dwResult = GetEnvironmentVariable(strEnvName.GetBuffer(), szTempBuf, MAX_PATH);
				if (dwResult > 0)
					strEnvVariable = szTempBuf;

				strResult = CombinationPath(strLeft, strEnvVariable, strRight);

			}
			else
				strResult = szLongPathBuffer;

			goto Exit0;

		}
	}
	else if ( CString("memdump").CompareNoCase(pszName) == 0 )
	{
		DWORD len = sizeof(szLongPathBuffer);
		GetRegistryValue(HKEY_LOCAL_MACHINE,
			L"SYSTEM\\CurrentControlSet\\Control\\CrashControl",
			L"DumpFile",
			NULL,
			(LPBYTE)szLongPathBuffer,
			&len
			);
		if(wcslen(szLongPathBuffer) == 0)
			strResult = L"%memdump%";
		else
		{
			int nFirstPos  = 0; 
			int nSecondPos = 0;
			BOOL bFind = FALSE;
			bFind = FindEnvironmentPos(szLongPathBuffer, nFirstPos, nSecondPos);
			if(bFind)
			{
				CString strLeft       ;
				CString strRight      ;
				CString strEnvName    ;
				CString strEnvVariable;

				strResult = szLongPathBuffer;
				strLeft    = strResult.Left(nFirstPos);
				strRight   = strResult.Mid (nSecondPos + 1);
				strEnvName = strResult.Mid(nFirstPos + 1, nSecondPos - nFirstPos - 1);
				TCHAR szTempBuf[MAX_PATH];
				DWORD dwResult = GetEnvironmentVariable(strEnvName.GetBuffer(), szTempBuf, MAX_PATH);
				if (dwResult > 0)
					strEnvVariable = szTempBuf;

				strResult = CombinationPath(strLeft, strEnvVariable, L"");
				strResult += strRight;
			}
			else
				strResult = szLongPathBuffer;
			if (GetFileAttributes(strResult.GetBuffer()) != FILE_ATTRIBUTE_DIRECTORY)
			{
				WCHAR szTempBuffer[MAX_PATH] = {0};
				wcscpy_s(szTempBuffer, MAX_PATH - 1, strResult.GetBuffer());
				::PathRemoveFileSpec(szTempBuffer);
				strResult = szTempBuffer;
			}

			goto Exit0;

		}
	}
	else if (CString("archivefiles").CompareNoCase(pszName) == 0)
	{
		DWORD len = sizeof(szLongPathBuffer);
		GetRegistryValue(HKEY_LOCAL_MACHINE,
			L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VolumeCaches\\Windows Error Reporting Archive Files",
			L"Folder",
			NULL,
			(LPBYTE)szLongPathBuffer,
			&len
			);
		if (wcslen(szLongPathBuffer) == 0)
		{
			strResult = L"%archivefiles%";
		}
		else
		{
			int nFirstPos  = 0; 
			int nSecondPos = 0;
			BOOL bFind = FALSE;
			bFind = FindEnvironmentPos(szLongPathBuffer, nFirstPos, nSecondPos);
			if(bFind)
			{
				CString strLeft       ;
				CString strRight      ;
				CString strEnvName    ;
				CString strEnvVariable;

				strResult = szLongPathBuffer;
				strLeft    = strResult.Left(nFirstPos);
				strRight   = strResult.Mid (nSecondPos + 1);
				strEnvName = strResult.Mid(nFirstPos + 1, nSecondPos - nFirstPos - 1);
				TCHAR szTempBuf[MAX_PATH];
				DWORD dwResult = GetEnvironmentVariable(strEnvName.GetBuffer(), szTempBuf, MAX_PATH);
				if (dwResult > 0)
					strEnvVariable = szTempBuf;

				strResult = CombinationPath(strLeft, strEnvVariable, L"");
				strResult += strRight;
			}
			else
			{
				strResult = szLongPathBuffer;
			}
			goto Exit0;

		}
	}
	else if (CString("queuefiles").CompareNoCase(pszName) == 0)
	{
		DWORD len = sizeof(szLongPathBuffer);
		GetRegistryValue(HKEY_LOCAL_MACHINE,
			L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VolumeCaches\\Windows Error Reporting Queue Files",
			L"Folder",
			NULL,
			(LPBYTE)szLongPathBuffer,
			&len
			);
		if (wcslen(szLongPathBuffer) == 0)
		{
			strResult = L"%queuefiles%";
		}
		else
		{
			int nFirstPos  = 0; 
			int nSecondPos = 0;
			BOOL bFind = FALSE;
			bFind = FindEnvironmentPos(szLongPathBuffer, nFirstPos, nSecondPos);
			if(bFind)
			{
				CString strLeft       ;
				CString strRight      ;
				CString strEnvName    ;
				CString strEnvVariable;

				strResult = szLongPathBuffer;
				strLeft    = strResult.Left(nFirstPos);
				strRight   = strResult.Mid (nSecondPos + 1);
				strEnvName = strResult.Mid(nFirstPos + 1, nSecondPos - nFirstPos - 1);
				TCHAR szTempBuf[MAX_PATH];
				DWORD dwResult = GetEnvironmentVariable(strEnvName.GetBuffer(), szTempBuf, MAX_PATH);
				if (dwResult > 0)
					strEnvVariable = szTempBuf;

				strResult = CombinationPath(strLeft, strEnvVariable, L"");
				strResult += strRight;
			}
			else
			{
				strResult = szLongPathBuffer;
			}
			goto Exit0;

		}
	}
	else if (CString("systemarchivefiles").CompareNoCase(pszName) == 0)
	{
		DWORD len = sizeof(szLongPathBuffer);
		GetRegistryValue(HKEY_LOCAL_MACHINE,
			L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VolumeCaches\\Windows Error Reporting System Archive Files",
			L"Folder",
			NULL,
			(LPBYTE)szLongPathBuffer,
			&len
			);
		if (wcslen(szLongPathBuffer) == 0)
		{
			strResult = L"%systemarchivefiles%";
		}
		else
		{
			int nFirstPos  = 0; 
			int nSecondPos = 0;
			BOOL bFind = FALSE;
			bFind = FindEnvironmentPos(szLongPathBuffer, nFirstPos, nSecondPos);
			if(bFind)
			{
				CString strLeft       ;
				CString strRight      ;
				CString strEnvName    ;
				CString strEnvVariable;

				strResult = szLongPathBuffer;
				strLeft    = strResult.Left(nFirstPos);
				strRight   = strResult.Mid (nSecondPos + 1);
				strEnvName = strResult.Mid(nFirstPos + 1, nSecondPos - nFirstPos - 1);
				TCHAR szTempBuf[MAX_PATH];
				DWORD dwResult = GetEnvironmentVariable(strEnvName.GetBuffer(), szTempBuf, MAX_PATH);
				if (dwResult > 0)
					strEnvVariable = szTempBuf;

				strResult = CombinationPath(strLeft, strEnvVariable, L"");
				strResult += strRight;
			}
			else
			{
				strResult = szLongPathBuffer;
			}
			goto Exit0;

		}
	}
	else if (CString("systemqueuefiles").CompareNoCase(pszName) == 0)
	{
		DWORD len = sizeof(szLongPathBuffer);
		GetRegistryValue(HKEY_LOCAL_MACHINE,
			L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VolumeCaches\\Windows Error Reporting System Queue Files",
			L"Folder",
			NULL,
			(LPBYTE)szLongPathBuffer,
			&len
			);
		if (wcslen(szLongPathBuffer) == 0)
		{
			strResult = L"%systemqueuefiles%";
		}
		else
		{
			int nFirstPos  = 0; 
			int nSecondPos = 0;
			BOOL bFind = FALSE;
			bFind = FindEnvironmentPos(szLongPathBuffer, nFirstPos, nSecondPos);
			if(bFind)
			{
				CString strLeft       ;
				CString strRight      ;
				CString strEnvName    ;
				CString strEnvVariable;

				strResult = szLongPathBuffer;
				strLeft    = strResult.Left(nFirstPos);
				strRight   = strResult.Mid (nSecondPos + 1);
				strEnvName = strResult.Mid(nFirstPos + 1, nSecondPos - nFirstPos - 1);
				TCHAR szTempBuf[MAX_PATH];
				DWORD dwResult = GetEnvironmentVariable(strEnvName.GetBuffer(), szTempBuf, MAX_PATH);
				if (dwResult > 0)
					strEnvVariable = szTempBuf;

				strResult = CombinationPath(strLeft, strEnvVariable, L"");
				strResult += strRight;
			}
			else
			{
				strResult = szLongPathBuffer;
			}
			goto Exit0;

		}
	}
    else if ( CString("tudou").CompareNoCase(pszName) == 0 )
    {
         DWORD len = sizeof(szLongPathBuffer);
         GetRegistryValue(HKEY_LOCAL_MACHINE,
             L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\飞速土豆",
             L"UninstallString",
             NULL,
             (LPBYTE)szLongPathBuffer,
             &len
             );
         if(wcslen(szLongPathBuffer) == 0)
            strResult = L"%tudou%";
         else
         {
             ::PathRemoveFileSpec(szLongPathBuffer);
             ::PathAppend(szLongPathBuffer,L"tudouva.ini");
             IniEditor IniEdit;
             IniEdit.SetFile(szLongPathBuffer);
             std::wstring tmpPath = IniEdit.ReadString(L"public",L"savedirectory");
             if(tmpPath.length() <= 3)
                 strResult = L"%tudou%";
             else 
                 strResult = tmpPath.c_str();

         }

        goto Exit0;
    }else if ( CString("qvod").CompareNoCase(pszName) == 0 )
    {
        DWORD len = sizeof(szBuffer);
        GetRegistryValue(HKEY_LOCAL_MACHINE,
            L"SOFTWARE\\QvodPlayer\\Insert",
            L"Insertpath",
            NULL,
            (LPBYTE)szLongPathBuffer,
            &len
            );
        if(wcslen(szLongPathBuffer) == 0)
            strResult = L"%qvod%";
        else
        {
            //::PathRemoveFileSpec(szLongPathBuffer);
            ::PathAppend(szLongPathBuffer,L"QvodPlayer.xml");
            TiXmlDocument xmlDoc;
            const TiXmlElement *pXmlQvodPlayer = NULL;
            const TiXmlElement *pXmlGeneral = NULL;
            strResult = L"%qvod%";
            if (!xmlDoc.LoadFile(UnicodeToAnsi(szLongPathBuffer).c_str(), TIXML_ENCODING_UTF8))
                goto Exit0;
            pXmlQvodPlayer = xmlDoc.FirstChildElement("QvodPlayer");
            if (!pXmlQvodPlayer)
                goto Exit0;
            pXmlGeneral = pXmlQvodPlayer->FirstChildElement("General");
            if (pXmlGeneral)
            {
                const char* szTmp = pXmlGeneral->Attribute("Defaultsavepath");
                if(!szTmp)
                    strResult = L"%qvod%";
                else 
                    strResult = Utf8ToUnicode(szTmp).c_str();
            }

        }

        goto Exit0;
    }
    else if ( CString("xunleikankan").CompareNoCase(pszName) == 0 )
    {
        DWORD len = sizeof(szBuffer);
        GetRegistryValue(HKEY_LOCAL_MACHINE,
            L"SOFTWARE\\Thunder network\\Xmp",
            L"storepath",
            NULL,
            (LPBYTE)szBuffer,
            &len
            );
        if(wcslen(szBuffer) == 0)
            strResult = L"%xunleikankan%";
        else
        {
//            wcscat(szBuffer,L"\\VODCache");
            strResult =szBuffer;
        }

        goto Exit0;
    }
    else if ( CString("youku").CompareNoCase(pszName) == 0 )
    {
        DWORD len = sizeof(szBuffer);
        GetRegistryValue(HKEY_CURRENT_USER,
            L"SOFTWARE\\youku\\iKuAcc",
            L"CachePath",
            NULL,
            (LPBYTE)szBuffer,
            &len
            );
        if(wcslen(szBuffer) == 0)
            strResult = L"%youku%";
        else
        {
            strResult =szBuffer;
            if(strResult.Find(L"\\Desktop")!=-1)
                strResult = L"%youku%";
        }

        goto Exit0;
    }
    else if ( CString("ku6").CompareNoCase(pszName) == 0 )
    {
        DWORD len = sizeof(szLongPathBuffer);
        GetRegistryValue(HKEY_LOCAL_MACHINE,
            L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Ku6SpeedUpper",
            L"UninstallString",
            NULL,
            (LPBYTE)szLongPathBuffer,
            &len
            );
        if(wcslen(szLongPathBuffer) == 0)
        {
            CString StrSuffix = _T("\\kvideo_cache");;
            strResult = GetDrive(StrSuffix);
        }
        else
        {
            ::PathRemoveFileSpec(szLongPathBuffer);
            ::PathAppend(szLongPathBuffer,L"Ku6SpeedUpper.ini");
            IniEditor IniEdit;
            IniEdit.SetFile(szLongPathBuffer);
            std::wstring tmpPath = IniEdit.ReadString(L"Settings",L"BufPath");
            if(tmpPath.length() > 0)
                strResult = tmpPath.c_str();
            else
            {
                CString StrSuffix = _T("\\kvideo_cache");;
                strResult = GetDrive(StrSuffix);
                
            }
        }
        goto Exit0;
    }
    else if ( CString("ppstream").CompareNoCase(pszName) == 0 )
    {
        CString strTmp = GetFolderPath(L"CSIDL_APPDATA");
        strTmp += L"\\ppstream\\psnetwork.ini";
        if(!::PathFileExists(strTmp.GetBuffer()))
        {
            strTmp = L"";
            GetWindowsDirectory(szLongPathBuffer,MAX_PATH);
            strTmp = szLongPathBuffer;
            strTmp +=  L"\\psnetwork.ini";
        }
        IniEditor IniEdit;
        IniEdit.SetFile(strTmp.GetBuffer());
        std::wstring tmpPath = IniEdit.ReadString(L"vodnet",L"pgfpath");
        if(tmpPath.length()>0)
          ::PathRemoveFileSpec((LPWSTR)tmpPath.c_str());
        else
        {
            tmpPath = IniEdit.ReadString(L"vodnet",L"pgfpath1");
            if(tmpPath.length()>0)
                tmpPath.erase(tmpPath.length()-1);
        }
        strResult = tmpPath.c_str();
        goto Exit0;
    }
    else if ( CString("pptv").CompareNoCase(pszName) == 0 )
    {
        CString strTmp = GetFolderPath(L"CSIDL_COMMON_APPDATA");
        strTmp += L"\\PPLive\\Core\\config.ini";
        IniEditor IniEdit;
        IniEdit.SetFile(strTmp.GetBuffer());
        std::wstring tmpPath = IniEdit.ReadString(L"peer",L"cachepath");
        std::string utf8str = KUTF16_To_ANSI(tmpPath.c_str());
        tmpPath = Utf8ToUnicode(utf8str.c_str());
        if(tmpPath.length() == 0)
            strResult = L"%pptv%";
        else
            strResult = tmpPath.c_str();
        goto Exit0;
    }
    else if ( CString("fengxing").CompareNoCase(pszName) == 0 )
    {
        CString strTmp = GetFolderPath(L"CSIDL_PERSONAL");
        int a = strTmp.ReverseFind(L'\\');
        strTmp = strTmp.Mid(0,strTmp.ReverseFind(L'\\'));
        strTmp += L"\\funshion.ini";
        IniEditor IniEdit;
        IniEdit.SetFile(strTmp.GetBuffer());
        std::wstring tmpPath = IniEdit.ReadString(L"FILE_PATH",L"MEDIA_PATH");
        if(tmpPath.length() == 0)
            strResult = L"%fengxing%";
        else
            strResult = tmpPath.c_str();
        goto Exit0;
    }
    else if ( CString("qqlive").CompareNoCase(pszName) == 0 )
    {
       CString strTmp = GetFolderPath(L"CSIDL_APPDATA");
       strTmp += L"\\Tencent\\QQLive\\user.ini";
       IniEditor IniEdit;
       IniEdit.SetFile(strTmp.GetBuffer());
       std::wstring tmpPath = IniEdit.ReadString(L"Cache",L"Directory");
       if(tmpPath.length()>0)
       {
           tmpPath.erase(tmpPath.length()-1);
           strResult = tmpPath.c_str();
       }
       else strResult = L"%qqlive%";
       
       goto Exit0;
    }
	else if ( CString("firefox").CompareNoCase(pszName) == 0 )
	{
		WCHAR szPath[MAX_PATH] = {0};
		SHGetSpecialFolderPath(NULL, szPath, CSIDL_APPDATA, FALSE);
		std::wstring strPath;
		std::wstring strTemp;
		strPath = szPath;
		HANDLE hFile = INVALID_HANDLE_VALUE;
		if (strPath.rfind(L'\\') != strPath.size())
		{
			strPath += L"\\";
		}
		strPath += L"Mozilla\\Firefox\\profiles.ini";
		IniEditor inif;
		inif.SetFile(strPath.c_str());
		strTemp = inif.ReadString(L"Profile0", L"Path");
		if(strTemp.find(L"//") != -1)
		{
			strTemp.replace(strTemp.find(L"//"), 1, L"\\");
		}

		ZeroMemory(szPath, MAX_PATH);
		SHGetSpecialFolderPath(NULL, szPath, CSIDL_LOCAL_APPDATA, FALSE);
		strPath = szPath;
		if (strPath.rfind(L'\\') != strPath.size())
		{
			strPath += L"\\";
		}
		strPath += L"Mozilla\\Firefox\\";
		strPath += strTemp;
		strPath += L"\\cache";

		strResult = strPath.c_str();
		goto Exit0;
	}
    else if ( CString("sogou").CompareNoCase(pszName) == 0 )
    {
        std::wstring strPath;
        std::wstring strTemp;
        WCHAR szPath[MAX_PATH] = {0};
        SHGetSpecialFolderPath(NULL, szPath, CSIDL_APPDATA, FALSE);
        strTemp = szPath;
        if ( strTemp.rfind(L'\\') != strTemp.size())
        {
            strTemp += L"\\";
        }
        strTemp += L"SogouExplorer\\CommCfg.xml";

        strResult = L"%sogou%";
        TiXmlDocument xmlDoc;
        const TiXmlElement *pXmlSogou = NULL;
        const TiXmlElement *pXmlGeneral = NULL;
        if (!xmlDoc.LoadFile(UnicodeToAnsi(strTemp.c_str()).c_str(), TIXML_ENCODING_UTF8))
            goto Exit0;
        pXmlSogou = xmlDoc.FirstChildElement("main");
        if (!pXmlSogou)
            goto Exit0;
        pXmlGeneral = pXmlSogou->FirstChildElement("Item");
        if (pXmlGeneral && pXmlGeneral->Attribute("videoacccachepath"))
        {
            const char* szTmp = pXmlGeneral->Attribute("videoacccachepath");
            if(!szTmp)
                strResult = L"%sogou%";
            else 
                strResult = Utf8ToUnicode(szTmp).c_str();
        }
        // 过滤根目录
        if (strResult.GetLength() <= 3)
            strResult = L"%sogou%";
        goto Exit0;
    }
    else if (CString("usertemp").CompareNoCase(pszName) == 0)
    {
        TCHAR szBuffer[MAX_PATH] = { 0 };
        CString strPath;
        CString strEnvName = L"%TEMP%";
        CString strEnvPath;

        ExpandEnvironmentStrings(strEnvName, strEnvPath.GetBuffer(MAX_PATH), MAX_PATH);
        strEnvPath.ReleaseBuffer();
        
        StandardPath(strEnvPath);
    
        UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);

        if (uResult < 3 || szBuffer[1] != TEXT(':') || szBuffer[2] != TEXT('\\'))
        {
            goto Exit0;     
        }
        szBuffer[3] = TEXT('\0');
        strPath += szBuffer;
        memset(szBuffer, 0, sizeof(szBuffer));
        DWORD MaxSize = sizeof(szBuffer);
        GetUserName(szBuffer, &MaxSize);

        if (KGetWinVersion() >= 4) 
        {
            strPath += L"Users\\"; 
            strPath += szBuffer; 
            strPath += L"\\AppData\\Local\\Temp\\";
        }
        else
        {
            strPath += L"Documents and Settings\\"; 
            strPath += szBuffer; 
            strPath += L"\\Local Settings\\Temp\\";
        }
        //
        if (strPath.CompareNoCase(strEnvPath) == 0 
            || strPath.Find(strEnvPath) != -1
            || strEnvPath.Find(strPath) != -1)
        {
            strResult = L"";
        }
        else
        {
            strResult = strPath;
        }
        goto Exit0;
    }
    else if (CString("wintemp").CompareNoCase(pszName) == 0)
    {
        DWORD len = sizeof(szLongPathBuffer);
        GetRegistryValue(HKEY_LOCAL_MACHINE,
            L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",
            L"TEMP",
            NULL,
            (LPBYTE)szLongPathBuffer,
            &len
            );
        if (wcslen(szLongPathBuffer) == 0)
        {
            strResult = L"";
        }
        else
        {
            if (CString("%SystemRoot%\\TEMP").CompareNoCase(szLongPathBuffer) == 0)
            {
                strResult = L"";
            }
            else
            {
                //解析环境变量
                CString strWinPath = szLongPathBuffer;

                int nFirstPos  = 0; 
                int nSecondPos = 0;
                BOOL bFind = FALSE;

                bFind = FindEnvironmentPos(strWinPath, nFirstPos, nSecondPos);
                
                if (bFind)
                {
                    CString strEnvName;
                    CString strEnvPath;
                    CString strLeft;
                    CString strRight;
                    strLeft = strWinPath.Left(nFirstPos);
                    strEnvName = strWinPath.Mid(nFirstPos, nSecondPos - nFirstPos + 1);
                    strRight = strWinPath.Mid(nSecondPos + 1);

                    ExpandEnvironmentStrings(strEnvName, strEnvPath.GetBuffer(MAX_PATH), MAX_PATH);
                    strEnvPath.ReleaseBuffer();
                    strResult += strLeft;
                    strResult += strEnvPath;
                    strResult += strRight;

                    UINT uResult = GetWindowsDirectory(szBuffer, MAX_PATH);

                    if(szBuffer[wcslen(szBuffer)-1] == _T('\\'))
                        szBuffer[wcslen(szBuffer)-1] = _T('\0');

                    CString strNormal = szBuffer;

                    strNormal += L"\\Temp\\";

                    StandardPath(strResult);

                    // 根目录跳过 和 子目录过滤,同时过滤 
                    if (strResult.GetLength() <= 3 
                        || strResult.Find(strNormal) != -1
                        || strNormal.Find(strResult) != -1)
                    {
                        strResult = L"";
                    }

                }
                else
                {
                    strResult = szLongPathBuffer;
                }
            }
        }
        goto Exit0;
    }
    else if (CString("office").CompareNoCase(pszName) == 0)
    {
        CString strDriverName;
        std::vector<CString> vecDrive;
        std::vector<CString>::iterator ite;

        TCHAR   szDriverName[500]; 

        DWORD nLength = GetLogicalDriveStrings(sizeof(szDriverName), szDriverName); 

        for (int i = 0; i < (int)nLength; i++) 
        { 
            if (szDriverName[i] != L'\0')
            {
                strDriverName += szDriverName[i]; 
            }
            else 
            { 
                strDriverName = strDriverName.Left(strDriverName.GetLength() - 1); 
                vecDrive.push_back(strDriverName); 
                strDriverName = ""; 
            } 
        }

        if (vecDrive.size() <= 0)
            goto Exit0;

        // 枚举盘符
        for (ite = vecDrive.begin(); ite != vecDrive.end(); ++ite)
        {
            CString strPath = (*ite) + _T("\\MSOCache");
            BOOL bRet = PathFileExists(strPath);

            if (bRet) 
            {
                strResult = strPath;
                break;
            }
        }
        goto Exit0;
    }
    else if (CString("qqmusic").CompareNoCase(pszName) == 0)
    {
        WCHAR szPath[MAX_PATH] = {0};
        std::wstring strPath;
        std::wstring strTemp;

        SHGetSpecialFolderPath(NULL, szPath, CSIDL_APPDATA, FALSE);
        strPath = szPath;

        if (strPath.rfind(L'\\') != strPath.size())
        {
            strPath += L"\\";
        }
        strPath += L"Tencent\\QQMusic\\CachePath.ini";
        IniEditor inif;
        inif.SetFile(strPath.c_str());
        strTemp = inif.ReadString(L"Cache", L"Path");
        if(strTemp.find(L"//") != -1)
        {
            strTemp.replace(strTemp.find(L"//"), 1, L"\\");
        }

        strResult += strTemp.c_str();

        if (strResult.IsEmpty())
            goto Exit0;

        if (strResult[strResult.GetLength() - 1] != _T('\\'))
            strResult += _T('\\');

        strResult += L"musiccache";

        goto Exit0;
    }
    else if (CString("kuwo").CompareNoCase(pszName) == 0)
    {
        WCHAR szPath[MAX_PATH] = {0};
        std::wstring strPath;
        std::wstring strTemp;

        SHGetSpecialFolderPath(NULL, szPath, CSIDL_COMMON_APPDATA, FALSE);
        strPath = szPath;

        if (strPath.rfind(L'\\') != strPath.size())
        {
            strPath += L"\\";
        }
        strPath += L"kuwo\\conf\\user\\config.ini";
        IniEditor inif;

        inif.SetFile(strPath.c_str());
        strTemp = inif.ReadString(L"Setting", L"temppath");
        if(strTemp.find(L"//") != -1)
        {
            strTemp.replace(strTemp.find(L"//"), 1, L"\\");
        }

        strResult = strTemp.c_str();

        goto Exit0;
    }
    else if (CString("ttplayer").CompareNoCase(pszName) == 0)
    {
        DWORD len = sizeof(szLongPathBuffer);
        TCHAR szDefault[MAX_PATH * 2] = { 0 };
        SHGetSpecialFolderPath(NULL, szDefault, CSIDL_APPDATA, FALSE);
        PathAppend(szDefault, L"TTPlayer\\cache");

        GetRegistryValue(HKEY_LOCAL_MACHINE,
            L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\TTPlayer",
            L"AppPath",
            NULL,
            (LPBYTE)szLongPathBuffer,
            &len
            );
        if(wcslen(szLongPathBuffer) == 0)
        {
            strResult = L"%ttplayer%";
        }
        else
        {
            ::PathRemoveFileSpec(szLongPathBuffer);
            ::PathAppend(szLongPathBuffer,L"TTPlayer.xml");
            TiXmlDocument xmlDoc;
            const TiXmlElement *pXmlTTPlayer = NULL;
            const TiXmlElement *pXmlGeneral = NULL;
            if (!xmlDoc.LoadFile(UnicodeToAnsi(szLongPathBuffer).c_str(), TIXML_ENCODING_UTF8))
                goto Exit0;

            pXmlTTPlayer = xmlDoc.FirstChildElement("ttplayer");
            if (!pXmlTTPlayer)
                goto Exit0;

            pXmlGeneral = pXmlTTPlayer->FirstChildElement("Network");
            if (pXmlGeneral)
            {
                const char* szTmp = pXmlGeneral->Attribute("CacheFolder");
                if(!szTmp)
                    strResult = L"%ttplayer%";
                else 
                    strResult = Utf8ToUnicode(szTmp).c_str();
            }
            
        }

        if (strResult.Find(szDefault) != -1 || strResult.GetLength() <= 3)
            strResult = L"%ttplayer%";

        goto Exit0;
    }
    else if (CString("ksafe").CompareNoCase(pszName) == 0)
    {
//         WCHAR szPath[MAX_PATH] = { 0 };
//         WCHAR szCmdline[MAX_PATH * 2] = { 0 };
//         ::GetModuleFileName(NULL, szPath, MAX_PATH);
// 
//         ::PathRemoveFileSpec(szPath);
//         std::wstring strIniPath = szPath;
//         std::wstring strTemp;
// 
//         strIniPath += L"\\cfg\\vulfix.ini";
// 
// //         IniEditor inif;
// // 
// //         inif.SetFile(strIniPath.c_str());
// //         strTemp = inif.ReadString(L"Main", L"downpath");
// //         if(strTemp.find(L"//") != -1)
// //         {
// //             strTemp.replace(strTemp.find(L"//"), 1, L"\\");
// //         }
// 
//         if (strTemp.length() == 0)
//         {
//             strResult = szPath;
//             strResult += L"\\hotfix";
//         }
//         else
//         {
//             strResult = strTemp.c_str();
//         }
        goto Exit0;
    }
    DWORD dwResult = GetEnvironmentVariable(pszName, szBuffer, MAX_PATH);
    if (dwResult > 0)
    {
        dwResult = 0;

        LPSTR pFileName = NULL;

        if (m_pfnGetLongPathName != NULL) 
            dwResult = m_pfnGetLongPathName(szBuffer, szLongPathBuffer, MAX_PATH);

        strResult = dwResult ? szLongPathBuffer : szBuffer;
    }
Exit0:
   
    return strResult;
}
Exemplo n.º 27
0
STDMETHODIMP CGitExtensionsShellEx::QueryContextMenu(
    HMENU hMenu, UINT menuIndex, UINT uidFirstCmd, UINT uidLastCmd, UINT uFlags)
{
    DBG_TRACE(L"CGitExtensionsShellEx::QueryContextMenu(menuIndex=%u,uidLastCmd=%u,uFlags=%u)", menuIndex, uidLastCmd, uFlags);
    // If the flags include CMF_DEFAULTONLY then we shouldn't do anything.
    if (uFlags & CMF_DEFAULTONLY)
        return S_OK;

    //check if we already added our menu entry for a folder.
    //we check that by iterating through all menu entries and check if
    //the dwItemData member points to our global ID string. That string is set
    //by our shell extension when the folder menu is inserted.
    TCHAR menubuf[MAX_PATH];
    int count = GetMenuItemCount(hMenu);
    for (int i=0; i<count; ++i)
    {
        MENUITEMINFO miif;
        SecureZeroMemory(&miif, sizeof(MENUITEMINFO));
        miif.cbSize = sizeof(MENUITEMINFO);
        miif.fMask = MIIM_DATA;
        miif.dwTypeData = menubuf;
        miif.cch = _countof(menubuf);
        GetMenuItemInfo(hMenu, i, TRUE, &miif);
        if (miif.dwItemData == (ULONG_PTR)_Module.GetModuleInstance())
        {
            DBG_TRACE(L"Menu already added");
            return S_OK;
        }
    }

    CString szCascadeShellMenuItems = GetRegistryValue(HKEY_CURRENT_USER, L"SOFTWARE\\GitExtensions", L"CascadeShellMenuItems");
    if (szCascadeShellMenuItems.IsEmpty())
        szCascadeShellMenuItems = "110111000111111111";
    bool cascadeContextMenu = szCascadeShellMenuItems.Find('1') != -1;
    bool alwaysShowAllCommands = GetRegistryBoolValue(HKEY_CURRENT_USER, L"SOFTWARE\\GitExtensions", L"AlwaysShowAllCommands");

    HMENU popupMenu = NULL;
    if (cascadeContextMenu)
        popupMenu = CreateMenu();

    bool isValidDir = true;
    bool isFolder = true;
    if (!alwaysShowAllCommands)
    {
        isValidDir = IsValidGitDir(m_szFile);
        isFolder = !IsFileExists(m_szFile);
    }

    // preset values, if not used
    commandsId.clear();

    UINT submenuIndex = 0;
    int id = 0;
    int cmdid;
    bool isSubMenu;

    if (alwaysShowAllCommands || !isValidDir)
    {
        isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcClone);
        cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Clone...", IDI_ICONCLONEREPOGIT, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
        commandsId[cmdid]=gcClone;

        isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcCreateRepository);
        cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Create new repository...", IDI_ICONCREATEREPOSITORY, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
        commandsId[cmdid]=gcCreateRepository;
    }
    if (isValidDir)
    {
        isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcBrowse);
        cmdid = AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Browse", IDI_ICONBROWSEFILEEXPLORER, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
        commandsId[cmdid]=gcBrowse;

        if (isFolder)
        {
            isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcCommit);
            cmdid = AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Commit...", IDI_ICONCOMMIT, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
            commandsId[cmdid]=gcCommit;

            isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcPull);
            cmdid = AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Pull...", IDI_ICONPULL, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
            commandsId[cmdid]=gcPull;

            isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcPush);
            cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Push...", IDI_ICONPUSH, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
            commandsId[cmdid]=gcPush;

            isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcStash);
            cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"View stash", IDI_ICONSTASH, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
            commandsId[cmdid]=gcStash;

            isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcViewDiff);
            cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"View changes", IDI_ICONVIEWCHANGES, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
            commandsId[cmdid]=gcViewDiff;

            isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcCheckoutBranch);
            if (isSubMenu && submenuIndex > 0) {
                InsertMenu(popupMenu, submenuIndex++, MF_SEPARATOR|MF_BYPOSITION, 0, NULL); ++id;
            }
            cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Checkout branch...", IDI_ICONBRANCHCHECKOUT, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
            commandsId[cmdid]=gcCheckoutBranch;

            isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcCheckoutRevision);
            cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Checkout revision...", IDI_ICONREVISIONCHECKOUT, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
            commandsId[cmdid]=gcCheckoutRevision;

            isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcCreateBranch);
            cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Create branch...", IDI_ICONBRANCHCREATE, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
            commandsId[cmdid]=gcCreateBranch;
        }

        isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcDiffTool);
        if (isSubMenu && submenuIndex > 0) {
            InsertMenu(popupMenu, submenuIndex++, MF_SEPARATOR|MF_BYPOSITION, 0, NULL); ++id;
        }
        cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Open with difftool", IDI_ICONVIEWCHANGES, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
        commandsId[cmdid]=gcDiffTool;

        isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcFileHistory);
        cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"File history", IDI_ICONFILEHISTORY, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
        commandsId[cmdid]=gcFileHistory;

        isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcResetFileChanges);
        cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Reset file changes...", IDI_ICONTRESETFILETO, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
        commandsId[cmdid]=gcResetFileChanges;

        isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcAddFiles);
        cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Add files...", IDI_ICONADDED, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
        commandsId[cmdid]=gcAddFiles;

        isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcApplyPatch);
        cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Apply patch...", 0, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
        commandsId[cmdid]=gcApplyPatch;
    }

    isSubMenu = DisplayInSubmenu(szCascadeShellMenuItems, gcSettings);
    if (isSubMenu && submenuIndex > 0) {
        InsertMenu(popupMenu, submenuIndex++, MF_SEPARATOR|MF_BYPOSITION, 0, NULL); ++id;
    }
    cmdid=AddMenuItem(!isSubMenu ? hMenu : popupMenu, L"Settings", IDI_ICONSETTINGS, uidFirstCmd, ++id, !isSubMenu ? menuIndex++ : submenuIndex++, isSubMenu);
    commandsId[cmdid]=gcSettings;

    ++id;

    if (cascadeContextMenu)
    {
        MENUITEMINFO info;
        info.cbSize = sizeof(MENUITEMINFO);
        info.fMask = MIIM_STRING | MIIM_ID | MIIM_BITMAP | MIIM_SUBMENU;
        info.wID = uidFirstCmd + 1;
        info.hbmpItem = IsVistaOrLater() ? IconToBitmapPARGB32(IDI_GITEXTENSIONS) : HBMMENU_CALLBACK;
        myIDMap[1] = IDI_GITEXTENSIONS;
        myIDMap[uidFirstCmd + 1] = IDI_GITEXTENSIONS;
        info.dwTypeData = _T("Git Extensions");
        info.hSubMenu = popupMenu;
        InsertMenuItem(hMenu, menuIndex, true, &info);
    }

    return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, id);
}
Exemplo n.º 28
0
//////////////////////////////////////////////////////////
//
// CInstallManager::_ProcessLayoutChecks
//
// Make sure new reg/dir structure is ok
//
//////////////////////////////////////////////////////////
SString CInstallManager::_ProcessLayoutChecks ( void )
{
    //
    // Validation
    //

    // Check data dir exists
    {
        if ( !DirectoryExists ( GetMTADataPath () ) )
            ShowLayoutError ( "[Data directory not present]" );   // Can't find directory
    }

    // Check reg key exists
    //{
    //    if ( GetRegistryValue ( "", "Last Install Location" ).empty () )
    //        ShowLayoutError ( "[Registry key not present]" );   // Can't find reg key
    //}

    // Check data dir writable
    {
        SString strTestFilePath = PathJoin ( GetMTADataPath (), "testdir", "testfile.txt" );

        FileDelete ( strTestFilePath );
        RemoveDirectory ( ExtractPath ( strTestFilePath ) );

        SString strContent = "test";
        if ( !FileSave ( strTestFilePath, strContent ) )
            ShowLayoutError ( "[Data directory not writable]" );   // Can't save file

        FileDelete ( strTestFilePath );
        RemoveDirectory ( ExtractPath ( strTestFilePath ) );
    }

    // Check reg key writable
    {
        RemoveRegistryKey ( "testkeypath" );

        SString strValue = GetTimeString( true, true );
        SetRegistryValue ( "testkeypath", "testname", strValue );
        SString strValueCheck = GetRegistryValue ( "testkeypath", "testname" );
        if ( strValueCheck != strValue )
            ShowLayoutError ( "[Registry key not writable]" );   // Can't write reg key

        RemoveRegistryKey ( "testkeypath" );
    }

    // Check install dir writable
    {
        SString strTestFilePath = CalcMTASAPath ( PathJoin ( "mta", "writetest.txt" ) );

        FileDelete ( strTestFilePath );

        SString strContent = "test";
        if ( !FileSave ( strTestFilePath, strContent ) )
            ShowLayoutError ( "[Install directory not writable]" );   // Can't save file

        FileDelete ( strTestFilePath );
    }

    //
    // Migration
    //

    // If news/temp/upcache folder doesn't exist in new, but does in old place, move it
    {
        const char* folders[] = { "news", "temp", "upcache" };
        for ( uint i = 0 ; i < NUMELMS( folders ) ; i++ )
        {
            SString strSrc = PathJoin ( GetSystemLocalAppDataPath (), "MTA San Andreas " + GetMajorVersionString (), folders[i] );
            SString strDest = PathJoin ( GetMTADataPath (), folders[i] );
            if ( !DirectoryExists ( strDest ) && DirectoryExists ( strSrc ) )
                MoveFile ( strSrc, strDest );
        }
    }

    // If aero option reg entry doesn't exist in new, but does in old place, move it
    {
        if ( GetApplicationSetting ( "aero-enabled" ).empty () )
        {
            SString strLegacyValue = GetVersionRegistryValueLegacy ( GetMajorVersionString (), PathJoin ( "Settings", "general" ), "aero-enabled" );
            if ( !strLegacyValue.empty () )
                SetApplicationSettingInt ( "aero-enabled", atoi ( strLegacyValue ) );
            else
                SetApplicationSettingInt ( "aero-enabled", 1 );
        }
    }

    return "ok";
}
Exemplo n.º 29
0
BOOL CKartenCtrl::OnProjectOpen( LPCTSTR pszNewProject ) {
    ASSERT(m_listOfSights.IsEmpty());
    ASSERT(m_listOfMaps.IsEmpty());

    m_hPr = 0;

// KK001220
// Projekt ( *.riw) enthält kein Kartenverzeichnis
// - in Datenquellen suchen und Liste kumulieren

    CTriasVMD::OnProjectOpen( pszNewProject );

    m_strDQ.clear();	// Verzeichnis der Datenquellen (HPROJECT,DATEI)

    SetDQ();

    m_strKVZ.clear();

    SetKVZ();	// For Each der Datenquellen !!

    m_strKVZCodes.clear();

    SetKVZCodes();	// For Each der Datenquellen-HeaderEinträge !!

    m_hPr = DEX_GetDataSourceHandle();

//----------------------------------------------------------------------------
// KK010105
    /*--------------------
    // Durchsuchen der INI-DatenquellenDateien

    	CString	myIniSection, myIniEntry;

    	VERIFY( myIniSection.LoadString( IDS_MYINISECTION ) );
    	VERIFY( myIniEntry.LoadString( IDS_MAPDIRENTRY ) );

    	CString	strMapDir;
    	char	ch;
    	for( int i = 1;; i++ ) {
    		strMapDir.Format( "%s%d", (LPCTSTR) myIniEntry, i );
    		strMapDir = GetProfileString( myIniSection, strMapDir ); // myIniEntry + (char) ( '1' + i ) );
    		if( strMapDir.IsEmpty() )
    			break;
    		if( '\\' != ( ch = strMapDir[ strMapDir.GetLength() - 1 ] ) && '/' != ch )
    			strMapDir += '\\';
    		strMapDir.MakeLower();
    		m_strMapDirs.Add( strMapDir );
    	}

    // KK010105
    --------------------------------------------------------------------------------*/

// Nur, falls in allen Datenquellen kein Verzeichnis vorhanden ist, Standard setzen

    if( 0 == m_strMapDirs.GetSize() ) {

// KK001116
        CString	myIniSection, myIniEntry;
        CString	strMapDir;

        VERIFY( myIniSection.LoadString( IDS_MYINISECTION ) );
        VERIFY( myIniEntry.LoadString( IDS_MAPDIRENTRY ) );

        CString	S;
        DEX_GetDataSourceName( m_hPr, S.GetBufferSetLength( _MAX_PATH ) );
        CPath	pathOfProj( S );

        VERIFY( myIniEntry.LoadString( IDS_DEFMAPDIR ) );
        strMapDir = pathOfProj.Drive() + pathOfProj.Dir() + myIniEntry;
        m_strMapDirs.Add( strMapDir );
    }


//--------------------------------------------------------------------------------

    /*-----------------------------KK010111---------------------------------------------

    	CString	strHdrValue;

    	if( GetGeoDBEntry( m_hPr,szOldPdbEntry, strHdrValue ) ) {
    		::LAfxExtractSubBase( m_lMapMCode, m_nMCodeBase, strHdrValue, 1, ';' );
    		::LAfxExtractSubBase( m_lPalMCode, m_nMCodeBase, strHdrValue, 2, ';' );
    	}

    	if( GetGeoDBEntry(m_hPr, szTKPdbEntry, strHdrValue ) )
    		::LAfxExtractSubBase( m_lMapMCode, m_nMCodeBase, strHdrValue, 0, ';' );

    	if( GetGeoDBEntry(m_hPr, szViewPdbEntry, strHdrValue ) )
    		::LAfxExtractSubBase( m_lPalMCode, m_nMCodeBase, strHdrValue, 0, ';' );

    */
    CString	strHdrValue;
    GetGeoDBEntry(HACTPROJECT, szMatchPdbEntry, strHdrValue);

    /*
    	CString	strHdrData;
    	GetGeoDBEntry( m_hPr,szDataPdbEntry, strHdrData );
    */
// KK010109
// Parameter @TopKartMatch in DB-Header : falls true - Bildname über uniqueIdent ( TK@...)
//	m_bMatchMapName = strHdrValue.IsEmpty() ? TRUE : (BOOL) atol( strHdrValue );
    m_bMatchMapName = strHdrValue.IsEmpty() ? FALSE : (BOOL) atol( strHdrValue );

    /*
    	if( 0L == m_lMapMCode )
    		m_lMapMCode = 99999301;

    	if( 0L == m_lPalMCode )
    		m_lPalMCode = 99999302;


    -----------------------------KK010111---------------------------------------------*/

    m_bProjDrawn = FALSE;

    m_minSize = 5.0;
    COleVariant	v;
    GetRegistryValue( _T("MinimumSize"), v );
    if( VT_I4 == v.vt ) {
        m_minSize = (double) v.lVal;
    } else if( VT_BSTR == v.vt ) {
        strHdrValue = v.bstrVal;
        m_minSize = atof(strHdrValue);
    }
    return TRUE;
}
int CGitExtensionsShellEx::PopulateMenu(HMENU hMenu, int id, bool isSubMenu)
{
    CString szShellVisibleMenuItems = GetRegistryValue(HKEY_CURRENT_USER, "SOFTWARE\\GitExtensions\\GitExtensions", "ShellVisibleMenuItems");

    // preset values, if not used
    AddFilesId = -1;
    ApplyPatchId = -1;
    BrowseId = -1;
    CreateBranchId = -1;
    CheckoutBranchId = -1;
    CheckoutRevisionId = -1;
    CloneId = -1;
    CommitId = -1;
    FileHistoryId = -1;
    PullId = -1;
    PushId = -1;
    SettingsId = -1;
    ViewDiffId = -1;
    ResetFileChangesId = -1;

    int pos = 0;

    if (isSubMenu)
    {
        if (IsMenuItemVisible(szShellVisibleMenuItems, 0))
            AddMenuItem(hMenu, "Add files", ++id, AddFilesId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 1))
            AddMenuItem(hMenu, "Apply patch", ++id, ApplyPatchId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 2))
            AddMenuItem(hMenu, "Browse", ++id, BrowseId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 3))
            AddMenuItem(hMenu, "Create branch", ++id, CreateBranchId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 4))
            AddMenuItem(hMenu, "Checkout branch", ++id, CheckoutBranchId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 5))
            AddMenuItem(hMenu, "Checkout revision", ++id, CheckoutRevisionId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 6))
            AddMenuItem(hMenu, "Clone", ++id, CloneId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 7))
            AddMenuItem(hMenu, "Commit", ++id, CommitId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 8))
            AddMenuItem(hMenu, "File history", ++id, FileHistoryId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 9))
            AddMenuItem(hMenu, "Reset file changes", ++id, ResetFileChangesId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 10))
            AddMenuItem(hMenu, "Pull", ++id, PullId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 11))
            AddMenuItem(hMenu, "Push", ++id, PushId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 12))
            AddMenuItem(hMenu, "Settings", ++id, SettingsId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 13))
            AddMenuItem(hMenu, "View diff", ++id, ViewDiffId=pos++);
    }

    else
    {
        if (IsMenuItemVisible(szShellVisibleMenuItems, 0))
            AddMenuItem(hMenu, "GitExtensions Add files", ++id, AddFilesId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 1))
            AddMenuItem(hMenu, "GitExtensions Apply patch", ++id, ApplyPatchId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 2))
            AddMenuItem(hMenu, "GitExtensions Browse", ++id, BrowseId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 3))
            AddMenuItem(hMenu, "GitExtensions Create branch", ++id, CreateBranchId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 4))
            AddMenuItem(hMenu, "GitExtensions Checkout branch", ++id, CheckoutBranchId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 5))
            AddMenuItem(hMenu, "GitExtensions Checkout revision", ++id, CheckoutRevisionId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 6))
            AddMenuItem(hMenu, "GitExtensions Clone", ++id, CloneId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 7))
            AddMenuItem(hMenu, "GitExtensions Commit", ++id, CommitId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 8))
            AddMenuItem(hMenu, "GitExtensions File history", ++id, FileHistoryId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 9))
            AddMenuItem(hMenu, "GitExtensions Reset file changes", ++id, ResetFileChangesId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 10))
            AddMenuItem(hMenu, "GitExtensions Pull", ++id, PullId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 11))
            AddMenuItem(hMenu, "GitExtensions Push", ++id, PushId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 12))
            AddMenuItem(hMenu, "GitExtensions Settings", ++id, SettingsId=pos++);

        if (IsMenuItemVisible(szShellVisibleMenuItems, 13))
            AddMenuItem(hMenu, "GitExtensions View diff", ++id, ViewDiffId=pos++);
    }

    ++id;
    return id;
}