如何将FORMAT.COM文件集成到我的EXE文件中?(100分)

H

ham9v

Unregistered / Unconfirmed
GUEST, unregistred user!
如何将FORMAT.COM文件集成到我的EXE文件中?
多谢各位!!!
 
当成资源文件加进来,用的时候解出来,Winexec后就删除。
 
用得着用format.com吗?在shell32.dll就有这样的函数:
There is an API hidden away in Shell32.dll called SHFormatDrive, this brings up the standard format removable drive dialog. I stumbled across this in the borland.public.delphi.winapi newsgroup.

{implementation section}
..
..
const
SHFMT_ID_DEFAULT = $FFFF;
// Formating options
SHFMT_OPT_QUICKFORMAT = $0000;
SHFMT_OPT_FULL = $0001;
SHFMT_OPT_SYSONLY = $0002;
// Error codes
SHFMT_ERROR = $FFFFFFFF;
SHFMT_CANCEL = $FFFFFFFE;
SHFMT_NOFORMAT = $FFFFFFFD;

function SHFormatDrive(Handle: HWND; Drive, ID, Options: Word): LongInt;
stdcall; external 'shell32.dll' name 'SHFormatDrive'

procedure TForm1.btnFormatDiskClick(Sender: TObject);
var
retCode: LongInt;
begin
retCode:= SHFormatDrive(Handle, 0, SHFMT_ID_DEFAULT,
SHFMT_OPT_QUICKFORMAT);
if retCode < 0 then
ShowMessage('Could not format drive');
end;

end.
/////////////////////////////////////////
function SHFormatDrive(hWnd : HWND;Drive, fmtID, Options : WORD) : longint; stdcall; external 'shell32.dll';
function _DiskFormat( const Drive : Char ):string; //对一个可移动驱动器或硬盘驱动器格式化,注意这个函数是非常危险的.
var
wDrive : WORD;
dtDrive : string;
formatretcode:longint;
begin
dtDrive := _DiskDriverType(Upcase(Drive));
if not _OK(dtDrive) then begin
result:=dtDrive+'(DiskFormat)'; exit;
end;
// if it's not a HDD or a FDD then raise an exception
if (not _Contain('可移动',dtDrive)) and (not _Contain('硬盘',dtDrive)) then
result := badresult+'无法格式化一个'+dtDrive
else begin// 进行格式化
wDrive := Ord( UpCase(Drive) ) - Ord( 'A' );
// SHFormatDrive 是一个没有公开的 API 函数调用
formatretcode:=SHFormatDrive( Application.Handle, wDrive, $ffff, 0);
if formatretcode=-1 then result:=badresult+'格式化程序已执行,在格式化中发生错误,返回代码:'+inttostr(formatretcode)
else if formatretcode=-2 then result:=badresult+'格式化程序已执行,用户放弃格式化驱动器:'+Drive
else if formatretcode=6 then result:='格式化程序已执行,完成驱动器:'+Drive+'的格式化'
else result:='格式化程序已执行,返回代码:'+inttostr(formatretcode);
end; // else
end;
 
to :louhong
我只能用I服了U来形容了,哈。
 
to bigroute:
听起来好象有言外之意?
 
to :louhong
没什么,我还在围绕问题转呢,你已经直接给出结果了。
 
好办法,不知道这个函数还真难办啊。向louhong致敬
 
to all:
我知道用资源文件,我用记事本写了一个文件:
myexefile file1 format.com
然后更改其扩展名后重新命令为qq.rc,再把format.com,qq.rc拷贝到Brcc32.exe同一目录
再在MSDOS下运行brcc32 qq.rc,但结果是could not open input file 'qq.rc'(win2000系统下)
不知是何原因?请大虾指教!!!多谢!

据说使用“流”技术可以不释放也可使用集成在EXE文件的资源,不知哪儿有这方面的资料,还
请大家帮帮忙!!!
 
多人接受答案了。
 
顶部