お知らせ

電子会議

ライブラリ

パレット

Delphi FAQ検索

Delphi FAQ一覧

サンプル蔵





FDelphi FAQ
16番会議室「玉石混淆みんなで作るSample蔵」に寄せられたサンプル

"[D3]Version Information From Your Progra"




{
Delph Tip NUMBER:3241の
Getting Version Information From Your Programでは Delphi3で新しく
入れられるようになったVersion Informationを表示するサンプルですが
lang-codepageが日本になっていないのでちょっと手直ししてみました。
これで自分のアプリのVersion情報を簡単に表示できます。
}
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
const
  InfoNum = 10;
  InfoStr : array [1..InfoNum] of String =
    ('CompanyName', 'FileDescription', 'FileVersion', 'InternalName',
     'LegalCopyright', 'LegalTradeMarks', 'OriginalFilename',
     'ProductName', 'ProductVersion', 'Comments');
  InfoStr_j : array [1..InfoNum] of String =
    ('会社名', '説明', 'ファイルバージョン', '内部名', '著作権', '商標', 
     '正式ファイル名', '製品名', '製品バージョン', 'コメント ');
var
  AppName: String;
  n, Len, i: Integer;
  Buf, Value: PChar;
begin
  Memo1.Lines.Clear; Label1.Caption:= '';
  AppName := Application.ExeName;
  n:= GetFileVersionInfoSize(PChar(AppName), n);
  if n > 0 then
  begin
    Buf:= AllocMem(n);
    Label1.Caption:= 'FileVersionInfoSize = ' + IntToStr(n);
    GetFileVersionInfo(PChar(AppName), 0, n, Buf);
    for i:= 1 to InfoNum do
      if VerQueryValue(Buf, 
                       PChar('StringFileInfo\041103a4\' + InfoStr[i]), 
                       Pointer(Value),Len) then
        Memo1.Lines.Add(InfoStr_j[i] + ' = ' + Value);
    FreeMem(Buf, n);
  end else
    Memo1.Lines.Add('No FileVersionInfo found');
end;

end.

でわ〜でわ〜
                                   by ヒシアマゾン
                                   BXC05221@niftyserve.or.jp
                                   ken_fu@mx4.meshnet.or.jp

Original document by ヒシアマゾン    氏 ID:(BXC05221)


ここにあるドキュメントは NIFTY SERVEの Delphi Users' Forum の16番会議室「玉石混淆みんなで作るSample蔵」に投稿されたサンプルです。これらのサンプルはボーランド株式会社がサポートする公式のものではありません。また、必ずしも動作が検証されているものではありません。これらのサンプルを使用したことに起因するいかなる損害も投稿者、およびフォーラムスタッフはその責めを負いません。使用者のリスクの範疇でご使用下さい。

Copyright 1996-2002 Delphi Users' Forum