C\S 通信中,比如 客户端知道要接受 Test.txt 文件,如何才能在客户端 弹出像QQ文件另存为那样的对话框,
来选择接收文件的路径, 默认文件名为原始名字(注:需要在Dll中实现)。哪位兄弟帮忙指点一下,万分感谢!
来选择接收文件的路径, 默认文件名为原始名字(注:需要在Dll中实现)。哪位兄弟帮忙指点一下,万分感谢!
解决方案 »
- 关于内存存取保护函数的使用
- 抢分啦 delphi 生成文本文件 问题
- 请教,delphi的dbcombobox控件,与数据库的某field关联,为何下拉框中没有显示该fields的值呢....
- 在对一个数据集做遍历或循环操作时,不想使数据感知控件(如DBGrid)显示数据怎么办?
- double和real型有什么区别
- 请问:在DELPHI中如何把一字符串转换为命令或控件名使用,DELPHI中有宏定义的概念吗?
- 如何在打开一个子窗口的时候关掉另一个子窗口?
- 怎样把自定义数据类型存入字段中
- 问一个delphi编码问题 gbk转ansi
- 大家来说说看,是delphi5好,还是6好啊?
- delphi procedure 终止
- sql server2000本身的whlie
unit OSDialogLib;
interface
uses
Windows,SysUtils,Dialogs,Forms;
function ShowOpenFileDialog(const DialogPrompt:PChar;
const DefaultFileName:PChar;
const FileFilter:PChar):PChar; stdcall;
function ShowSaveFileDialog(const DialogPrompt:PChar;
const DefaultFileName:PChar;
const FileFilter:PChar):PChar; stdcall;
implementation
//显示打开文件对话框
function ShowOpenFileDialog(const DialogPrompt:PChar;
const DefaultFileName:PChar;
const FileFilter:PChar):PChar; stdcall;
var
OpenFileDialog: TOpenDialog;
FileNameA: String;
FileName: String;
begin
Result := PChar('');
Application.Handle := GetActiveWindow();
OpenFileDialog := TOpenDialog.Create(Application);
OpenFileDialog.Filter := StrPas(FileFilter);
OpenFileDialog.Title := StrPas(DialogPrompt);
if OpenFileDialog.Title = '' then OpenFileDialog.Title := '打开';
//设置路径和文件必须存在
OpenFileDialog.Options := OpenFileDialog.Options + [ofPathMustExist, ofFileMustExist];
FileNameA := StrPas(DefaultFileName);
if FileNameA <> '' then OpenFileDialog.FileName := FileNameA;
if OpenFileDialog.Execute() then
begin
FileName := OpenFileDialog.FileName;
if Pos('nsf',FileName) <= 0 then FileName := FileName + '.nsf';
Result := PChar(FileName);
OpenFileDialog.Free;
end;
end;
//保存打开文件对话框
function ShowSaveFileDialog(const DialogPrompt:PChar;
const DefaultFileName:PChar;
const FileFilter:PChar):PChar; stdcall;
var
SaveFileDialog: TSaveDialog;
FileNameA: String;
FileName: String;
begin
Result := PChar('');
Application.Handle := GetActiveWindow();
SaveFileDialog := TSaveDialog.Create(Application);
SaveFileDialog.Filter := StrPas(FileFilter);
SaveFileDialog.Title := StrPas(DialogPrompt);
if SaveFileDialog.Title = '' then SaveFileDialog.Title := '另存为';
//设置提示用户文件已经存在
SaveFileDialog.Options := SaveFileDialog.Options + [ofOverwritePrompt];
FileNameA := StrPas(DefaultFileName);
if FileNameA <> '' then SaveFileDialog.FileName := FileNameA;
if SaveFileDialog.Execute() then
begin
FileName := SaveFileDialog.FileName;
if Pos('nsf',FileName) <= 0 then FileName := FileName + '.nsf';
Result := PChar(FileName);
SaveFileDialog.Free;
end;
end;
end.