[BlueLeaf1336]> PROBLEMS> winbeads>
| history | TOP |
2005/01/23:作成
2005/01/25:更新
| 2005/01/23 | TOP |
最近はずっとドラクエVIばっかりやっています。どのぐらい「ずっと」かというと... BOOKSのページに、ほぼ毎日にわたって、その日に読んだ本・購入した本・プレイしたゲームを、溜まりに溜まった買ってしまった本を少しでも減らす助けになるかと思って、記録しているんですが、「DRAGON QUEST VI 幻の大地」も同様に「プレイした」という事実だけを貼り付けています。で、Googleで「DRAGON QUEST VI 幻の大地」を検索すると、このホームページへのリンクが1ページ目に現われるぐらい、「ずっと」やっています。
さて、まったくもって、特に作りたいプログラムを思いつかないのですが、Tipsの寄せ集めで作れそうなものを思いついたというか見つけました。それは、Windowsの情報を表示するツールです。先に書いておきますが、Vector:ソフトウェア・ライブラリ&PCショップ に行けば腐るほどあります。
とりあえず上位に表示されているプログラムを一つ選んで、そのプログラムが表示している内容を、Delphi 6 Personal で取得できるかどうか(正確には、できるに決まってるんですが、ソースコードを発見/翻訳することで、Delphi 6 Personal で記述できるか)をやろうじゃないかと、思います。
というわけで、某有名PC情報取得ツールをダウンロードしてきましたので、そのツールが表示している内容を一つずつやってみることにします。
ちなみに、「winbeads」は「ウィンビーズ」と読みます。で「ウィンドーズ」と似ているつもりです。また「ビーズ」で「ちみっちゃい何か」を意図しています。そんなとこです。
ところで、こういった情報というのはどのように使うのか? 実は知りません。役に立ったことも思い出せないのですが。でもまあそれを言い出したらきりがないので、ネタには困らないほど大量の小物があるので、しばらく暇がつぶせそうです。
| Windowsのバージョンを取得する | TOP |
早速、順番に片付けていくことにします。まずはWindowsのバージョンですが、実は既にやったことがあるので、それをそのまま使うことにします。
改めて翻訳元のSDKを確認しましたが変わってないような気がします。なのでそのままで。
| WindowsのプロダクトIDを取得する | TOP |
次はWindowsのプロダクトIDですが、これもやったことがありました。
| IEのバージョンを取得する | TOP |
次はInternet Explorerのバージョンです。参考になりそうなサイトを探します。
上のサイトの一つ目に、レジストリを読むと書いてますよ、と書いてあります。説明の終わりぐらいに、
レジストリにこれらの値が存在しない場合は、Internet Explorer が正しくインストールされていないか、まったくインストールされていません。
ということですので、正式な取得方法と言えそうです。
// ===========================================================================
// IEのバージョンを取得する
// http://support.microsoft.com/kb/164539/JA/
// ===========================================================================
function GetIEVersion(): string;
const
IE_KEY = 'Software\Microsoft\Internet Explorer';
var
Reg: TRegistry;
StrBuf: TStringList;
index: integer;
IVer, Build: string;
begin
Result := '';
Reg := TRegistry.Create;
try
StrBuf := TStringList.Create;
try
// ルートキーを設定して
Reg.RootKey := HKEY_LOCAL_MACHINE;
// 説明書どおりのキーを開く(ない場合に作らないように)
if Reg.OpenKey(IE_KEY, false) then
begin
// 作成されているキーの一覧を取得する
Reg.GetValueNames(StrBuf);
// ソートする
StrBuf.Sorted := true;
// Internet Explorer 4.0 以降
if (StrBuf.Find('Version', index)) then
begin
Result := Reg.ReadString(StrBuf[index]);
end
// 'IVer'で判定(しかないのか?)
else if (StrBuf.Find('IVer', index)) then
begin
IVer := Reg.ReadString(StrBuf[index]);
Build := Reg.ReadString('Build');
// Internet Explorer 3.x など
if (IVer = '103') then
begin
Result := 'Internet Explorer 3.x.' + Build;
end
else if (IVer = '102') then
begin
Result := 'Internet Explorer 2.0 for Windows 95 Build ' + Build;
end
else if (IVer = '101') then
begin
Result := 'Windows NT 4.0 に含まれる Internet Explorer';
end
else if (IVer = '100') then
begin
Result := 'Internet Explorer 1.0 for Windows 95';
end;
end
else
begin
// コレはありえないように読める
end;
end;
finally
StrBuf.Free;
end;
finally
Reg.Free;
end;
end;
と、やってみたものの、結局IE4以降でないと楽しい値にならないことがわかります。このままというのも嫌なので、同じサイトにある「Shdocvw.dll のバージョンを調べる方法」もやってみます。
ファイルは、Windows 95、Windows 98、および Windows Me では %Windir%\System フォルダにインストールされ、Windows NT 4.0、Windows 2000、Windows XP、Windows Server 2003 では %Windir%\System32 フォルダにインストールされます。Shdocvw.dll ファイルが存在しない場合、Internet Explorer が正しくインストールされていないか、まったくインストールされていません。
ということなので、それなりにやってみます。ところで「%Windir%」とはGetWindowsDirectoryで取得できるパスのことだと思います。
// ===========================================================================
// IEのバージョンを取得する
// http://support.microsoft.com/kb/164539/JA/
// ===========================================================================
function GetIEVersion2(): string;
const
QX_DIR = 'system';
NT_DIR = 'system32';
IE_DLL = 'Shdocvw.dll';
var
DllVerTable, ExeVerTable: TStringList;
WinDir: string;
DllPath: string;
index, i: integer;
procedure MakeTable(const DllVer, ExeVer: string);
begin
DllVerTable.Add(DllVer);
ExeVerTable.Add(ExeVer);
end;
begin
Result := '';
// Windowsディレクトリを取得
WinDir := GetWindowsDirectory();
// Windows 95、Windows 98、および Windows Me の場合と仮定
DllPath := IncludeTrailingPathDelimiter(WinDir) + QX_DIR + '\' + IE_DLL;
if (not FileExists(DllPath)) then
begin
// Windows NT 4.0、Windows 2000、Windows XP、Windows Server 2003 らしい
DllPath := IncludeTrailingPathDelimiter(WinDir) + NT_DIR + '\' + IE_DLL;
if (not FileExists(DllPath)) then
begin
// IE無し
exit;
end;
end;
// 見つかったDLLのバージョンを調べる
Result := GetFileVersion(DllPath);
// DLLバージョンとIEバージョンを引き当てるテーブルを作成
DllVerTable := TStringList.Create();
ExeVerTable := TStringList.Create();
try
MakeTable('4.70.1155','Internet Explorer 3.0');
MakeTable('4.70.1158','Internet Explorer 3.0 (Windows 95 OSR2)');
MakeTable('4.70.1215','Internet Explorer 3.01');
MakeTable('4.70.1300','Internet Explorer 3.02 and 3.02a');
MakeTable('4.71.1008.3','Internet Explorer 4.0 Platform Preview 2.0 (PP2)');
MakeTable('4.71.1712.5','Internet Explorer 4.0');
MakeTable('4.72.2106.7','Internet Explorer 4.01');
MakeTable('4.72.3110.3','Internet Explorer 4.01 Service Pack 1 (Windows 98)');
MakeTable('4.72.3612.1707','Internet Explorer 4.01 Service Pack 2');
MakeTable('5.00.0518.5','Internet Explorer 5 Developer Preview (Beta 1)');
MakeTable('5.00.0910.1308','Internet Explorer 5 Beta (Beta 2)');
MakeTable('5.00.2014.213','Internet Explorer 5');
MakeTable('5.00.2314.1000','Internet Explorer 5 (Office 2000)');
MakeTable('5.00.2516.1900','Internet Explorer 5.01 (Windows 2000 Beta 3, build 5.00.2031)');
MakeTable('5.00.2614.3500','Internet Explorer 5 (Windows 98 Second Edition)');
MakeTable('5.00.2919.800','Internet Explorer 5.01 (Windows 2000 RC1, build 5.00.2072)');
MakeTable('5.00.2919.3800','Internet Explorer 5.01 (Windows 2000 RC2, build 5.00.2128)');
MakeTable('5.00.2919.6307','Internet Explorer 5.01 (Office 2000 SR-1)');
MakeTable('5.00.2920.0000','Internet Explorer 5.01 (Windows 2000, build 5.00.2195)');
MakeTable('5.00.3103.1000','Internet Explorer 5.01 SP1 (Windows 2000 SP1)');
MakeTable('5.00.3105.0106','Internet Explorer 5.01 SP1 (Windows 95/98 and Windows NT 4.0)');
MakeTable('5.00.3314.2100','Internet Explorer 5.01 SP2 (Windows 95/98 and Windows NT 4.0)');
MakeTable('5.00.3315.2879','Internet Explorer 5.01 SP2 (Windows 2000 SP2)');
MakeTable('5.00.3502.5400','Internet Explorer 5.01 SP3 (Windows 2000 SP3 only)');
MakeTable('5.00.3700.6668','Internet Explorer 5.01 SP4 (Windows 2000 SP4 only)');
MakeTable('5.50.3825.1300','Internet Explorer 5.5 Developer Preview (Beta)');
MakeTable('5.50.4030.2400','Internet Explorer 5.5 & Internet Tools Beta');
MakeTable('5.50.4134.0100','Internet Explorer 5.5 for Windows Me (4.90.3000)');
MakeTable('5.50.4134.0600','Internet Explorer 5.5');
MakeTable('5.50.4308.2900','Internet Explorer 5.5 Advanced Security Privacy Beta');
MakeTable('5.50.4522.1800','Internet Explorer 5.5 Service Pack 1');
MakeTable('5.50.4807.2300','Internet Explorer 5.5 Service Pack 2');
MakeTable('6.00.2462.0000','Internet Explorer 6 Public Preview (Beta)');
MakeTable('6.00.2479.0006','Internet Explorer 6 Public Preview (Beta) Refresh');
MakeTable('6.00.2600.0000','Internet Explorer 6 (Windows XP)');
MakeTable('6.00.2800.1106','Internet Explorer 6 Service Pack 1 (Windows XP SP1)');
MakeTable('6.00.2800.1278','Internet Explorer 6 Update v.01 Developer Preview (SP1b Beta)');
MakeTable('6.00.2800.1314','Internet Explorer 6 Update v.04 Developer Preview (SP1b Beta)');
MakeTable('6.00.2900.2180','Internet Explorer 6 for Windows XP SP2');
MakeTable('6.00.3663.0000','Internet Explorer 6 for Microsoft Windows Server 2003 RC1');
MakeTable('6.00.3718.0000','Internet Explorer 6 for Windows Server 2003 RC2');
MakeTable('6.00.3790.0000','Internet Explorer 6 for Windows Server 2003 (released)');
// バージョンに一致するものがあるかどうか調べる
index := DllVerTable.IndexOf(Result);
if (index <> -1) then
begin
Result := Format('%s'#13#10'%s:%s', [ExeVerTable[index], IE_DLL, Result]);
end
// ない場合は、コレを超えない最大のバージョンのものを採用
else
begin
index := 0;
for i := 0 to DllVerTable.Count - 1 do
begin
if (DllVerTable[i] > Result) then break;
index := i;
end;
Result := Format('%s'#13#10'%s:%s', [ExeVerTable[index], IE_DLL, Result]);
end;
finally
DllVerTable.Free;
ExeVerTable.Free;
end;
end;
ちょっと無理があります。ちなみに、GetWindowsDirectory / GetFileVersion という関数はそれぞれ、Windowsディレクトリを取得する関数 / 実行ファイルのファイルバージョンを取得する関数で、HTML化はしていません。ソースコードをダウンロードしてもらえれば、書いてあります。もろパクリで。
| EOF | TOP |