如下是VB6的代码
'引用Microsoft Shell Controls And Automation
Private Sub Command1_Click()
MsgBox getfilePTY("C:\WINDOWS\notepad.exe")
End Sub
Function getfilePTY(strFl As String) As String
Dim fso 'As FileSystemObject
Dim fl 'As Scripting.File
Dim pth As String
Dim flname As String
Dim shl As Shell32.Shell
Dim shfd As Shell32.Folder
Dim s As String
Dim i
'Set fso = New FileSystemObject
Set fso = CreateObject("scripting.filesystemobject")
Set fl = fso.GetFile(strFl)
pth = fl.ParentFolder.Path
flname = fl.Name
Set shl = New Shell
Set shfd = shl.NameSpace(pth)
For i = 0 To 100
If shfd.GetDetailsOf(0, i) <> "" Or shfd.GetDetailsOf(shfd.Items.Item(flname), i) <> "" Then
s = s & shfd.GetDetailsOf(0, i) & ": " & shfd.GetDetailsOf(shfd.Items.Item(flname), i) & Chr(10)
End If
Next i
VB声明
Declare Function GetFileVersionInfo& Lib "version.dll" Alias "GetFileVersionInfoA" (ByVal lptstrFilename As String, ByVal dwHandle As Long, ByVal dwLen As Long, lpData As Byte)
说明
从支持版本标记的一个模块里获取文件版本信息
返回值
Long,非零表示成功,零表示失败。会设置GetLastError
参数表
参数 类型及说明
lptstrFilename String,欲从中载入版本信息的一个文件的名字
dwHandle Long,win32中未用
dwLen Long,由lpData参数指定的字节数组或缓冲区的大小。用GetFileVersionInfoSize函数判断要求的缓冲区长度有多大
lpData Byte,指定一个字节缓冲区的第一个字节。该缓冲区用于装载文件的版本信息
注解
在win32下不用dwHandle参数
其他
请看vb的api文本查看器中的声明:Declare Function GetFileVersionInfo Lib "version.dll" Alias "GetFileVersionInfoA" (ByVal lptstrFilename As String, ByVal dwHandle As Long, ByVal dwLen As Long, lpData As Any) As Long