Questions tagged [createfile]

The Windows CreateFile API function

The Windows CreateFile API function.

Use this tag only in conjunction with the windows-specific API. Do not use this tag if you intend to refer to the generic concept of referring to a file.

474 questions
10
votes
4 answers

In Windows, should I use CreateFile or fopen, portability aside?

What are the differences, and in what cases one or the other would prove superior in some way?
CannibalSmith
  • 4,742
  • 10
  • 44
  • 52
8
votes
2 answers

Can't open COM1 from application launched at startup

I'm using WinLIRC with IR receiver connected to serial port COM1 on Windows 7 x64. WinLIRC is added to Startup folder (Start->All applications->Startup) so it starts every time I log in. Very often (but not all the time) I see initialization error…
n0rd
  • 11,850
  • 5
  • 35
  • 56
8
votes
1 answer

CreateFile() returns INVALID_HANDLE_VALUE but GetLastError() is ERROR_SUCCESS

I am opening a serial port using CreateFile(). I've got a testcase (too complicated to redistribute) that consistently causes CreateFile() to return INVALID_HANDLE_VALUE and GetLastError() to return ERROR_SUCCESS. By the looks of it, this bug only…
Gili
  • 86,244
  • 97
  • 390
  • 689
8
votes
7 answers

Best way to create an application icon

What is the best way to create an icon for an application? From Visual Studio or maybe some another program. I create an icon in Visual Studio and use it as application icon, but when I put the icon shortcut on the desktop there is only some gray…
tanasi
  • 1,804
  • 6
  • 37
  • 53
7
votes
2 answers

iOS create file

I am trying to open a file for writing into it. The file may not exist. I found that [NSFileHandle fileHandleForWritingAtPath:filePath] returns nil if file does not exist. Having googled, I found code snippets like this [[NSData data]…
Nick
  • 3,205
  • 9
  • 57
  • 108
7
votes
4 answers

php create file with given size

How can i create in PHP a file with a given size (no matter the content)? I have to create a file bigger than 1GB. Arround 4-10GB maximum
Mike
  • 965
  • 4
  • 15
  • 24
7
votes
1 answer

CreateFile with the FILE_FLAG_DELETE_ON_CLOSE flag

Before I describe my problem, here is a description of the program (IHExplorer.exe) I'm writting: This is a C++ application. The IHExplorer application is to look as much like a Windows Explorer window as possible. With one exception, and that is…
cchampion
  • 7,607
  • 11
  • 41
  • 51
7
votes
2 answers

How to open the file system of a volume in CreateFile?

The MSDN page on CreateFile says: The string "\\.\C:\" can be used to open the file system of the C: volume. However, the following code always returns an error : ERROR_PATH_NOT_FOUND. HANDLE h = CreateFile(L"\\\\.\\C:\\", FILE_READ_ATTRIBUTES, …
xmllmx
  • 39,765
  • 26
  • 162
  • 323
7
votes
7 answers

Created folder is not visible in the file explorer..

I have a problem with creating a folder and a file on the sdcard. Here's the code: File folder = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString() + "/folder"); boolean success; if…
Tobi Weißhaar
  • 1,617
  • 6
  • 26
  • 35
6
votes
2 answers

MacVim: create new file from command line by using `alias mvim="open -a macvim"`

When I use vim newfilename to open a file and this file does not exit, vim will create a new file with the name newfilename. However, MacVim does not work in this way --- i.e. mvim newfilename (alias mvim="open -a macvim") will lead to an error:…
Liw
  • 377
  • 2
  • 4
  • 12
6
votes
1 answer

C Windows API - close file handle before UnmapViewOfFile

I am wondering if for this code snippet: HANDLE fhandle = CreateFile("something.c", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); HANDLE mapping = CreateFileMapping(fhandle, NULL, PAGE_READONLY, 0, 0,…
Mojo28
  • 335
  • 1
  • 3
  • 9
6
votes
2 answers

Read text file (Unicode) in 'C' using native Win32

I have a line-oriented text file (Unicode) that was created using CreateFile() and WriteFile(). Reading that file as a binary stream using ReadFile() is straightforward, but extra low-level processing is needed to break it into lines. Is there a…
Android Eve
  • 14,864
  • 26
  • 71
  • 96
6
votes
1 answer

What is the memory overhead of opening a file on Windows?

TL;DR How much memory does opening a file take up on a modern Windows system? Some application loads will need to open "a lot" of files. Windows is very capable of opening "a lot" of files, but what is the load of keeping a single file open, so that…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337
6
votes
1 answer

Why is Windows's CreateFile() lying to me?

I'm trying to prevent a third-party DLL in my process from reading a file I've opened, and I've found it to be... well, impossible. No matter what I do, no matter what share flags I specify, their call always seems to succeed! Here is the screenshot…
user541686
  • 205,094
  • 128
  • 528
  • 886
6
votes
2 answers

Can images be read from an iPhone programmatically using CreateFile in Windows?

When an iPhone is connected to a Win7 computer, the images can be viewed using Explorer (and the open file dialog of my app). However, the file location does not contain a drive letter. For example Computer\Apple iPhone\Internal…
Lawrence Barsanti
  • 31,929
  • 10
  • 46
  • 68
1
2
3
31 32