sgzhou12345 2010-10-22 15:09
Delphi 获取DLL文件中的版本信息
delphi 获取DLL文件中的版本信息
我想用DELPHI编程加载一个可执行程序(EXE格式)或者库文件(DLL格式)
显示这个文件中所有信息如下图所示:
sgzhou12345 2010-10-22 15:17
就是这些信息:
版本:
描述:
版权:
备注:
产品版本:
................................................就这些信息》》》》》》》》》》》》》》》
Nothing 2010-10-24 22:12
GetFileVersionInfo这个API可以完成你的要求
[color=#000000][color=#0000ff]var[/color]
InfoSize [color=#0000cc],[/color] Zero [color=#0000cc]:[/color] DWORD[color=#0000cc];[/color]
VersionInfo [color=#0000cc],[/color]Info [color=#0000cc]:[/color] [color=#ff0000]Pointer[/color][color=#0000cc];[/color]
Translation[color=#0000cc]:[/color] PLANGANDCODEPAGE[color=#0000cc];[/color]
InfoPath [color=#0000cc]:[/color] [color=#ff0000]String[/color][color=#0000cc];[/color]
[color=#0000ff]begin[/color]
InfoSize [color=#0000cc]:[/color][color=#0000cc]=[/color] GetFileVersionInfoSize[color=#0000cc]([/color][color=#ff0000]PChar[/color][color=#0000cc]([/color]NamePath[color=#0000cc])[/color][color=#0000cc],[/color]Zero[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]if[/color] InfoSize [color=#0000cc]=[/color] 0 [color=#0000ff]then[/color] [color=#0000ff]begin[/color]
Exit[color=#0000cc];[/color]
[color=#0000ff]end[/color][color=#0000cc];[/color]
GetMem[color=#0000cc]([/color]VersionInfo[color=#0000cc],[/color]InfoSize[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]try[/color]
[color=#0000ff]if[/color] [color=#0000ff]Not[/color] GetFileVersionInfo[color=#0000cc]([/color][color=#ff0000]PChar[/color][color=#0000cc]([/color]NamePath[color=#0000cc])[/color][color=#0000cc],[/color]0[color=#0000cc],[/color]InfoSize[color=#0000cc],[/color]VersionInfo[color=#0000cc])[/color] [color=#0000ff]then[/color] [color=#0000ff]begin[/color]
Exit[color=#0000cc];[/color]
[color=#0000ff]end[/color][color=#0000cc];[/color]
[color=#0000ff]if[/color] VerQueryValue[color=#0000cc]([/color]VersionInfo[color=#0000cc],[/color] [color=#ff00ff]'\VarFileInfo\Translation '[/color][color=#0000cc],[/color] [color=#ff0000]Pointer[/color][color=#0000cc]([/color]Translation[color=#0000cc])[/color][color=#0000cc],[/color] InfoSize[color=#0000cc])[/color] [color=#0000ff]then[/color]
[color=#0000ff]begin[/color]
InfoPath [color=#0000cc]:[/color][color=#0000cc]=[/color] [color=#ff00ff]'\StringFileInfo\ '[/color] + inttoHex[color=#0000cc]([/color]Translation^[color=#0000cc].[/color]wLanguage[color=#0000cc],[/color] 4[color=#0000cc])[/color] + inttoHex[color=#0000cc]([/color]Translation^[color=#0000cc].[/color]wCodePage[color=#0000cc],[/color] 4[color=#0000cc])[/color] + [color=#ff00ff]'\ '[/color][color=#0000cc];[/color]
GetMem[color=#0000cc]([/color]Info[color=#0000cc],[/color] 2000[color=#0000cc])[/color][color=#0000cc];[/color]
VerLanguageName[color=#0000cc]([/color]Translation^[color=#0000cc].[/color]wLanguage[color=#0000cc],[/color] Info[color=#0000cc],[/color] 2000[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]end[/color]
[color=#0000ff]else[/color] [color=#0000ff]begin[/color][color=#ff9900]//set default value
[/color]
InfoPath [color=#0000cc]:[/color][color=#0000cc]=[/color] [color=#ff00ff]'\StringFileInfo\040904E4\ '[/color][color=#0000cc];[/color]
[color=#0000ff]end[/color][color=#0000cc];[/color]
[color=#0000ff]if[/color] VerQueryValue[color=#0000cc]([/color]VersionInfo[color=#0000cc],[/color] [color=#ff0000]PChar[/color][color=#0000cc]([/color]InfoPath + [color=#ff00ff]'ProductVersion '[/color][color=#0000cc])[/color][color=#0000cc],[/color] Info[color=#0000cc],[/color] InfoSize[color=#0000cc])[/color] [color=#0000ff]then[/color]
S1 [color=#0000cc]:[/color][color=#0000cc]=[/color] [color=#ff0000]string[/color][color=#0000cc]([/color][color=#ff0000]PChar[/color][color=#0000cc]([/color]Info[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color] [color=#ff9900]//版本;
[/color]
[color=#0000ff]if[/color] VerQueryValue[color=#0000cc]([/color]VersionInfo[color=#0000cc],[/color] [color=#ff0000]PChar[/color][color=#0000cc]([/color]InfoPath + [color=#ff00ff]'CompanyName '[/color][color=#0000cc])[/color][color=#0000cc],[/color] Info[color=#0000cc],[/color] InfoSize[color=#0000cc])[/color] [color=#0000ff]then[/color]
S2 [color=#0000cc]:[/color][color=#0000cc]=[/color] [color=#ff0000]string[/color][color=#0000cc]([/color][color=#ff0000]PChar[/color][color=#0000cc]([/color]Info[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color] [color=#ff9900]//厂商;
[/color]
[color=#0000ff]if[/color] VerQueryValue[color=#0000cc]([/color]VersionInfo[color=#0000cc],[/color] [color=#ff0000]PChar[/color][color=#0000cc]([/color]InfoPath + [color=#ff00ff]'LegalTrademarks '[/color][color=#0000cc])[/color][color=#0000cc],[/color] Info[color=#0000cc],[/color] InfoSize[color=#0000cc])[/color] [color=#0000ff]then[/color]
S3 [color=#0000cc]:[/color][color=#0000cc]=[/color] [color=#ff0000]string[/color][color=#0000cc]([/color][color=#ff0000]PChar[/color][color=#0000cc]([/color]Info[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color] [color=#ff9900]//
[/color]
[color=#0000ff]if[/color] VerQueryValue[color=#0000cc]([/color]VersionInfo[color=#0000cc],[/color] [color=#ff0000]PChar[/color][color=#0000cc]([/color]InfoPath + [color=#ff00ff]'FileDescription '[/color][color=#0000cc])[/color][color=#0000cc],[/color] Info[color=#0000cc],[/color] InfoSize[color=#0000cc])[/color] [color=#0000ff]then[/color]
S4 [color=#0000cc]:[/color][color=#0000cc]=[/color] [color=#ff0000]string[/color][color=#0000cc]([/color][color=#ff0000]PChar[/color][color=#0000cc]([/color]Info[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color] [color=#ff9900]//描述;
[/color]
[color=#0000ff]finally[/color]
FreeMem[color=#0000cc]([/color]VersionInfo[color=#0000cc],[/color] InfoSize[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]end[/color][color=#0000cc];[/color]
[color=#0000ff]end[/color][color=#0000cc];[/color][/color]
sgzhou12345 2011-6-14 16:53
不行,不能运行,提示:
Translation: PLANGANDCODEPAGE;