ENGLISH page is here.
GET DinopSearchBar
サイト内検索:
HOME
VC++ TIPS
ダウンロード
DinopExifReader
DinopSearchBar
DinopSearchBar mini
DinopTabbingBar
for Firefox
大阪湾の生き物
甲子園浜の自然
甲子園浜の干潟
甲子園浜の水中
甲子園浜の野鳥
近畿の山々
植物図鑑
箕面マップ
水中機材
カメラ
ランキング
望遠鏡の世界
顕微鏡の世界
Googleのすべて
GoogleマップAPI
ニュース
読んだ本
日記
変な料理の作り方
遺伝子操作
論文紹介
デイトレード
自動売買でFX
ネットで小遣い稼ぎ
Solaris
電子工作
その他
問い合わせ
VC++用コード集
大阪湾の生き物
水中用機材
since:2000/11/15
dinopcom@gmail.com
www.dinop.comは
だいのっぷ・どっと・こむ
と読んでください。







« DinopSearchBarとCOMプログラミング(タブブラウザへの対応) | メイン | フォルダ選択ダイアログの表示 »

DinopSearchBarのインストールバージョンチェック方法




   DinopSearchBarを外部プログラムなどで使用する場合に必要なバージョンチェック方法です。


   以下の情報を用いてインストールされているバージョンのチェックを行います。
     ・COMによるインスタンス生成
     ・レジストリのインストールフォルダ情報
     ・DLL内のリソース情報



void OnButton1() 
{
	int			nVer;
	CString		strMessage;

	nVer = GetDinopSearchBarVersion();
	if(nVer > 0)
		strMessage.Format("DinopSearchBarのバージョンは「%d」です。",nVer);
	else
		strMessage = "DinopSearchBarがインストールされていません";

	AfxMessageBox(strMessage);
}


#include "atlbase.h"

#import "C:\Program Files\dinop\DinopSearchBar\DinopSearchBar.dll" no_namespace


const CLSID CLSID_DinopSearchBarBand = {0x509AC252,0x12BD,0x11d5,{0x97,0x39,0x00,0x50,0x04,0xC0,0x99,0xCF}};

//
// インストールされているDinopSearchBarのバージョン番号を返す
//
//     ※大昔のバージョンやインストールされてない場合は「0」が返ります
//
int		GetDinopSearchBarVersion()
{
	HRESULT							hr;
	CComPtr<IUnknown>				lpUnknown;
	CComPtr<IDinopSearchBarBand>	lpDinop;

	//////////////////////////////////////////////////////////////////////////
	//
	// DinopSearchBarがインストールされているかどうかのチェック
	//
	::CoInitialize(NULL);										//COMの初期化
	hr= lpUnknown.CoCreateInstance(CLSID_DinopSearchBarBand);	//IDinopSearchBarBandの作成
	if(SUCCEEDED(hr) && (lpUnknown != NULL))
		hr = lpUnknown->QueryInterface(&lpDinop);				//IDinopSearchBarBandの取得

	//////////////////////////////////////////////////////////////////////////
	//
	// DinopSearchBarがインストールされているなら...
	//
	if(SUCCEEDED(hr) && (lpDinop != NULL))
	{
		CString		strFile;
		HMODULE		hInstance;
		LONG		ret;
		HKEY		hKey;
		DWORD		dwType;
		DWORD		dwLen;
		char		lpszBuff[1024];

		//////////////////////////////////////////////////////////////////////////
		//
		// DinopSearchBarのインストールフォルダをレジストリから取得
		//
		dwLen	= 1024;
		dwType	= REG_SZ;
		hKey	= NULL;
		::RegOpenKeyEx(HKEY_LOCAL_MACHINE,"software\\dinop\\DinopSearchBar",NULL,KEY_QUERY_VALUE,&hKey);
		if(hKey != NULL)
		{
			ret = ::RegQueryValueEx(hKey,"",NULL,&dwType,(BYTE*)lpszBuff,&dwLen);
			::RegCloseKey(hKey);
			if(ret == ERROR_SUCCESS)
			{
				strFile = lpszBuff;
				if(strFile.Right(1) != "\\")		//フォルダ名の末尾を確実に"\\"にする
					strFile += "\\";
				strFile += "dinopsearchbar.dll";	//dll名をアペンドしてフルパス名にする

				//////////////////////////////////////////////////////////////////////////
				//
				// DinopSearchBarのdllファイルからバージョン情報を取得
				//
				hInstance = ::LoadLibrary(strFile);
				if(::LoadString(hInstance,102,lpszBuff,1024) > 0)	//バージョン情報は"102"に保存されている
					return	atoi(lpszBuff);			//バージョン取得成功
			}
		}

	}
	return	0;		//バージョン取得失敗
}








Copyright (c) 1999-2007 issei. All rights reserved. (運営者情報