Delphi文件操作
unit unitFileOP;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
implementation
function GetSys32Dir:String;
var
Sys32Dir: string;
pSys32Dir: array[0..Max_Path] of char;
begin
GetSystemDirectory(pSys32Dir,Max_Path);
Sys32Dir := String(pSys32Dir) + chr(92);
Result := Sys32Dir;
end;
procedure MyFileCopy(const fromFile, ToFile: string);
var
fromF, ToF: file;
NumRead, NumWritten: integer;
Buf: array[1..2048] of Char;
begin
AssignFile(fromF, fromFile);
Reset(fromF, 1);
AssignFile(ToF, ToFile);
Rewrite(ToF, 1);
repeat
BlockRead(fromF, Buf, SizeOf(Buf), NumRead);
BlockWrite(ToF, Buf, NumRead, NumWritten);
until (NumRead = 0) or (NumWritten <> NumRead);
CloseFile(fromF);
CloseFile(ToF);
end;
function GetExeFileVersion(fn: string; var ma, mi, r, b: integer): boolean;
var
buf, p: pChar;
sver: ^VS_FIXEDFILEINFO;
i: LongWord;
begin
i := GetFileVersionInfoSize(pchar(fn), i);
new(sver);
p := pchar(sver);
GetMem(buf, i);
ZeroMemory(buf, i);
result := false;
if GetFileVersionInfo(pchar(fn), 0, 4096, pointer(buf)) then
if VerQueryValue(buf, '\', pointer(sver), i) then
begin
ma := sVer^.dwFileVersionMS shr 16;
mi := sver^.dwFileVersionMS and $0000FFFF;
r := sver^.dwFileVersionLS shr 16;
b := sver^.dwFileVersionLS and $0000FFFF;
result := true;
end;
Dispose(p);
FreeMem(buf);
end;
function GetVersionString(const pFileName: string): string;
var
VerInfoSize: DWORD;
VerInfo: Pointer;
VerValueSize: DWORD;
Dummy: DWORD;
VerValue: PVSFixedFileInfo;
begin
Result := '0';
VerInfoSize := GetFileVersionInfoSize(PChar(pFileName), Dummy);
if VerInfoSize = 0 then
Exit;
GetMem(VerInfo, VerInfoSize);
GetFileVersionInfo(PChar(pFileName), 0, VerInfoSize, VerInfo);
VerQueryValue(VerInfo, chr(92), Pointer(VerValue), VerValueSize);
相关文档:
一年前开发了一个MIDAS的程序,最近修改服务端,可是这个服务无法注册,最后终于找到了解决办法,这个相关文章如下:(算是备份吧)
(一)MIDAS是什么?
Delphi中MIDAS到底是什么呢?和他相关组件是什么呢?
MIDAS(Multitiered Distributed Application Services)多层分布式应用服务。
Delphi所提出 ......
下面三个delphi函数实现了bmp类型图片和jpg(jpeg)类型图片的转换和改变位图图片的大小。
jpg转换为bmp:
{********************************************
作者/日期
描述: 实现jpg(jpeg)图片向bmp图片的转换
参数介绍
FileName:要转换的jpg(jpeg)图片的名称(包括路径)
SaveFileName:转换后的bmp图片的存储位置。
......
URL: http://edn.embarcadero.com/article/27568
Abstract: Delphi 6 introduces support for COM+ object pooling, which can provide significant performance improvements under some circumstances. We take a look at Delphi 6s object pooling support. By Vincent Parrett.
Typically, when a client appl ......
谁说Delphi没有哈希?--Delphi中,TStringList和THashedStringList的性能对比
曾经看到很多人在嚷嚷Delphi没有哈希表,这些人的动手意识姑且不论,却还有很多人以此来证明Delphi比别的语言垃圾,实在是...
好,牢骚打住,转接正题。
TStringList是我们常用的字符串列表类型,用法就不在这里赘述,但是,在数据其项数增 ......
procedure TForm_BaseMDI.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
Key := #0;
SendMessage(Handle, 48384, 9, 0);
end;
end; ......