信頼するサイトの登録と設定


  Win32 Console Application で MFC の CString を使用




http://winofsql.jp/VA003334/asp051101194921.htm の C++ バージョンです

API のラップ関数は、API の引数の型が明示できるように、引数を参照で定義しています
また、MFC はスタティックライブラリを使用しています

  

#include "stdafx.h"
#include <afx.h>

BOOL LboxOpenReg( HKEY hRoot, LPCTSTR lpSubKey, HKEY &hNew );
BOOL LboxGetDword( HKEY hKey, LPCTSTR lpEntry, DWORD &Value );
BOOL LboxSetDword( HKEY hKey, LPCTSTR lpEntry, DWORD dwValue );

CString domain = "";
CString server = "layla";

int main(int argc, char* argv[])
{
	BOOL bRet;
	HKEY hKey;
	CString strRegPath;

	// *********************************************************
	// このゾーンのサイトには全てサーバーの確認 (https:) を必要とする
	// というチェックを外す
	// *********************************************************
	strRegPath = 
		"Software\\Microsoft\\Windows\\CurrentVersion\\"
		"Internet Settings\\Zones\\2";
	bRet = ::LboxOpenReg(
		HKEY_CURRENT_USER,
		(LPCTSTR)strRegPath,
		hKey
	);

	if ( bRet ) {
		DWORD dw;

		if ( ::LboxGetDword( hKey, "Flags", dw ) ) {
			dw &= 0xfffffffb;
			::LboxSetDword( hKey, "Flags", dw );
		}

		RegCloseKey( hKey );
	}


	// *********************************************************
	// サイトの登録
	// *********************************************************
	strRegPath = 
		"Software\\Microsoft\\Windows\\CurrentVersion\\"
		"Internet Settings\\ZoneMap\\Domains\\";

	if ( domain != "" ) {
		strRegPath += ( domain + "\\" );
	}
	strRegPath += server;

	bRet = ::LboxOpenReg(
		HKEY_CURRENT_USER,
		(LPCTSTR)strRegPath,
		hKey
	);
	
	if ( bRet ) {
		::LboxSetDword( hKey, "http", 2 );
		RegCloseKey( hKey );
	}
	
	// *********************************************************
	// 詳細設定
	// *********************************************************
	strRegPath = 
		"Software\\Microsoft\\Windows\\CurrentVersion\\"
		"Internet Settings\\Zones\\2";
	bRet = ::LboxOpenReg(
		HKEY_CURRENT_USER,
		(LPCTSTR)strRegPath,
		hKey
	);

	if ( bRet ) {
		// ActiveX コントロールとプラグインの実行
		::LboxSetDword( hKey, "1200", 0 );

		// スクリプトを実行しても安全だとマークされていない
		// ActiveX コントロールの初期化とスクリプトの実行
		::LboxSetDword( hKey, "1201", 0 );

		// スクリプトを実行しても安全だとマークされている
		// ActiveX コントロールのスクリプトの実行
		::LboxSetDword( hKey, "1405", 0 );

		// 署名済み ActiveX コントロールのダウンロード
		::LboxSetDword( hKey, "1001", 0 );

		// 未署名の ActiveX コントロールのダウンロード
		::LboxSetDword( hKey, "1004", 0 );

		// 未署名の ActiveX コントロールのダウンロード
		::LboxSetDword( hKey, "1004", 0 );

		// Java アプレットのスクリプト
		::LboxSetDword( hKey, "1402", 0 );

		// アクティブ スクリプト
		::LboxSetDword( hKey, "1400", 0 );

		// スクリプトによる貼り付け処理の許可
		::LboxSetDword( hKey, "1407", 0 );

		// ドメイン間でのデータ ソースのアクセス
		::LboxSetDword( hKey, "1406", 0 );

		RegCloseKey( hKey );
	}

	return 0;
}

// *********************************************************
// レジストリキーの作成
// *********************************************************
BOOL LboxOpenReg( HKEY hRoot, LPCTSTR lpSubKey, HKEY &hNew )
{
	LONG nRet;
	DWORD dwDisposition;

	nRet = RegCreateKeyEx(
		hRoot,
		lpSubKey,
		0,
		NULL,
		REG_OPTION_NON_VOLATILE,
		KEY_ALL_ACCESS,
		NULL,
		&hNew,
		&dwDisposition
	);

	if ( nRet == ERROR_SUCCESS ) {
		return true;
	}
	return false;
}

// *********************************************************
// DWORD 値の取得
// *********************************************************
BOOL LboxGetDword( HKEY hKey, LPCTSTR lpEntry, DWORD &Value )
{
	DWORD nType,nSize;
	LONG nRet;

	nSize = 4;

	nRet = RegQueryValueEx(
		hKey,
		lpEntry,
		NULL,
		&nType,
		(LPBYTE)(&Value),
		(unsigned long *)(&nSize)
	);

	if ( nRet == ERROR_SUCCESS ) {
		return true;
	}
	else {
		return false;
	}
}

// *********************************************************
// DWORDの登録
// *********************************************************
BOOL LboxSetDword( HKEY hKey, LPCTSTR lpEntry, DWORD dwValue )
{
	LONG nRet;
	long nLen;

	nLen = 4;

	nRet =  RegSetValueEx(
		hKey,
		lpEntry,
		0,
		REG_DWORD,
		(const unsigned char *)&dwValue,
		nLen
	);

	if ( nRet == ERROR_SUCCESS ) {
		return true;
	}
	else {
		return false;
	}
}
  










yahoo  google  MSDN  MSDN(us)  WinFAQ  Win Howto  tohoho  ie_DHTML  vector  wdic  辞書  天気 


[Cprog]
Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
24/04/20 18:10:46
InfoBoard Version 1.00 : Language=Perl

1 BatchHelper COMprog CommonSpec Cprog CprogBase CprogSAMPLE CprogSTD CprogSTD2 CprogWinsock Cygwin GameScript HTML HTMLcss InstallShield InstallShieldFunc JScript JScriptSAMPLE Jsfuncs LLINK OldProg OracleGold OracleSilver PRO PRObrowser PROc PROconePOINT PROcontrol PROftpclient PROjscript PROmailer PROperl PROperlCHAT PROphp PROphpLesson PROphpLesson2 PROphpLesson3 PROphpfunction PROphpfunctionArray PROphpfunctionMisc PROphpfunctionString PROsql PROvb PROvbFunction PROvbString PROvbdbmtn PROvbonepoint PROwebapp PROwin1POINT PROwinSYSTEM PROwinYOROZU PROwindows ProjectBoard RealPHP ScriptAPP ScriptMaster VBRealtime Vsfuncs a1root access accreq adsi ajax amazon argus asp aspSample aspVarious aspdotnet aw2kinst cappvariety centura ckeyword classStyle cmaterial cmbin cmdbapp cmenum cmlang cmlistbox cmstd cmstdseed cmtxt cs daz3d db dbCommon dbaccess dnettool dos download flex2 flex3 flex4 framemtn framereq freeWorld freesoft gimp ginpro giodownload google hdml home hta htmlDom ie9svg install java javaSwing javascript jetsql jquery jsp jspTest jspVarious lightbox listasp listmsapi listmsie listmsiis listmsnt listmspatch listmsscript listmsvb listmsvc memo ms msde mysql netbeans oraPlsql oracle oracleWiper oraclehelper orafunc other panoramio pear perl personal pgdojo pgdojo_cal pgdojo_holiday pgdojo_idx pgdojo_ref pgdojo_req php phpVarious phpguide plsql postgres ps r205 realC realwebapp regex rgaki ruby rule sboard sc scprint scquest sdb sdbquest seesaa setup sh_Imagick sh_canvas sh_dotnet sh_google sh_tool sh_web shadowbox shgm shjquery shvbs shweb sjscript skadai skywalker smalltech sperl sqlq src systemdoc tcpip tegaki three toolbox twitter typeface usb useXML vb vbdb vbsfunc vbsguide vbsrc vpc wcsignup webanymind webappgen webclass webparts webtool webwsh win8 winofsql wmi work wp youtube