请告诉您如何将文件最大大小设置为 100 位元。 如果我试图写入超过 100 位元的更多数据, 则 < code> untwritefile () 应当丢弃错误 < code> ERROR_ NOT_ ENOUGH_ MEMORY code > 。
请建议我, 一个设置 100 字节( 或固定大小) 文件的 Widnows API 。
在我们的产品中, ntwritefile () 错误失败 。 我试图理解, 在什么情况下, 我们会得到错误 。
请告诉您如何将文件最大大小设置为 100 位元。 如果我试图写入超过 100 位元的更多数据, 则 < code> untwritefile () 应当丢弃错误 < code> ERROR_ NOT_ ENOUGH_ MEMORY code > 。
请建议我, 一个设置 100 字节( 或固定大小) 文件的 Widnows API 。
在我们的产品中, ntwritefile () 错误失败 。 我试图理解, 在什么情况下, 我们会得到错误 。
使用 SetFilePointer
,然后是 SetEndofFile
。在 SetEndofFile
之后,不要忘记 CloseHandle
!
您可以创建大小为 100 字节的缓冲符, 完成后将缓冲符写入文件 。
#include <stdio.h>
#include <memory.h>
int main(int argc, char* argv[])
{
char buffer[100];
//assign values
memset(buffer, A , 100);
buffer[5]= @ ;
FILE * pFile;
pFile = fopen ( "buffer.100" , "wb" );
fwrite (buffer, 1, sizeof(buffer) , pFile );
fclose (pFile);
return 0;
}
您要创建100字节的文件吗? 还是要将文件大小限制为100字节? 意味着如果文件超过100字节, 文件上的任何进一步写作都不会有效?
如果在那之后您第一次重写它, 您可以使用 CreateFile
和 writeFile
, 并将缓冲大小限制在100字节。
如果它的第二个... 那么我想它不可能...
从建筑学角度看,你的最佳方法如下:
I m sorry you don t need a buffer for this. Simply if you create a memory map object of file ,which is greater than the file size, the system automatically expand the file into that size.
But for just 100bytes you just create a 100 bytes of dummy char array and write it to the file.
see, http://msdn.microsoft.com/en-us/library/windows/desktop/aa366542(v=vs.85).aspx
I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...
I have been searching for sample code creating iterator for my own container, but I haven t really found a good example. I know this been asked before (Creating my own Iterators) but didn t see any ...
Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...
I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?
Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...
Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?