久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <i id='W2MMe'><tr id='W2MMe'><dt id='W2MMe'><q id='W2MMe'><span id='W2MMe'><b id='W2MMe'><form id='W2MMe'><ins id='W2MMe'></ins><ul id='W2MMe'></ul><sub id='W2MMe'></sub></form><legend id='W2MMe'></legend><bdo id='W2MMe'><pre id='W2MMe'><center id='W2MMe'></center></pre></bdo></b><th id='W2MMe'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='W2MMe'><tfoot id='W2MMe'></tfoot><dl id='W2MMe'><fieldset id='W2MMe'></fieldset></dl></div>
      <bdo id='W2MMe'></bdo><ul id='W2MMe'></ul>
  • <legend id='W2MMe'><style id='W2MMe'><dir id='W2MMe'><q id='W2MMe'></q></dir></style></legend>
      1. <small id='W2MMe'></small><noframes id='W2MMe'>

        <tfoot id='W2MMe'></tfoot>

        我可以使用 CreateFile,但將句柄強制轉換為 std:

        Can I use CreateFile, but force the handle into a std::ofstream?(我可以使用 CreateFile,但將句柄強制轉換為 std::ofstream 嗎?)
        <tfoot id='RGoTb'></tfoot>
          <tbody id='RGoTb'></tbody>
            • <bdo id='RGoTb'></bdo><ul id='RGoTb'></ul>

                <small id='RGoTb'></small><noframes id='RGoTb'>

                • <i id='RGoTb'><tr id='RGoTb'><dt id='RGoTb'><q id='RGoTb'><span id='RGoTb'><b id='RGoTb'><form id='RGoTb'><ins id='RGoTb'></ins><ul id='RGoTb'></ul><sub id='RGoTb'></sub></form><legend id='RGoTb'></legend><bdo id='RGoTb'><pre id='RGoTb'><center id='RGoTb'></center></pre></bdo></b><th id='RGoTb'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='RGoTb'><tfoot id='RGoTb'></tfoot><dl id='RGoTb'><fieldset id='RGoTb'></fieldset></dl></div>
                  <legend id='RGoTb'><style id='RGoTb'><dir id='RGoTb'><q id='RGoTb'></q></dir></style></legend>
                  本文介紹了我可以使用 CreateFile,但將句柄強制轉換為 std::ofstream 嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  有什么方法可以利用 Win32 API 中的文件創建標志,例如 FILE_FLAG_DELETE_ON_CLOSEFILE_FLAG_WRITE_THROUGH,如此處所述http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx ,然后將該句柄強制轉換為 std::ofstream ?

                  Is there any way to take advantage of the file creation flags in the Win32 API such as FILE_FLAG_DELETE_ON_CLOSE or FILE_FLAG_WRITE_THROUGH as described here http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx , but then force that handle into a std::ofstream?

                  ofstream 的接口顯然是平臺無關的;我想在幕后"中強制執行一些平臺相關的設置.

                  The interface to ofstream is obviously platform independent; I'd like to force some platform dependent settings in 'under the hood' as it were.

                  推薦答案

                  可以將 C++ std::ofstream 附加到 Windows 文件句柄.以下代碼適用于 VS2008:

                  It is possible to attach a C++ std::ofstream to a Windows file handle. The following code works in VS2008:

                  HANDLE file_handle = CreateFile(
                      file_name, GENERIC_WRITE,
                      0, NULL, CREATE_ALWAYS,
                      FILE_ATTRIBUTE_NORMAL, NULL);
                  
                  if (file_handle != INVALID_HANDLE_VALUE) {
                      int file_descriptor = _open_osfhandle((intptr_t)file_handle, 0);
                  
                      if (file_descriptor != -1) {
                          FILE* file = _fdopen(file_descriptor, "w");
                  
                          if (file != NULL) {
                              std::ofstream stream(file);
                  
                              stream << "Hello World
                  ";
                  
                              // Closes stream, file, file_descriptor, and file_handle.
                              stream.close();
                  
                              file = NULL;
                              file_descriptor = -1;
                              file_handle = INVALID_HANDLE_VALUE;
                          }
                  }
                  

                  這適用于 FILE_FLAG_DELETE_ON_CLOSE,但 FILE_FLAG_WRITE_THROUGH 可能沒有預期的效果,因為數據將被 std::ofstream 對象緩沖,而不是直接寫入磁盤.但是,當調用 stream.close() 時,緩沖區中的任何數據都將刷新到操作系統.

                  This works with FILE_FLAG_DELETE_ON_CLOSE, but FILE_FLAG_WRITE_THROUGH may not have the desired effect, as data will be buffered by the std::ofstream object, and not be written directly to disk. Any data in the buffer will be flushed to the OS when stream.close() is called, however.

                  這篇關于我可以使用 CreateFile,但將句柄強制轉換為 std::ofstream 嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  In what ways do C++ exceptions slow down code when there are no exceptions thown?(當沒有異常時,C++ 異常會以何種方式減慢代碼速度?)
                  Why catch an exception as reference-to-const?(為什么要捕獲異常作為對 const 的引用?)
                  When and how should I use exception handling?(我應該何時以及如何使用異常處理?)
                  Scope of exception object in C++(C++中異常對象的范圍)
                  Catching exceptions from a constructor#39;s initializer list(從構造函數的初始化列表中捕獲異常)
                  Difference between C++03 throw() specifier C++11 noexcept(C++03 throw() 說明符 C++11 noexcept 之間的區別)
                • <i id='Y9M7E'><tr id='Y9M7E'><dt id='Y9M7E'><q id='Y9M7E'><span id='Y9M7E'><b id='Y9M7E'><form id='Y9M7E'><ins id='Y9M7E'></ins><ul id='Y9M7E'></ul><sub id='Y9M7E'></sub></form><legend id='Y9M7E'></legend><bdo id='Y9M7E'><pre id='Y9M7E'><center id='Y9M7E'></center></pre></bdo></b><th id='Y9M7E'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Y9M7E'><tfoot id='Y9M7E'></tfoot><dl id='Y9M7E'><fieldset id='Y9M7E'></fieldset></dl></div>
                    <tbody id='Y9M7E'></tbody>

                      <legend id='Y9M7E'><style id='Y9M7E'><dir id='Y9M7E'><q id='Y9M7E'></q></dir></style></legend>
                    1. <tfoot id='Y9M7E'></tfoot>
                        <bdo id='Y9M7E'></bdo><ul id='Y9M7E'></ul>

                        <small id='Y9M7E'></small><noframes id='Y9M7E'>

                            主站蜘蛛池模板: 午夜精品久久久 | 成年人在线观看 | 黄色精品| 久久aⅴ乱码一区二区三区 亚洲欧美综合精品另类天天更新 | 久久综合一区二区 | 亚洲毛片一区二区 | 欧美日韩国产精品 | 日韩三极 | 国产亚洲一区二区精品 | 日本色综合 | 久久久久久亚洲精品 | 激情欧美一区二区三区中文字幕 | 亚洲成人av在线播放 | 欧美456 | 天天操天天插 | 国产资源在线视频 | 国内精品视频 | 久久国产精彩视频 | 国产精品久久久久久久久久妞妞 | 欧美日韩成人在线 | 免费av直接看 | 国产一区在线视频 | 免费一区二区三区 | 精品国产欧美一区二区三区不卡 | 在线观看免费毛片 | 欧美一级艳情片免费观看 | 在线看av网址 | 日本aa毛片a级毛片免费观看 | 午夜小电影 | 999久久久久久久久 国产欧美在线观看 | 亚洲一区二区在线电影 | 成人在线视频免费看 | 成人免费毛片片v | 亚洲狠狠 | 成人av一区二区亚洲精 | 伊人网伊人网 | 一区二区三区国产精品 | 成人免费一区二区三区视频网站 | 91精品久久久久久久久久入口 | 亚洲国产欧美国产综合一区 | 成人一区二区视频 |