windows高手请帮忙(200分)

  • 主题发起人 主题发起人 tangdongping
  • 开始时间 开始时间
T

tangdongping

Unregistered / Unconfirmed
GUEST, unregistred user!
一个文件的版本信息如何设置、如何获取;有没有提供api接口;
在windows/system下的dll文件,其属性页都有版本信息如版本号、公司名称等信息,而我
自己编的dll没有这些信息,请问为什么
 
在Project Option里面的Include Version Information
 
如热血所言!
 
那如何获取这些信息,当程序判断是否要更新文件,肯定要先读取文件的版本等信息
文件的版本信息存放于文件的哪里,格式是怎么样的?

 
help 里很清楚:
procedure TForm1.Button1Click(Sender: TObject);

const
InfoNum = 10;
InfoStr: array[1..InfoNum] of string = ('CompanyName', 'FileDescription', 'FileVersion', 'InternalName', 'LegalCopyright', 'LegalTradeMarks', 'OriginalFileName', 'ProductName', 'ProductVersion', 'Comments');
var
S: string;
n, Len, i: DWORD;
Buf: PChar;
Value: PChar;
begin
S := Application.ExeName;
n := GetFileVersionInfoSize(PChar(S), n);
if n > 0 then
begin

Buf := AllocMem(n);
Memo1.Lines.Add('VersionInfoSize = ' + IntToStr(n));
GetFileVersionInfo(PChar(S), 0, n, Buf);
for i := 1 to InfoNum do
if VerQueryValue(Buf, PChar('StringFileInfo/040904E4/' + InfoStr), Pointer(Value), Len) then
Memo1.Lines.Add(InfoStr + ' = ' + Value);
FreeMem(Buf, n);
end
else
Memo1.Lines.Add('No version information found');
end;
 
'StringFileInfo/040904E4/' + InfoStr[i 该行是何意识
我安照以上代码,不能返回版本号等信息
 
sorry, missed a right bracket . I've corrected it.
you can just copy the codes above to your application again.
Good Luck![:D]
 
sorry
好像还是不行,我看了buf的值为‘?4’
 
buf是指针呀?你看它干什么?
你说不行指的是什么?
 
谁来救我
 
就是memo框里不能显示出相关的一堆版本信息入comment,filedescrption 等
不信你try it
 
are u sure 'comment' is included in "Projects"-->"Options"--->"Version Info"----"Key"?
No problem on my computer.
 
我在文件的属性里可以看到相关版本信息
但在程序里的memo里就是看不到类似信息
只显示VersionInfoSize = 1804
 
function GetVersion;
var
InfoSize, Wnd: DWORD;
VerBuf: Pointer;
szName: array[0..255] of Char;
Value: Pointer;
Len: UINT;
TransString:string;
begin
InfoSize := GetFileVersionInfoSize(PChar(FileName), Wnd);
if InfoSize <> 0 then
begin
GetMem(VerBuf, InfoSize);
try
if GetFileVersionInfo(PChar(FileName), Wnd, InfoSize, VerBuf) then
begin
Value :=nil;
VerQueryValue(VerBuf, '/VarFileInfo/Translation', Value, Len);
if Value <> nil then
TransString := IntToHex(MakeLong(HiWord(Longint(Value^)), LoWord(Longint(Value^))), 8);
Result := '';
StrPCopy(szName, '/StringFileInfo/'+Transstring+'/FileVersion');
^^^^^^^此处换成ProductVersion得到的是"产品版本"和其他
相关信息
if VerQueryValue(VerBuf, szName, Value, Len) then
Result := StrPas(PChar(Value));
end;
finally
FreeMem(VerBuf);
end;
end;
end;

 
谢谢各位高手
 
1.Be sure that 'Include version information in project' is checked in "Projects"-->"Options"--->"Version Info".
2.Be sure that 'Comments' is included in "Projects"-->"Options"--->"Version Info"----"Key".
3.Copy the codes I give you into your Application.
4.I PROMISE you the result will be like this
//////////////////////////////////
VersionInfoSize = 1892
CompanyName = Borland Software Corporation
FileDescription = Borland User's Components
FileVersion = 6.0.6.163
InternalName = DCLUSR60
LegalCopyright = Copyright ? 1997-2001 Borland Corporation
LegalTradeMarks =
OriginalFileName = DCLUSR60.BPL
ProductName = Borland Package Library
ProductVersion = 6.0
Comments = savenight is a good person
//////////////////////////////////
 
后退
顶部