高手帮忙:可以把word文件进行base64编码,转换字符串的方式,最后保存到表去(以后并能读出来)???(60分)

  • 主题发起人 主题发起人 0752
  • 开始时间 开始时间
0

0752

Unregistered / Unconfirmed
GUEST, unregistred user!
高手帮忙:可以把word文件进行base64编码,转换字符串的方式,最后保存到表去(以后并能读出来)???
 
兄弟,你的问题我看的比较模糊。您的实际含义是不是这样:将Word文件保存到数据库中,以后可以调出来?
如果是这个含义,您可以这样处理:
(1)将Word文档直接存入数据库。
(2)调用的时候,读出来存到本地文件系统,然后打印。
具体的代码,可以从论坛中查询,或者直接向我要。
 
zhl_yt:你好。
我的问题意思是:把wore文件,图片或者其他文件保存到表去,其中,当然不能把原文件保存到表去,所以要通过处理,我不想通过流保存到表去,而是想通过base64编码(产生如15656fse5574...等格式)保存到表去,最后可以通过表读取文件,不知是否可以。
 
你是要Base64的机密解密算法函数还是要什么?
 
没问题。给你贴一个BASE64的单元
不过建议用二进制字段存储,效率更高。
unit BASE64;

interface

{.DEFINE SpeedDecode}

{$IFNDEF SpeedDecode}
{$DEFINE ValidityCheck}
{$ENDIF}

uses SysUtils;

// codiert einen String in die zugeh?rige Base64-Darstellung
function EncodeBase64(const InText: AnsiString): AnsiString; overload;
// decodiert die Base64-Darstellung eines Strings in den zugeh?rigen String
function DecodeBase64(const InText: AnsiString): AnsiString; overload;

// bestimmt die Gr??e der Base64-Darstellung
function CalcEncodedSize(InSize: Cardinal): Cardinal;
// bestimmt die Gr??e der bin?ren Darstellung
function CalcDecodedSize(const InBuffer; InSize: Cardinal): Cardinal;

// codiert einen Buffer in die zugeh?rige Base64-Darstellung
procedure Base64Encode(const InBuffer; InSize: Cardinal; var OutBuffer);
overload; register;
// decodiert die Base64-Darstellung in einen Buffer
{$IFDEF SpeedDecode}
procedure Base64Decode(const InBuffer; InSize: Cardinal; var OutBuffer);
overload; register;
{$ENDIF}
{$IFDEF ValidityCheck}
function Base64Decode(const InBuffer; InSize: Cardinal; var OutBuffer): Boolean;
overload; register;
{$ENDIF}

// codiert einen String in die zugeh?rige Base64-Darstellung
procedure Base64Encode(const InText: AnsiString; var OutText: AnsiString);
overload;
// decodiert die Base64-Darstellung eines Strings in den zugeh?rigen String
procedure Base64Decode(const InText: AnsiString; var OutText: AnsiString);
overload;

implementation

const
cBase64Codec: array[0..63] of AnsiChar =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
Base64Filler = '=';

function EncodeBase64(const InText: string): string; overload;
begin
Base64Encode(InText, Result);
end;

function DecodeBase64(const InText: string): string; overload;
begin
Base64Decode(InText, Result);
end;

function CalcEncodedSize(InSize: Cardinal): Cardinal;
begin
// no buffers passed along, calculate outbuffer size needed
Result := (InSize div 3) shl 2;
if ((InSize mod 3) > 0) then INC(Result, 4);
end;

function CalcDecodedSize(const InBuffer; InSize: Cardinal): Cardinal;
type
BA = array of Byte;
begin
Result := 0;
if InSize = 0 then
Exit;
if InSize mod 4 <> 0 then
Exit;
Result := InSize div 4 * 3;
if (BA(InBuffer)[InSize - 2] = Ord(Base64Filler)) then
Dec(Result, 2)
else if BA(InBuffer)[InSize - 1] = Ord(Base64Filler) then
Dec(Result);
end;

procedure Base64Encode(const InBuffer; InSize: Cardinal; var OutBuffer
); register;
var
ByThrees, LeftOver: Cardinal;
// reset in- and outbytes positions
asm
// load addresses for source and destination
// PBYTE(InBuffer);
mov ESI, [EAX]
// PBYTE(OutBuffer);
mov EDI, [ECX]
// ByThrees := InSize div 3;
// LeftOver := InSize mod 3;
// load InSize (stored in EBX)
mov EAX, EBX
// load 3
mov ECX, $03
// clear upper 32 bits
xor EDX, EDX
// divide by ECX
div ECX
// save result
mov ByThrees, EAX
// save remainder
mov LeftOver, EDX
// load addresses
lea ECX, cBase64Codec[0]
// while I < ByThrees do
// begin
xor EAX, EAX
xor EBX, EBX
xor EDX, EDX
cmp ByThrees, 0
jz @@LeftOver
@@LoopStart:
// load the first two bytes of the source triplet
LODSW
// write Bits 0..5 to destination
mov BL, AL
shr BL, 2
mov DL, BYTE PTR [ECX + EBX]
// save the Bits 12..15 for later use [1]
mov BH, AH
and BH, $0F
// save Bits 6..11
rol AX, 4
and AX, $3F
mov DH, BYTE PTR [ECX + EAX]
mov AX, DX
// store the first two bytes of the destination quadruple
STOSW
// laod last byte (Bits 16..23) of the source triplet
LODSB
// extend bits 12..15 [1] with Bits 16..17 and save them
mov BL, AL
shr BX, 6
mov DL, BYTE PTR [ECX + EBX]
// save bits 18..23
and AL, $3F
xor AH, AH
mov DH, BYTE PTR [ECX + EAX]
mov AX, DX
// store the last two bytes of the destination quadruple
STOSW
dec ByThrees
jnz @@LoopStart
@@LeftOver:
// there are up to two more bytes to encode
cmp LeftOver, 0
jz @@Done
// clear result
xor EAX, EAX
xor EBX, EBX
xor EDX, EDX
// get left over 1
LODSB
// load the first six bits
shl AX, 6
mov BL, AH
// save them
mov DL, BYTE PTR [ECX + EBX]
// another byte ?
dec LeftOver
jz @@SaveOne
// save remaining two bits
shl AX, 2
and AH, $03
// get left over 2
LODSB
// load next 4 bits
shl AX, 4
mov BL, AH
// save all 6 bits
mov DH, BYTE PTR [ECX + EBX]
shl EDX, 16
// save last 4 bits
shr AL, 2
mov BL, AL
// save them
mov DL, BYTE PTR [ECX + EBX]
// load base 64 'no more data flag'
mov DH, Base64Filler
jmp @@WriteLast4
@@SaveOne:
// adjust the last two bits
shr AL, 2
mov BL, AL
// save them
mov DH, BYTE PTR [ECX + EBX]
shl EDX, 16
// load base 64 'no more data flags'
mov DH, Base64Filler
mov DL, Base64Filler
// ignore jump, as jump reference is next line !
// jmp @@WriteLast4
@@WriteLast4:
// load and adjust result
mov EAX, EDX
ror EAX, 16
// save it to destination
STOSD
@@Done:
end;

{$IFDEF SpeedDecode}

procedure Base64Decode(const InBuffer; InSize: Cardinal; var OutBuffer);
overload; register;
{$ENDIF}
{$IFDEF ValidityCheck}

function Base64Decode(const InBuffer; InSize: Cardinal; var OutBuffer):
Boolean; overload; register;
{$ENDIF}
const
{$IFDEF SpeedDecode}
cBase64Codec: array[0..127] of Byte =
{$ENDIF}
{$IFDEF ValidityCheck}
cBase64Codec: array[0..255] of Byte =
{$ENDIF}
(
$FF, $FF, $FF, $FF, $FF, {005>} $FF, $FF, $FF, $FF, $FF, // 000..009
$FF, $FF, $FF, $FF, $FF, {015>} $FF, $FF, $FF, $FF, $FF, // 010..019
$FF, $FF, $FF, $FF, $FF, {025>} $FF, $FF, $FF, $FF, $FF, // 020..029
$FF, $FF, $FF, $FF, $FF, {035>} $FF, $FF, $FF, $FF, $FF, // 030..039
$FF, $FF, $FF, $3E, $FF, {045>} $FF, $FF, $3F, $34, $35, // 040..049
$36, $37, $38, $39, $3A, {055>} $3B, $3C, $3D, $FF, $FF, // 050..059
$FF, $FF, $FF, $FF, $FF, {065>} $00, $01, $02, $03, $04, // 060..069
$05, $06, $07, $08, $09, {075>} $0A, $0B, $0C, $0D, $0E, // 070..079
$0F, $10, $11, $12, $13, {085>} $14, $15, $16, $17, $18, // 080..089
$19, $FF, $FF, $FF, $FF, {095>} $FF, $FF, $1A, $1B, $1C, // 090..099
$1D, $1E, $1F, $20, $21, {105>} $22, $23, $24, $25, $26, // 100..109
$27, $28, $29, $2A, $2B, {115>} $2C, $2D, $2E, $2F, $30, // 110..119
$31, $32, $33, $FF, $FF, {125>} $FF, $FF, $FF // 120..127

{$IFDEF ValidityCheck}
{125>}, $FF, $FF, // 128..129
$FF, $FF, $FF, $FF, $FF, {135>} $FF, $FF, $FF, $FF, $FF, // 130..139
$FF, $FF, $FF, $FF, $FF, {145>} $FF, $FF, $FF, $FF, $FF, // 140..149
$FF, $FF, $FF, $FF, $FF, {155>} $FF, $FF, $FF, $FF, $FF, // 150..159
$FF, $FF, $FF, $FF, $FF, {165>} $FF, $FF, $FF, $FF, $FF, // 160..169
$FF, $FF, $FF, $FF, $FF, {175>} $FF, $FF, $FF, $FF, $FF, // 170..179
$FF, $FF, $FF, $FF, $FF, {185>} $FF, $FF, $FF, $FF, $FF, // 180..189
$FF, $FF, $FF, $FF, $FF, {195>} $FF, $FF, $FF, $FF, $FF, // 190..199
$FF, $FF, $FF, $FF, $FF, {205>} $FF, $FF, $FF, $FF, $FF, // 200..209
$FF, $FF, $FF, $FF, $FF, {215>} $FF, $FF, $FF, $FF, $FF, // 210..219
$FF, $FF, $FF, $FF, $FF, {225>} $FF, $FF, $FF, $FF, $FF, // 220..229
$FF, $FF, $FF, $FF, $FF, {235>} $FF, $FF, $FF, $FF, $FF, // 230..239
$FF, $FF, $FF, $FF, $FF, {245>} $FF, $FF, $FF, $FF, $FF, // 240..249
$FF, $FF, $FF, $FF, $FF, {255>} $FF // 250..255
{$ENDIF}
);
asm
push EBX
mov ESI, [EAX]
mov EDI, [ECX]
{$IFDEF ValidityCheck}
mov EAX, InSize
and EAX, $03
cmp EAX, $00
jz @@DecodeStart
jmp @@ErrorDone
@@DecodeStart:
{$ENDIF}
mov EAX, InSize
shr EAX, 2
jz @@Done
lea ECX, cBase64Codec[0]
xor EBX, EBX
dec EAX
jz @@LeftOver
push EBP
mov EBP, EAX
@@LoopStart:
// load four bytes into EAX
LODSD
// save them to EDX as AX is used to store results
mov EDX, EAX
// get bits 0..5
mov BL, DL
// decode
mov AH, BYTE PTR [ECX + EBX]
{$IFDEF ValidityCheck}
// check valid code
cmp AH, $FF
jz @@ErrorDoneAndPopEBP
{$ENDIF}
// get bits 6..11
mov BL, DH
// decode
mov AL, BYTE PTR [ECX + EBX]
{$IFDEF ValidityCheck}
// check valid code
cmp AL, $FF
jz @@ErrorDoneAndPopEBP
{$ENDIF}
// align last 6 bits
shl AL, 2
// get first 8 bits
ror AX, 6
// store first byte
STOSB
// align remaining 4 bits
shr AX, 12
// get next two bytes from source quad
shr EDX, 16
// load bits 12..17
mov BL, DL
// decode
mov AH, BYTE PTR [ECX + EBX]
{$IFDEF ValidityCheck}
// check valid code
cmp AH, $FF
jz @@ErrorDoneAndPopEBP
{$ENDIF}
// align ...
shl AH, 2
// ... and adjust
rol AX, 4
// get last bits 18..23
mov BL, DH
// decord
mov BL, BYTE PTR [ECX + EBX]
{$IFDEF ValidityCheck}
// check valid code
cmp BL, $FF
jz @@ErrorDoneAndPopEBP
{$ENDIF}
// enter in destination word
or AH, BL
// and store to destination
STOSW
// more coming ?
dec EBP
jnz @@LoopStart
pop EBP
// no
// last four bytes are handled separately, as special checking is needed
// on the last two bytes (may be end of data signals '=' or '==')
@@LeftOver:
// get the last four bytes
LODSD
// save them to EDX as AX is used to store results
mov EDX, EAX
// get bits 0..5
mov BL, DL
// decode
mov AH, BYTE PTR [ECX + EBX]
{$IFDEF ValidityCheck}
// check valid code
cmp AH, $FF
jz @@ErrorDone
{$ENDIF}
// get bits 6..11
mov BL, DH
// decode
mov AL, BYTE PTR [ECX + EBX]
{$IFDEF ValidityCheck}
// check valid code
cmp AL, $FF
jz @@ErrorDone
{$ENDIF}
// align last 6 bits
shl AL, 2
// get first 8 bits
ror AX, 6
// store first byte
STOSB
// get next two bytes from source quad
shr EDX, 16
// check DL for "end of data signal"
cmp DL, Base64Filler
jz @@SuccessDone
// align remaining 4 bits
shr AX, 12
// load bits 12..17
mov BL, DL
// decode
mov AH, BYTE PTR [ECX + EBX]
{$IFDEF ValidityCheck}
// check valid code
cmp AH, $FF
jz @@ErrorDone
{$ENDIF}
// align ...
shl AH, 2
// ... and adjust
rol AX, 4
// store second byte
STOSB
// check DH for "end of data signal"
cmp DH, Base64Filler
jz @@SuccessDone
// get last bits 18..23
mov BL, DH
// decord
mov BL, BYTE PTR [ECX + EBX]
{$IFDEF ValidityCheck}
// check valid code
cmp BL, $FF
jz @@ErrorDone
{$ENDIF}
// enter in destination word
or AH, BL
// AH - AL for saving last byte
mov AL, AH
// store third byte
STOSB
@@SuccessDone:
{$IFDEF ValidityCheck}
mov Result, $01
jmp @@Done
@@ErrorDoneAndPopEBP:
pop EBP
@@ErrorDone:
mov Result, $00
{$ENDIF}
@@Done:
pop EBX
end;

procedure Base64Encode(const InText: AnsiString; var OutText: AnsiString);
overload;
var
InSize, OutSize: Cardinal;
PIn, POut: POINTER;
begin
// get size of source
InSize := Length(InText);
// calculate size for destination
OutSize := CalcEncodedSize(InSize);
// prepare string length to fit result data
SetLength(OutText, OutSize);
PIn := @InText[1];
POut := @OutText[1];
// encode !
Base64Encode(PIn, InSize, POut);
end;

procedure Base64Decode(const InText: AnsiString; var OutText: AnsiString);
overload;
var
InSize, OutSize: Cardinal;
PIn, POut: POINTER;
begin
// get size of source
InSize := Length(InText);
// calculate size for destination
PIn := @InText[1];
OutSize := CalcDecodedSize(PIn, InSize);
// prepare string length to fit result data
SetLength(OutText, OutSize);
FillChar(OutText[1], OutSize, '.');
POut := @OutText[1];
// encode !
{$IFDEF SpeedDecode}
Base64Decode(PIn, InSize, POut);
{$ENDIF}
{$IFDEF ValidityCheck}
if not Base64Decode(PIn, InSize, POut) then
SetLength(OutText, 0);
{$ENDIF}
end;

end.
 
to VictorWoo:
请加我。qq:84430620,msn:wenjihao_wjh@hotmail.com
请允许我在QQ或MSN请教你,因为这个问题对我很重要,做了好久都不行
 
公司的防火墙太BT,上不了一时。不好意思。
我觉得,您所要做的,用流最合适不过了,为何不用呢?2175303贴有可用于TStream的BASE64函数。
另外,您这样的做法,数据量大时,恐怕性能会很不理想。前面有讨论过了,最佳做法是用数据库来存放文件的路径,而文件单独存放。

另,文件直接存倒是很简单:
--------------------
with adoquery1 do
begin
active:=false;
sql.Clear;
sql.Text:='select * from tbupfile where 1=2';
active:=true;

insert;
TBlobField(fieldbyname('upfileData')).LoadFromFile(ExeFileName);
post;
end;
ShowMessage('上传完毕!');


下载:TBlobField(fieldbyname('upfiledata')).SaveToFile(ExeFileName);
 
to VictorWoo:
我要传到别的机器的(甚至跨网),所以不能用数据库来存放文件的路径,而文件单独存放,而你上面给我的是用流保存,这个我会,但我不能用。
我希望你能给我个通过base64保存文件到表去的方法。
 
上面那段用blobfield的就可以啊:)

DFW里找了段比较完整的:

来自: zqs10597249, 时间: 2002-02-06 16:23:00, ID: 911517
先把文件存入库
tab_TB_JCWH_WDMB.Insert;
tab_TB_JCWH_WDMB.FieldByName('dcid').asstring:=fdcid;
tab_TB_JCWH_WDMB.FieldByName('wdlx').asstring:=fwdlx;
tab_TB_JCWH_WDMB.FieldByName('mbmc').asstring:=edit_mbmc.text;
tab_TB_JCWH_WDMB.FieldByName('zwhy').asstring:=edit_zwhy.text;
tab_TB_JCWH_WDMB.FieldByName('wjlj').asstring:=edit_wjlj.text;
tab_TB_JCWH_WDMB.FieldByName('bcsm').asstring:=memo1.text;
tab_TB_JCWH_WDMB.FieldByName('dylx').asstring:=copy(edit_wjlj.text,length(edit_wjlj.text)-3,4);
WriteDbStream(OpenDialog1.FileName,tab_TB_JCWH_WDMB.FieldByName('wdmb') as TBlobField);
tab_TB_JCWH_WDMB.ApplyUpdates;
tab_TB_JCWH_WDMB.CommitUpdates;
说明WriteDbStream
//Fname为文件名,BField为BLOB字段,成功反回true 否则为false
Function WriteDbStream(FName:string;BField: TBlobField):boolean;
var
MemSize: Integer;
Buffer: PChar;
BStream: TBlobStream;
FHandle:HFile;
num:DWord;
begin
result:=true;
if not FileExists(FName) then
begin
Application.MessageBox('文件不存在!','错误',MB_OKCANCEL+MB_ICONEXCLAMATION);
result:=false;
exit;
end;
try
FHandle:=_lopen(PChar(FName), OF_READ+OF_SHARE_DENY_NONE);
if (FHandle = INVALID_HANDLE_VALUE) then
begin
Application.MessageBox('打开文件失败!','错误',MB_OKCANCEL+MB_ICONEXCLAMATION);
result:=false;
exit;
end;
try
BStream := TBlobStream.Create(BField, bmWrite);
MemSize :=_llseek(FHandle,0,FILE_END);
//加一字节放NULL字符
//Inc(MemSize);
try
Buffer := AllocMem(MemSize);
except
FreeMem(Buffer,MemSize);
Application.MessageBox('分配内存失败!','错误',MB_OKCANCEL+MB_ICONEXCLAMATION);
result:=false;
exit;
end;
_llseek(FHandle,0,FILE_BEGIN);
_lread(FHandle,buffer,MemSize);
BStream.Seek(0, soFromBeginning);
//流指针位置放到最前
BStream.Write(Buffer^,MemSize);
finally
BStream.Free;
FreeMem(Buffer,MemSize);
end;
finally
_lclose(FHandle);
end;
end;

来自: zqs10597249, 时间: 2002-02-06 16:32:00, ID: 911549
打开之前自己先建个临时文件,从数据库把数据读出来写进这个文件里
procedure Tsb_sbgl_wdmx.Button1Click(Sender: TObject);//文档信息按钮
var
fstr:string;
ldcid,lwdbm:string;
begin
if not DirectoryExists('c:/temp') then
MkDir('c:/temp');

fstr:='c:/temp/HDBFS_QWJS'+fdylx;//fdylx入库时对应的文件的后缀
ldcid:=fdcid;
lwdbm:=fwdbm;
try
tab_tb_wdgl_wdmx.open;
except
exit;
end;
if not tab_tb_wdgl_wdmx.Locate('dcid;wtbm',VarArrayOf([lDCID,lWDBM]),[]) then
exit;
ReadDbStream(fstr,tab_tb_wdgl_wdmx.FieldByName('wdmx') as TBlobField);
OpenTypeFile(fdylx,fstr);
end;
说明ReadDbStream
//Fname为文件名,BField为BLOB字段,成功反回true 否则为false
Function ReadDbStream(FName:string;BField: TBlobField):Boolean;
var
MemSize: Integer;
Buffer: PChar;
BStream: TBlobStream;
FHandle:HFile;
num:DWord;
FDir:string;
begin
//如果文件存在则先删除
result:=true;
//判断路径
FDir:=copy(FName,0,GetPos('/',FName) - 1);
if not DirectoryExists(FDir) then
begin
//如果路径不存在,则创建C:/TEMP,文件名则相应改变
FDir:='c:/temp';
FName:=FDir + Copy(FName,GetPos('/',FName),length(FName) - GetPos('/',FName) + 1);
if not DirectoryExists(FDir) then
begin
if not ForceDirectories(FDir) then
begin
result:=false;
exit;
end;
end;
end;
if FileExists(FName) then DeleteFile(FName);
try
FHandle:=_lcreat(PChar(FName),0);
if (FHandle =INVALID_HANDLE_VALUE) then
begin
Application.MessageBox('创建文件失败!','错误',MB_OKCANCEL+MB_ICONEXCLAMATION);
result:=false;
exit;
end;
try
BStream:=TBlobStream.Create(BField, bmRead);
MemSize := BStream.Size;
//加一字节放NULL字符
//Inc(MemSize);
try
Buffer := AllocMem(MemSize);
except
FreeMem(Buffer,MemSize);
Application.MessageBox('分配内存失败!','错误',MB_OKCANCEL+MB_ICONEXCLAMATION);
result:=false;
exit;
end;
BStream.Read(Buffer^,MemSize);
_llseek(FHandle,0,FILE_BEGIN);
_lwrite(FHandle,Buffer,MemSize);
finally
BStream.Free;
FreeMem(Buffer,MemSize);
end;
finally
_lclose(FHandle);
end;
end;
说明OpenTypeFile
//***extname后缀名,**************filename文件名
procedure OpenTypeFile(extname,filename:string);
function GetOpenFileCommand(ls_ext:string):string;
function GetCommand(ext,subkey:string):string;
var Reg:TRegistry;
str:string;
begin
if ext[1]<>'.' then ext:='.'+ext;
try
Reg:=TRegistry.Create;
Reg.RootKey:= HKEY_CLASSES_ROOT;
Reg.OpenKey(ext, True);
//读取类型值
str:=Reg.ReadString('');
Reg.CloseKey;
str:= str+subkey;
Reg.OpenKey(str, True);
//读取打开文件的程序
str:=Reg.ReadString('');
Reg.CloseKey;
finally
Reg.Free;
end;
result:=str;
end;
var str:string;
position:integer;
dir:Array[1..512] of char;
begin
str:=GetCommand(ls_ext,'/shell/Open/command');
if str = '' then
begin
str:=GetCommand(ls_ext,'/DefaultIcon');
end;
str:=string(StrUpper(pchar(str)));
position:=pos('%SYSTEMROOT%',str);
if position > 0 then
begin
FillChar(dir,512,32);
GetwindowsDirectory(@dir,512);
Delete(str,position,12);
insert(trim(string(dir)),str,position);
end;
position:=pos('.',str);
str:=copy(str,1,position+3);
position:=pos('"',str);
if position>0 then
begin
Delete(str,position,1);
end;
result:=str;
end;
var ls_command:string;
FDir:string;
begin
if extname = '' then
begin
Application.MessageBox('该文件类型不存在!','错误',MB_OKCANCEL+MB_ICONEXCLAMATION);
exit;
end;
ls_command:=GetOpenFileCommand(extname);
if not FileExists(ls_command) then
begin
Application.MessageBox('打开该类型文件的应用程序不存在!','错误',MB_OKCANCEL+MB_ICONEXCLAMATION);
exit;
end;
//判断路径
FDir:=copy(FileName,0,GetPos('/',FileName) - 1);
if not DirectoryExists(FDir) then
begin
//如果路径不存在,则创建C:/TEMP,文件名则相应改变
FDir:='c:/temp';
FileName:=FDir + Copy(FileName,GetPos('/',FileName),length(FileName) - GetPos('/',FileName) + 1);
if not DirectoryExists(FDir) then
begin
if not ForceDirectories(FDir) then
exit;
end;
end;
if not FileExists(FileName) then
begin
Application.MessageBox('要打开的文件不存在!','错误',MB_OKCANCEL+MB_ICONEXCLAMATION);
exit;
end;
winexec(pchar('"'+ls_command + '" "' + filename+'"' ),SW_SHOWNORMAL);
end;

申明 tab_TB_JCWH_WDMB.FieldByName('dylx').asstring:=copy(edit_wjlj.text,length(edit_wjlj.text)-3,4);
有问题,我只是对与word
取文件的后缀,就是调用类型。要查找‘.'你自己看看。
实际上我这个函数是用来对多媒体信息的,当然包括word
 
帮顶!

╭=========================================╮

80G海量源代码,控件,书籍全免费狂下不停!

http://www.source520.com

个人网站站长开发推广同盟,让所有人知道你的世界!

http://www.source520.com/search/search.asp

╰=========================================╯
 
kaoleoloi,我真的真的很烦你了。
 
后退
顶部