The Grimoire of Nonsense

個人的なメモを残すブログ

IEの「閲覧の履歴の削除」ダイアログを呼び出す

すっっっっっっっっっっっっごくどうでもいいけど、IEの履歴を削除するあのダイアログを呼び出す方法。
inetcpl.cplの中のShowDeleteBrowsingHistoryDialog()にウィンドウハンドルを渡して呼べばあのダイアログが出る。

以下サンプルプログラム

#include <cstdio>
#include <Windows.h>

typedef void( WINAPI *LPFUNC )( HWND );

int main()
{
	HMODULE hModule = LoadLibrary( R"(C:\Windows\System32\inetcpl.cpl)" );
	LPFUNC lpFunc = nullptr;

	if ( hModule == INVALID_HANDLE_VALUE || hModule == nullptr ) {
		printf( "LoadLibrary()に失敗\n" );
		return -1;
	}

	lpFunc = reinterpret_cast<LPFUNC>(GetProcAddress( hModule, "ShowDeleteBrowsingHistoryDialog" ));
	if ( lpFunc == nullptr ) {
		printf( "GetProcAddress()に失敗\n" );
		FreeLibrary( hModule );
		return -2;
	}

	lpFunc( GetDesktopWindow() );
	FreeLibrary( hModule );

	return 0;
}