//取版本号<br>function TClientThread.GetVersions(FileName: String): string;<br> var<br> FileName: string;<br> InfoSize, Wnd: LongWord;<br> VerBuf: Pointer;<br> FI: PVSFixedFileInfo;<br> VerSize: LongWord;<br> ProcName:string;<br> begin<br> ProcName:='TDlgLoginFrm.BtnOkClick.GetVersions';<br> FileName := ExtractFilePath(ParamStr(0))+'cycomputer.exe' ;<br> InfoSize := GetFileVersionInfoSize(PChar(FileName), Wnd);<br> if InfoSize <> 0 then<br> begin<br> GetMem(VerBuf, InfoSize);<br> try<br> try<br> if GetFileVersionInfo(PChar(FileName), Wnd, InfoSize, VerBuf) then<br> if VerQueryValue(VerBuf, '/', Pointer(FI), VerSize) then<br> begin<br> Result := inttostr(DWORD(LOBYTE(HIWORD(FI.dwFileVersionMS))));<br> Result :=Result +'.'+ inttostr(DWORD(LOWORD(LOWORD(FI.dwFileVersionMS))));<br> Result :=Result +'.'+ inttostr(DWORD(LOBYTE(HIWORD(FI.dwFileVersionLS))));<br> Result :=Result +'.'+ inttostr(DWORD(LOWORD(LOWORD(FI.dwFileVersionLS))));<br> end else Result :='0.0.0.0'<br> else Result :='0.0.0.0';<br> except<br> on E:exception do<br> begin<br> WriteErrorLog(E,ProcName);<br> Raise;<br> end;<br> end;<br> finally<br> FreeMem(VerBuf);<br> end;<br> end else Result :='0.0.0.0';<br> end;<br> <br>function GetApplicationVersion:String; // Added 取得程序版本号<br>var FileName:String; <br> InfoSize,Wnd
WORD; <br> VerBuf
ointer; <br> VerInfo:^VS_FIXEDFILEINFO;<br>begin<br> Result:='0.0.0.0';<br> FileName:=Application.ExeName;<br> InfoSize:=GetFileVersionInfoSize(PChar(FileName),Wnd);<br> if InfoSize<>0 then<br> begin<br> GetMem(VerBuf,InfoSize);<br> try<br> if GetFileVersionInfo(PChar(FileName),Wnd,InfoSize,VerBuf) then<br> begin<br> VerInfo:=nil;<br> VerQueryValue(VerBuf,'/',Pointer(VerInfo),Wnd);<br> if VerInfo<>nil then Result:=Format('%d.%d.%d.%d',[VerInfo^.dwFileVersionMS shr 16,<br> VerInfo^.dwFileVersionMS and $0000ffff,<br> VerInfo^.dwFileVersionLS shr 16,<br> VerInfo^.dwFileVersionLS and $0000ffff]);<br> end;<br> finally<br> FreeMem(VerBuf,InfoSize);<br> end;<br> end;<br>end;