我的delphi程序编译了怎么版本号没有变啊

我的delphi程序编译了怎么版本号没有变啊,第1张

你可以用下面的方式去取一下版本号,应该没什么问题!!!

定一个版本信息结构:

type

PFixedFileInfo = ^TFixedFileInfo;

TFixedFileInfo = record

dwSignature : DWORD;

dwStrucVersion : DWORD;

wFileVersionMS : WORD; // 次版本号

wFileVersionLS : WORD; // 主版本号

wProductVersionMS : WORD; // 建立次数(build)

wProductVersionLS : WORD; // 发行次数(release)

dwFileFlagsMask : DWORD;

dwFileFlags : DWORD;

dwFileOS : DWORD;

dwFileType : DWORD;

dwFileSubtype : DWORD;

dwFileDateMS : DWORD;

dwFileDateLS : DWORD;

end; // TFixedFileInfo

下面是取版本信息函数

function FileInfo( const FileName :String ) : TFixedFileInfo;

var

dwHandle, dwVersionSize : DWORD;

strSubBlock : String;

pTemp : Pointer;

pData : Pointer;

begin

strSubBlock := ';

// 取得文件版本信息的大小

dwVersionSize := GetFileVersionInfoSize( PChar( FileName ), dwHandle );

if dwVersionSize <> 0 then

begin

GetMem( pTemp, dwVersionSize );

try

//取文件版本信息

if GetFileVersionInfo( PChar( FileName ),dwHandle,

dwVersionSize,pTemp ) then

//查询文件版本信息

if VerQueryValue( pTemp,PChar( strSubBlock ),

pData,dwVersionSize ) then

Result := PFixedFileInfo( pData )^;

finally

FreeMem( pTemp );

end; // try

end; // if dwVersionSize

end;

调用例子:

var

f1:string;

x :TFixedFileInfo;

begin

f1 := ApplicationExeName;

x := FileInfo( f1 );

ShowMessage( f1 +

#13#10 'Version: ' + IntToStr( xwFileVersionLS ) + ' ' +

IntToStr( xwFileVersionMS ) +

#13#10 'Release: ' + IntToStr( xwProductVersionLS) +

#13#10 'Build: ' + IntToStr( xwProductVersionMS ) );

end;

获取文件版本信息

type

TFileInfo = packed record

CommpanyName: string;

FileDescription: string;

FileVersion: string;

InternalName: string;

LegalCopyright: string;

LegalTrademarks: string;

OriginalFileName: string;

ProductName: string;

ProductVersion: string;

Comments: string;

VsFixedFileInfo:VS_FIXEDFILEINFO;

UserDefineValue:string;

end;

function GetFileVersionInfomation(const FileName: string; var info: TFileInfo;UserDefine:string= ' '):

boolean;

const

SFInfo= ';

var

VersionInfo: Pointer;

InfoSize: DWORD;

InfoPointer: Pointer;

Translation: Pointer;

VersionValue: string;

unused: DWORD;

begin

unused := 0;

Result := False;

InfoSize := GetFileVersionInfoSize(pchar(FileName), unused);

if InfoSize > 0 then

begin

GetMem(VersionInfo, InfoSize);

Result := GetFileVersionInfo(pchar(FileName), 0, InfoSize, VersionInfo);

if Result then

begin

VerQueryValue(VersionInfo, ' ', Translation, InfoSize);

VersionValue := SFInfo + IntToHex(LoWord(Longint(Translation^)), 4) +

IntToHex(HiWord(Longint(Translation^)), 4) + ';

VerQueryValue(VersionInfo, pchar(VersionValue + 'CompanyName '), InfoPointer, InfoSize);

infoCommpanyName := string(pchar(InfoPointer));

VerQueryValue(VersionInfo, pchar(VersionValue + 'FileDescription '), InfoPointer, InfoSize);

infoFileDescription := string(pchar(InfoPointer));

VerQueryValue(VersionInfo, pchar(VersionValue + 'FileVersion '), InfoPointer, InfoSize);

infoFileVersion := string(pchar(InfoPointer));

VerQueryValue(VersionInfo, pchar(VersionValue + 'InternalName '), InfoPointer, InfoSize);

infoInternalName := string(pchar(InfoPointer));

VerQueryValue(VersionInfo, pchar(VersionValue + 'LegalCopyright '), InfoPointer, InfoSize);

infoLegalCopyright := string(pchar(InfoPointer));

VerQueryValue(VersionInfo, pchar(VersionValue + 'LegalTrademarks '), InfoPointer, InfoSize);

infoLegalTrademarks := string(pchar(InfoPointer));

VerQueryValue(VersionInfo, pchar(VersionValue + 'OriginalFileName '), InfoPointer, InfoSize);

infoOriginalFileName := string(pchar(InfoPointer));

VerQueryValue(VersionInfo, pchar(VersionValue + 'ProductName '), InfoPointer, InfoSize);

infoProductName := string(pchar(InfoPointer));

VerQueryValue(VersionInfo, pchar(VersionValue + 'ProductVersion '), InfoPointer, InfoSize);

infoProductVersion := string(pchar(InfoPointer));

VerQueryValue(VersionInfo, pchar(VersionValue + 'Comments '), InfoPointer, InfoSize);

infoComments := string(pchar(InfoPointer));

if VerQueryValue(VersionInfo, ', InfoPointer, InfoSize) then

infoVsFixedFileInfo := TVSFixedFileInfo(InfoPointer^);

if UserDefine <> ' ' then

begin

if VerQueryValue(VersionInfo,pchar(VersionValue+UserDefine),InfoPointer,InfoSize) then

infoUserDefineValue:=string(pchar(InfoPointer));

end;

end;

FreeMem(VersionInfo);

end;

end;

调用演示:

procedure TForm1Button1Click(Sender: TObject);

var

info: TFileInfo;

begin

if OpenDialog1Execute then

begin

if GetFileVersionInfomation(opendialog1FileName, info, 'WOW Version ') then

begin

Listbox1ItemsAdd(OpenDialog1FileName);

ListBox1ItemsAdd( 'Comments: ' + infoComments);

ListBox1ItemsAdd( 'CommpanyName: ' + infoCommpanyName);

ListBox1ItemsAdd( 'FileDescription: ' + infoFileDescription);

ListBox1ItemsAdd( 'FileVersion: ' + infoFileVersion);

ListBox1ItemsAdd( 'InternalName: ' + infoInternalName);

ListBox1ItemsAdd( 'LegalCopyright: ' + infoLegalCopyright);

ListBox1ItemsAdd( 'LegalTrademarks: ' + infoLegalTrademarks);

ListBox1ItemsAdd( 'OriginalFileName: ' + infoOriginalFileName);

ListBox1ItemsAdd( 'ProductName: ' + infoProductName);

ListBox1ItemsAdd( 'ProductVersion: ' + infoProductVersion);

ListBox1ItemsAdd( 'UserDefineValue: ' + infoUserDefineValue);

if boolean(infoVsFixedFileInfodwFileFlags and vs_FF_Debug) then

listbox1ItemsAdd( 'Debug:True ')

else

ListBox1ItemsAdd( 'Debug:False ');

ListBox1ItemsAdd( ' ');

end;

end;

end;

Visual Query Builder 以可视化的方式建立SQL语句对数据表和表中的记录进行 *** 作

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

SQL links使得Delphi数据库应用程序利用SQL语言访问驻留在远程服务器上的数据 这些服务器包括ORACLE Sybase Microsoft SQL Server Informix InterBase 当安装SQL Link驱动程序之后 SQL语句便可以直接 *** 作服务器上的数据

Delphi可以访问的数据源(DataSource)

Delphi数据库应用程序是通过BDE获取它们所需的数据的 BDE与不同类型的数据源打交道 BDE可以使用的数据源有如表 所示

表 Delphi可访问的数据源

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

数据源(DataSource)   特 性 描 述  文件扩展名

─────────────────────────────────────

dBASE数据库  数据库表是通过dBASE数据库管理系统或DBD建立的 每个表是一个独立的文件  DBF

─────────────────────────────────────

Paradox数据库  数据库表是通过Paradox数据库管理系统  DB或DBD建立的 每个表是一个独立的文件

─────────────────────────────────────

ASCII文件  表是通过Database Desktop建立的 每个  TXT表是一个独立的文件

─────────────────────────────────────

本地InterBase服务器  数据库是通过InterBase数据库管理系统  GDB建立的 多个表包含在一个数据库文件中

─────────────────────────────────────

SQL数据库服务器   数据库是通过相应的数据库服务器提供的 依赖不同的ORACLE Sybase Informix 专用或通用工具建立的 也可以通过DBD来 数据库管理Microsoft SQL Server  创建数据库 并通过SQL Link访问数据库  系统InterBase

─────────────────────────────────────

ODBC数据源  主要是指那些具有ODBC接口的数据库系统 依赖于相应如MS Access Btrieve等的数据库

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Delphi数据库的体系结构

Delphi使用可视化的部件创建数据库应用 跟创建其它的非数据库应用程序一样 数据库部件都具备一定的属性 程序设计人员可以在设计过程中设置部件的多种属性 也可以在程序运行过程中通过程序来设置部件的各种属性

在Delphi部件板上有两页数据库部件用于开发数据库应用程序

数据访问部件页 该页上的部件主要用于说明有关的数据库的信息 如应用程序要访问(连接)的数据库 要访问数据库中的具体的数据库表 以及要访问表中哪些字段等 在实际的开发应用中常用的部件有TDataSource TTable TQuery等

数据控制部件页 该页上的部件主要用于显示浏览数据库中的数据信息 为用户提供了一个可视化的界面 常用的部件有 TDBGrid TDBEdit TDBCheck等 可以让用户对数据库中的信息进行有效的浏览 编辑 插入 删除等 *** 作

TTable TQuery TStoredproc部件负责与实际的数据库表联系 并从中获取数据信息 因而它们又常常被称为数据集部件 它们在程序设计过程中是可见的 但在程序运行时是不可见的 它们通过 BDE 为应用程序提供与数据库的连接 数据控制部件通过TDataSource部件与数据集部件相连 为用户提供一个可视化的界面 并在其中显示数据库中的数据信息

数据访问部件

数据访问部件页上提供了一组数据访问部件用来访问数据库中的数据

当要创建一个数据库应用时 首先在窗体中选择一个数据访问部件 然后为数据访问部件设置有关的属性 说明要访问的数据库 数据表以及表中的记录等 数据访问部件为数据控制部件与数据源建立一条通道 数据访问部件在程序运行时是不可见的 下表列出了数据访问页上的数据访问部件以及它们的主要用途

表 数据访问部件

━━━━━━━━━━━━━━━━━━━━━━━━━━━━

部件名称   主 要 用 途

────────────────────────────

作为数据集部件TTable TQuery StoredProc组TDataSource 件与数据浏览件TDBGrid TDBEdit之间传送数据的通道

────────────────────────────

TTable  它是存取磁盘上数据库表的媒介 它通过BDE存取数据库表中的数据 TTable再与TDataSource进行 对话 使得数据浏览部件能够有效地从TTable中访问数据并能显示和编辑其中的数据

────────────────────────────

TQuery  它利用SQL语言访问磁盘上数据库表中的数据 并与TDataSource 对话 实现数据浏览部件对数据库的访问

────────────────────────────

TStoredProc 在应用程序中 它主要用来访问远程服务器中的存贮过程

────────────────────────────

TDatabase  当应用程序要登录到一个远程服务器上的数据库时 可以用该部件来建立应用程序与数据库永久

性的连接

────────────────────────────

TBatchMove 用于复制数据库表的结构或表中的记录

────────────────────────────

TReport  用于创建数据库的输出报表

━━━━━━━━━━━━━━━━━━━━━━━━━━━━

lishixinzhi/Article/program/Delphi/201311/25180

在 Delphi 中,获取文件的属性使用 FileGetAttr 函数,以下是详细说明:

设置文件的属性使用 FileSetAttr 函数:

示例代码:

Attrs := FileGetAttr('MyFilesys'); //获取指定文件的属性

if (Attrs or faHidden) <> 0 then //对文件属性进行 隐藏/显示 设置

   FileSetAttr('MyFilesys', Attrs and SysUtilsfaHidden)

else

   FileSetAttr('MyFilesys', Attrs and (not SysUtilsfaHidden));

delphi目录下文件数量

使用命令行查看Delphi目录下文件数量:

1 在命令行中输入 cd Delphi,进入Delphi目录;

2 输入 dir /a /b /s,查看Delphi目录下的文件数量。

{根据文件的名字得到此文件在系统中对应大小的图标large=true(6464) false(3232)}

procedure GetFileIcon(TypeName: Widestring; Icon: TIcon;Large:Boolean=False);

var

strTmp: Widestring;

IndexS, IndexL: HIcon;

ShFileInfo: TSHFileInfo ;

imgList: TImageList;

begin

strTmp := TypeName;

TypeName := Tnt_WideLowerCase(wideExtractFileExt(strTmp));

if pos('', TypeName) = 0 then

TypeName := '' + TypeName;

if Large then

begin

//如果是EXE、Ico文件,直接取文件的图标

if (TypeName = 'exe') or (TypeName = 'ico') then

begin

ExtractIconExw(pwidechar(strTmp), 0, IndexL, IndexS, 1);

if IndexS <> 0 then

begin

IconHandle := IndexL;

exit;

end;

end;

//在临时目录下建立一个空类型文件,便于取图标

TypeName := GetWindowsTempPath + TypeName;

if not wideFileExists(TypeName) then

with TUniFileStreamCreate(TypeName, fmCreate) do

Free;

imgList := TImageListCreateSize(64, 64);

try

{将系统图象列表连接到TListView控件上。注意我们设置动态建立的图象列表

的ShareImages属性为真,这可以确保我们不试图释放Windows系统拥有的图象}

imgListShareImages := True;

imgListHandle := ShGetFileInfo ('', 0, SHFileInfo, SizeOf(SHFileInfo),

SHGFI_SYSICONINDEX or

SHGFI_LARGEICON);

ShGetFileInfo (pchar( string( TypeName)), 0, SHFileInfo, SizeOf(SHFileInfo),

SHGFI_SYSICONINDEX or

SHGFI_LARGEICON);

imgListGetIcon(SHFileInfoiIcon, Icon);

finally

imgListFree;

end;

end else

begin

//如果是EXE、Ico文件,直接取文件的图标

if (TypeName = 'exe') or (TypeName = 'ico') then

begin

ExtractIconExw(pwidechar(strTmp), 0, IndexL, IndexS, 1);

if IndexS <> 0 then

begin

IconHandle := IndexS;

exit;

end;

end;

//在临时目录下建立一个空类型文件,便于取图标

TypeName := GetWindowsTempPath + TypeName;

if not wideFileExists(TypeName) then

with TUniFileStreamCreate(TypeName, fmCreate) do

Free;

imgList := TImageListCreateSize(32, 32);

try

imgListShareImages := True;

imgListHandle := ShGetFileInfo ('', 0, SHFileInfo, SizeOf(SHFileInfo),

SHGFI_SYSICONINDEX or

SHGFI_SMALLICON);

ShGetFileInfo (pchar( string( TypeName)), 0, SHFileInfo, SizeOf(SHFileInfo),

SHGFI_SYSICONINDEX or

SHGFI_SMALLICON);

imgListGetIcon(SHFileInfoiIcon, Icon);

finally

imgListFree;

end;

end;

end;

字段名称类型描述

id自动编号 主键值

img OLE对象 用来保存数据procedure TForm1Button1Click(Sender: TObject);

var

F:File of Byte;

size:Longint; //文件大小

FilePath,time:string; //文件时间

begin

FilePath:=ExtractFilePath(Paramstr(0))+'demojpg';//地址为当前目录下

AssignFile(F,FilePath);

reset(F);

size:=Filesize(F);//获取文件大小。

time:=DatetimetoStr(FileDateToDateTime(FileAge(FilePath)));//获取文件创建时间。

closefile(F);

adoquery1Close;

adoquery1SQLClear;

adoquery1SQLAdd('select from Image');

adoquery1Open;

adoquery1Insert;

adoquery1FieldByName('FileName')AsString:=ExtractFileName(FilePath); //存储文件名称

adoquery1FieldByName('FileKind')AsString:=ExtractFileExt(FilePath); //存储文件扩展名。

adoquery1FieldByName('FileSize')AsInteger:=size; //存储文件的大小。

adoquery1FieldByName('FileTime')AsString:=time; //存储文件的创建时间。

adoquery1FieldByName('SaveTime')AsDateTime:=now();//存取文件的存储时间

TBlobField(ADOquery1FieldByName('FileContent'))LoadFromFile(FilePath);//的二进制流,存进去之后,数据库会显示(<<Binary>>)

ADOquery1Post;

end;下面是读取还有代开的代码,添加一个Timage空间进行显示,ID为我的自增列,读取最后一条插入记录procedure TForm1Button2Click(Sender: TObject);

Var

Ms:TStream;

jpg:Tjpegimage;

begin

adoquery1Close;

adoquery1SQLClear;

adoquery1SQLAdd('select top 1 from Image order by id desc');

adoquery1Open;

Ms:=TStreamCreate;

MS:=adoquery1CreateBlobStream(adoquery1FieldbyName('FileContent'),bmRead);

MsPosition :=0;

jpg:=TjpegimageCreate;

JpgLoadFromStream(Ms);

Image1PictureAssign(Jpg);

jpgFree;

MSFree;

end;当然这里你也可以将其中的代码修改一下,不用显示就把“Image1PictureAssign(Jpg);”改为保存“JpgSaveToFile(路径);” 详情可以上我的百度博客看>

以上就是关于我的delphi程序编译了怎么版本号没有变啊全部的内容,包括:我的delphi程序编译了怎么版本号没有变啊、DELPHI基础教程:Delphi开发数据库应用程序概述(一)[3]、用Delphi怎样取得和改变某个文件的属性等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9590795.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-29
下一篇2023-04-29

发表评论

登录后才能评论

评论列表(0条)

    保存