コード例 #1
0
    void CfgTest::SetARP(LPCWSTR wzKeyName, LPCWSTR wzDisplayName, LPCWSTR wzInstallLocation, LPCWSTR wzUninstallString)
    {
        HRESULT hr = S_OK;
        HKEY hkArp = NULL;
        HKEY hkNew = NULL;

        hr = RegOpen(HKEY_CURRENT_USER, ARP_REG_KEY, KEY_WOW64_32KEY | KEY_ALL_ACCESS, &hkArp);
        ExitOnFailure1(hr, "Failed to open fake ARP regkey: %ls", ARP_REG_KEY);

        hr = RegDelete(hkArp, wzKeyName, REG_KEY_32BIT, TRUE);
        if (E_FILENOTFOUND == hr)
        {
            hr = S_OK;
        }
        ExitOnFailure1(hr, "Failed to delete subkey: %ls", wzKeyName);

        if (NULL != wzDisplayName)
        {
            hr = RegCreate(hkArp, wzKeyName, KEY_WOW64_32KEY | KEY_ALL_ACCESS, &hkNew);
            ExitOnFailure1(hr, "Failed to create subkey: %ls", wzKeyName);

            hr = RegWriteString(hkNew, L"DisplayName", wzDisplayName);
            ExitOnFailure(hr, "Failed to write DisplayName to registry");

            hr = RegWriteString(hkNew, L"UninstallString", wzUninstallString);
            ExitOnFailure(hr, "Failed to write UninstallString to registry");

            hr = RegWriteString(hkNew, L"InstallLocation", wzInstallLocation);
            ExitOnFailure(hr, "Failed to write InstallLocation to registry");
        }

    LExit:
        ReleaseRegKey(hkArp);
        ReleaseRegKey(hkNew);
    }
コード例 #2
0
bool SaveViewerSettings (const char *filename, StudioModel *pModel )
{
	LONG lResult;           // Registry function result code
	DWORD dwDisposition;    // Type of key opening event

	if (filename == NULL || pModel == NULL)
		return false;

	HKEY hModelKey;
	lResult = RegViewerSettingsKey( filename, &hModelKey, &dwDisposition);

	if (lResult != ERROR_SUCCESS)  // Failure
		return false;

	RegWriteQAngle( hModelKey, "Rot", pModel->m_angles );
	RegWriteVector( hModelKey, "Trans", pModel->m_origin );
	RegWriteColor( hModelKey, "bgColor", g_viewerSettings.bgColor );
	RegWriteColor( hModelKey, "gColor", g_viewerSettings.gColor );
	RegWriteColor( hModelKey, "lColor", g_viewerSettings.lColor );
	RegWriteColor( hModelKey, "aColor", g_viewerSettings.aColor );
	RegWriteQAngle( hModelKey, "lightrot", g_viewerSettings.lightrot );
	RegWriteInt( hModelKey, "sequence", pModel->GetSequence() );
	RegWriteInt( hModelKey, "overlaySequence0", pModel->GetOverlaySequence( 0 ) );
	RegWriteFloat( hModelKey, "overlayWeight0", pModel->GetOverlaySequenceWeight( 0 ) );
	RegWriteInt( hModelKey, "overlaySequence1", pModel->GetOverlaySequence( 1 ) );
	RegWriteFloat( hModelKey, "overlayWeight1", pModel->GetOverlaySequenceWeight( 1 ) );
	RegWriteInt( hModelKey, "overlaySequence2", pModel->GetOverlaySequence( 2 ) );
	RegWriteFloat( hModelKey, "overlayWeight2", pModel->GetOverlaySequenceWeight( 2 ) );
	RegWriteInt( hModelKey, "overlaySequence3", pModel->GetOverlaySequence( 3 ) );
	RegWriteFloat( hModelKey, "overlayWeight3", pModel->GetOverlaySequenceWeight( 3 ) );
	RegWriteInt( hModelKey, "renderwidth", g_viewerSettings.width );
	RegWriteInt( hModelKey, "renderheight", g_viewerSettings.height );
	RegWriteFloat( hModelKey, "speedscale", g_viewerSettings.speedScale );
	RegWriteInt( hModelKey, "viewermode", g_viewerSettings.application_mode );
	RegWriteInt( hModelKey, "thumbnailsize", g_viewerSettings.thumbnailsize );
	RegWriteInt( hModelKey, "thumbnailsizeanim", g_viewerSettings.thumbnailsizeanim );
	RegWriteInt( hModelKey, "speechapiindex", g_viewerSettings.speechapiindex );
	RegWriteInt( hModelKey, "cclanguageid", g_viewerSettings.cclanguageid );
	RegWriteInt( hModelKey, "showground", g_viewerSettings.showGround );
	RegWriteInt( hModelKey, "showbackground", g_viewerSettings.showBackground );
	RegWriteInt( hModelKey, "showshadow", g_viewerSettings.showShadow );
	RegWriteInt( hModelKey, "showillumpos", g_viewerSettings.showIllumPosition );

	RegWriteString( hModelKey, "merge0", g_viewerSettings.mergeModelFile[0] );
	RegWriteString( hModelKey, "merge1", g_viewerSettings.mergeModelFile[1] );
	RegWriteString( hModelKey, "merge2", g_viewerSettings.mergeModelFile[2] );
	RegWriteString( hModelKey, "merge3", g_viewerSettings.mergeModelFile[3] );

	return true;
}
コード例 #3
0
ファイル: utils.cpp プロジェクト: GEO-IASS/nsis
void SaveSymbolSet(const TCHAR *name, TCHAR **symbols) {
  HKEY hCfgKey, hSymKey;
  if (CreateRegSettingsKey(hCfgKey)) {
    TCHAR subkey[SYMSET_SUBKEY_MAXLEN+1], bufName[8];
    CreateSymbolSetSubkeyPath(name, subkey);
    if (RegOpenKey(hCfgKey, subkey, &hSymKey) == ERROR_SUCCESS) {
      // Cannot use DeleteSymbolSet because name might be NULL and named sets are stored inside the base symbols key
      for (DWORD cb;;) {
        cb = sizeof(bufName);
        if (RegEnumValue(hSymKey,0, bufName, &cb,NULL,NULL,NULL,NULL)!=ERROR_SUCCESS) break;
        RegDeleteValue(hSymKey, bufName);
      }
      RegCloseKey(hSymKey);
    }
    if(symbols) {
      if (RegCreateKey(hCfgKey, subkey, &hSymKey) == ERROR_SUCCESS) {
        for (SIZE_T i = 0; symbols[i]; ++i) {
          wsprintf(bufName, _T("%d"), (INT) i);
          RegWriteString(hSymKey, bufName, symbols[i]);
        }
        RegCloseKey(hSymKey);
      }
    }
    RegCloseKey(hCfgKey);
  }
}
コード例 #4
0
ファイル: wcm-config.cpp プロジェクト: Karamax/WalCommander
void SaveStringList(const char *section, ccollect< carray<char> > &list)
{
	int n = 1;
	char name[64];

	for (int i = 0; i<list.count(); i++)
	{
		if (list[i].ptr() && list[i][0])
		{
			snprintf(name, sizeof(name), "v%i", n);
			if (!RegWriteString(section, name, list[i].ptr()))
				break;
			n++;
		}
	}

	snprintf(name, sizeof(name), "v%i", n);
	RegWriteString(section, name, "");
}
コード例 #5
0
ファイル: wcm-config.cpp プロジェクト: Karamax/WalCommander
void WcmConfig::Save( NCWin* nc )
{
	if ( nc )
	{
		leftPanelPath = new_char_str( nc->GetLeftPanel()->GetPath().GetUtf8() );
		rightPanelPath = new_char_str( nc->GetRightPanel()->GetPath().GetUtf8() );
		crect Rect = nc->ScreenRect();
		windowX = Rect.top;
		windowY = Rect.left;
		windowWidth = Rect.Width();
		windowHeight = Rect.Height();
	}
	
#ifdef _WIN32
	for (int i = 0; i<mapList.count(); i++)
	{
		Node &node = mapList[i];
		if (node.type == MT_BOOL && node.ptr.pBool != 0)
			RegWriteInt(node.section, node.name, *node.ptr.pBool);
		else
		if (node.type == MT_INT && node.ptr.pInt != 0)
			RegWriteInt(node.section, node.name, *node.ptr.pInt);
		else
		if (node.type == MT_STR && node.ptr.pStr != 0)
			RegWriteString(node.section, node.name, node.ptr.pStr->ptr());
	}
#else 
	IniHash hash;
	FSPath path = configDirPath;
	path.Push(CS_UTF8, "config");
	hash.Load((sys_char_t*)path.GetString(sys_charset_id));

	for (int i = 0; i<mapList.count(); i++)
	{
		Node &node = mapList[i];
		if (node.type == MT_BOOL && node.ptr.pBool != 0)
			hash.SetBoolValue(node.section, node.name, *node.ptr.pBool);
		else
		if (node.type == MT_INT && node.ptr.pInt != 0)
			hash.SetIntValue(node.section, node.name, *node.ptr.pInt);
		else
		if (node.type == MT_STR && node.ptr.pStr != 0)
			hash.SetStrValue(node.section, node.name, node.ptr.pStr->ptr());
	}
	
	hash.Save((sys_char_t*)path.GetString(sys_charset_id));
#endif
}
コード例 #6
0
ファイル: utils.cpp プロジェクト: GEO-IASS/nsis
void SaveCompressor()
{
  HKEY hKey;
  int n = (int)COMPRESSOR_SCRIPT;
  NCOMPRESSOR v = g_sdata.default_compressor;

  if(v >= COMPRESSOR_SCRIPT && v <= COMPRESSOR_BEST) {
    n = (int)v;
  }

  if (CreateRegSettingsKey(hKey)) {
    if (compressor_names[n][0])
      RegWriteString(hKey, REGCOMPRESSOR, compressor_names[n]);
    else
      RegDeleteValue(hKey, REGCOMPRESSOR);
    RegCloseKey(hKey);
  }
}
コード例 #7
0
ファイル: utils.cpp プロジェクト: GEO-IASS/nsis
void SaveMRUList()
{
  UINT c = 0, i;
  for (i = 0; i < MRU_LIST_SIZE; ++i)
    if (*g_mru_list[i])
      ++c;
  HKEY hCfgKey, hMRUKey;
  if (CreateRegSettingsKey(hCfgKey)) {
    if ((c ? RegCreateKey : RegOpenKey)(hCfgKey, REGMRUSUBKEY, &hMRUKey) == ERROR_SUCCESS) {
      for (i = 0; i < MRU_LIST_SIZE; ++i) {
        TCHAR bufName[8];
        wsprintf(bufName, _T("%d"), i);
        if (*g_mru_list[i])
          RegWriteString(hMRUKey, bufName, g_mru_list[i]);
        else
          RegDeleteValue(hMRUKey, bufName);
      }
      RegCloseKey(hMRUKey);
    }
    RegCloseKey(hCfgKey);
  }
}
コード例 #8
0
    void CfgTest::SetApplication(LPCWSTR wzFileName, LPCWSTR wzFilePath)
    {
        HRESULT hr = S_OK;
        HKEY hk = NULL;
        LPWSTR sczFullPath = NULL;
        LPWSTR sczQuotedCommand = NULL;

        hr = StrAllocFormatted(&sczFullPath, L"%ls\\%ls\\shell\\open\\command", APPLICATIONS_REG_KEY, wzFileName);
        ExitOnFailure(hr, "Failed to format string to full shell\\open\\command path");

        hr = RegCreate(HKEY_CURRENT_USER, sczFullPath, KEY_WOW64_32KEY | KEY_ALL_ACCESS, &hk);
        ExitOnFailure1(hr, "Failed to create key: %ls", sczFullPath);

        hr = StrAllocFormatted(&sczQuotedCommand, L"\"%ls\" \"%%1\"", wzFilePath);
        ExitOnFailure(hr, "Failed to format quoted command string");

        hr = RegWriteString(hk, NULL, sczQuotedCommand);
        ExitOnFailure(hr, "Failed to write quoted command to registry");

    LExit:
        ReleaseRegKey(hk);
        ReleaseStr(sczFullPath);
        ReleaseStr(sczQuotedCommand);
    }
コード例 #9
0
ファイル: rgdfault.cpp プロジェクト: firegiant/wix4
extern "C" HRESULT RegDefaultWriteValue(
    __in LEGACY_PRODUCT *pProduct,
    __in_z LPCWSTR wzName,
    __in const CONFIG_VALUE *pcvValue,
    __out BOOL *pfHandled
    )
{
    HRESULT hr = S_OK;
    LPWSTR sczValue = NULL;
    LPWSTR sczRegKey = NULL;
    LPWSTR sczRegValueName = NULL;
    BYTE *pbBuffer = NULL;
    SIZE_T cbBuffer = 0;
    BOOL fReleaseBuffer = FALSE;
    DWORD dwRoot = DWORD_MAX;
    HKEY hk = NULL;

    hr = MapCfgNameToRegValue(pProduct, wzName, &dwRoot, &sczRegKey, &sczRegValueName);
    if (E_INVALIDARG == hr)
    {
        *pfHandled = FALSE;
        // Not a regkey, so just ignore
        ExitFunction1(hr = S_OK);
    }
    ExitOnFailure(hr, "Failed to convert value name to registry information");
    *pfHandled = TRUE;

    hr = RegOpen(ManifestConvertToRootKey(dwRoot), sczRegKey, KEY_SET_VALUE, &hk);
    if (E_FILENOTFOUND == hr)
    {
        hr = S_OK;

        // The key doesn't exist, so no need to proceed with deleting the value
        if (VALUE_DELETED == pcvValue->cvType)
        {
            ExitFunction1(hr = S_OK);
        }
        hr = RegCreate(ManifestConvertToRootKey(dwRoot), sczRegKey, KEY_SET_VALUE, &hk);
        ExitOnFailure(hr, "Failed to create regkey: %ls", sczRegKey);
    }
    ExitOnFailure(hr, "Failed to open regkey: %ls", sczRegKey);

    switch (pcvValue->cvType)
    {
    case VALUE_DELETED:
        hr = RegWriteString(hk, sczRegValueName, NULL);
        ExitOnFailure(hr, "Failed to delete existing value");
        break;

    case VALUE_BLOB:
        switch (pcvValue->blob.cbType)
        {
        case CFG_BLOB_POINTER:
            pbBuffer = const_cast<BYTE *>(pcvValue->blob.pointer.pbValue);
            cbBuffer = pcvValue->blob.cbValue;
            break;
        case CFG_BLOB_DB_STREAM:
            fReleaseBuffer = TRUE;
            hr = StreamRead(pcvValue->blob.dbstream.pcdb, pcvValue->blob.dbstream.dwContentID, NULL, &pbBuffer, &cbBuffer);
            ExitOnFailure(hr, "Failed to read stream from database while writing binary to the registry");
            break;
        default:
            hr = E_INVALIDARG;
            ExitOnFailure(hr, "Invalid blob type encountered");
            break;
        }
        hr = RegWriteBinary(hk, sczRegValueName, pbBuffer, cbBuffer);
        ExitOnFailure(hr, "Failed to write binary value to registry");
        break;

    case VALUE_STRING:
        hr = RegWriteString(hk, sczRegValueName, pcvValue->string.sczValue);
        ExitOnFailure(hr, "Failed to write string to registry");
        break;

    case VALUE_DWORD:
        hr = RegWriteNumber(hk, sczRegValueName, pcvValue->dword.dwValue);
        ExitOnFailure(hr, "Failed to write dword to registry");
        break;

    case VALUE_QWORD:
        hr = RegWriteQword(hk, sczRegValueName, pcvValue->qword.qwValue);
        ExitOnFailure(hr, "Failed to write qword to registry");
        break;

    default:
        ExitFunction1(hr = E_INVALIDARG);
    }

LExit:
    ReleaseRegKey(hk);
    ReleaseStr(sczValue);
    ReleaseStr(sczRegKey);
    ReleaseStr(sczRegValueName);
    if (fReleaseBuffer)
    {
        ReleaseMem(pbBuffer);
    }

    return hr;
}