有關取得Delphi的版本資訊 |
答題得分者是:william
|
ivankuo
中階會員 ![]() ![]() ![]() 發表:132 回覆:272 積分:95 註冊:2002-11-21 發送簡訊給我 |
小弟抄寫了前人的一段取得版本程式,但是雖然可以做到,但是form在close之後,程式跑回program的最後一行出現了Invalid pointer operation的錯誤訊息
,不知道為什ㄇ??請各位前輩幫幫忙 program ERPManager; uses
Forms,
ShareMem,
windows,
sysutils,
Dialogs,
Controls, ManagerForm in '..\ManagerForm.pas' {FormManager}; type
TLangInfoBuffer = array [1..4] of SmallInt;
{$R *.RES} var
jet_lag:integer;
VInfoSize, DetSize: DWord;
pVInfo, pDetail: Pointer;
pLangInfo: ^TLangInfoBuffer;
strLangId: string;
f:textfile;
S,S1:string;
BufLen: DWORD;
Buffer: PChar;
fi:boolean;
i:integer;
sys_la:string;
s_MdiFormCount:integer;
sys_db_sw:boolean;
ver:string;
begin
VInfoSize := GetFileVersionInfoSize (PChar (ParamStr (0)), DetSize); //取得版本資訊的大小
GetMem (pVInfo, VInfoSize);
GetFileVersionInfo (PChar (ParamStr (0)), 0,VInfoSize, pVInfo);
VerQueryValue(pVInfo,'\VarFileInfo\Translation',Pointer(pLangInfo), DetSize);
strLangId := IntToHex (SmallInt (pLangInfo^ [1]), 4) IntToHex (SmallInt (pLangInfo^ [2]), 4);
strLangId := '\StringFileInfo\' strLangId;
VerQueryValue(pVInfo, PChar(strLangId '\FileDescription'),pDetail, DetSize); VerQueryValue(pVInfo, PChar(strLangId '\FileVersion'),pDetail, DetSize);
ver:=' V' PChar(pDetail); BufLen := 255;
GetMem(Buffer, BufLen);
GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SABBREVLANGNAME, Buffer, BufLen);
S1:= Buffer; Application.Initialize;
Application.Title := 'Manager'; FormManager.CreateFormManager(ver); Application.Run; end. unit ManagerForm; interface uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, ComCtrls; type
TFormManager = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
StatusBar1: TStatusBar;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
private
{ Private declarations }
public
{ Public declarations }
procedure CreateFormManager(ver:string);
end; var
FormManager: TFormManager; implementation {$R *.DFM} { TFormManager } procedure TFormManager.CreateFormManager(ver: string);
begin
Application.CreateForm(TFormManager,FormManager);
with FormManager do
begin
Caption:='ERP Manager' ver;
ShowModal;
close;
end;
end; end.
------
ivankuo |
william
版主 ![]() ![]() ![]() ![]() ![]() 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
|
ivankuo
中階會員 ![]() ![]() ![]() 發表:132 回覆:272 積分:95 註冊:2002-11-21 發送簡訊給我 |
引言: Remove ShareMem from your project, it is intended for using string in dll. BTW, your program has memory leak, only GetMem but no FreeMem?我有試過把 FreeMem (pVInfo); FreeMem (Buffer); 加入但是還是一樣耶 sorry 我知道了~~~ 感謝感謝~~~ 發表人 - ivankuo 於 2003/06/20 10:42:12 發表人 - ivankuo 於 2003/06/20 10:51:50
------
ivankuo |
william
版主 ![]() ![]() ![]() ![]() ![]() 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |