FileClose - C++ Builder

2021-11-16  本文已影响0人  玄坴

C++ Builder 参考手册System::SysutilsFileClose


关闭由 FileCreate 或 FileOpen 打开的文件

头文件:#include <System.SysUtils.hpp>
命名空间:System::Sysutils
函数原型:

void __fastcall FileClose(NativeUInt Handle);

参数:

返回值:


例:创建一个 UTF-8 文本文件,写入一行文字

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    NativeUInt hFile = FileCreate(L"D:\\HsuanluFileTest.txt");
    if(hFile == (NativeUInt)INVALID_HANDLE_VALUE)
    {
        ShowMessage(L"创建文件失败");
        return;
    }
    UTF8String s = L"测试 FileCreate / FileWrite / FileClose - 玄坴";
    FileWrite(hFile, "\xEF\xBB\xBF", 3); // UTF-8 BOM
    FileWrite(hFile, s.c_str(), s.Length());
    FileClose(hFile);
}

相关:


C++ Builder 参考手册System::SysutilsFileClose

上一篇 下一篇

猜你喜欢

热点阅读