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
2
votes
2 answers

how do disable disk cache in c# invoke win32 CreateFile api with FILE_FLAG_NO_BUFFERING

everyone,i have a lot of files write to disk per seconds,i want to disable disk cache to improve performance,i google search find a solution:win32 CreateFile method with FILE_FLAG_NO_BUFFERING and How to empty/flush Windows READ disk cache in C#?. i…
springchun
  • 193
  • 3
  • 13
2
votes
2 answers

CreateFile Returns negative handle

Any ideas why the createfile() function would be returning -1. Handle = CreateFile(filename, &H80000000, 0, 0, 3, &H80, 0) This is run a few times. I was thinking perhaps maybe the file is not being closed properly? EDIT Err.LastllError returns 32.
gberg927
  • 1,636
  • 9
  • 38
  • 51
2
votes
2 answers

Create dir with datetime name and subfiles within directory (Python)

I'm currently looking to create a directory on Linux using Python v2.7 with the directory name as the date and time (ie. 27-10-2011 23:00:01). My code for this is below:- import time import os dirfmt = "/root/%4d-%02d-%02d %02d:%02d:%02d" dirname =…
thefragileomen
  • 1,537
  • 8
  • 24
  • 40
2
votes
0 answers

Is there an option to prohibit user from accessing basic file?

I'm currently working on developing some driver. For now connection between kernel and system is done via simple text file created like this: handle=CreateFile(TEXT("\\\\.\\" FILE_NAME), GENERIC_READ | GENERIC_WRITE, 0, NULL, …
szefitoo
  • 99
  • 6
2
votes
4 answers

Windows WriteFile problem when using threads

My company is developing a hardware that needs to communicate with software. To do this, we have made a driver that enables writing to and reading from the hardware. To access the driver, we use the command: HANDLE device = CreateFile(DEVICE_NAME, …
pjaall
  • 379
  • 5
  • 14
2
votes
2 answers

foreign chars in file name on Android

File outputFile = new File(path, clickedKey+".txt"); OutputStream fos = new FileOutputStream(outputFile); fos.write(data.getBytes()); fos.close(); This piece of code works when a path doesn't contain chars like: "ąóźżę" (special characters from…
klimat
  • 24,711
  • 7
  • 63
  • 70
2
votes
2 answers

Reading from a communications resource

I want to read some data from a device connected to a COM port. HANDLE handle =CreateFileW(L"\\\\.\\COM3", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); gives me a valid HANDLE which is then configured via…
Etan
  • 17,014
  • 17
  • 89
  • 148
2
votes
2 answers

How to pass *uint16 pointer to windows.CreateFile() in Golang

I am trying to create a file using windows.CreateFile() function (for reference please see https://godoc.org/golang.org/x/sys/windows#CreateFile and https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew ) in Golang…
Rodrigo
  • 93
  • 1
  • 8
2
votes
1 answer

VB6: CreateFile() creates file with garbled name in current working directory

I was troubleshooting a problem where CreateFile couldn't open an existing named pipe when I found CreateFile() didn't work well with the filename parameter. My code is: Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileW" (…
Charlie
  • 764
  • 2
  • 13
  • 24
2
votes
3 answers

Opening %SystemRoot%\system32\calc.exe from a 32-bit process redirects to another file. Which, why and how?

I'm currently writing some test code in C++ that messes around with PE files to understand its file format structure. My project is set to compile to 64 bit. In my code I open %SystemRoot%\system32\calc.exe and read the IMAGE_DOS_HEADER and…
Jehjoa
  • 551
  • 8
  • 23
2
votes
4 answers

How can I write to a file and remove the file afterwards in C#?

I need to create a file, write one line of text in the file and then delete the file and estimate how long it will take to do it. Unfortunately, I am running in couple of problems, first I cannot write in the file, it succesfully creates it but…
grozdeto
  • 1,201
  • 1
  • 13
  • 34
2
votes
1 answer

SharePoint through Web Client Service (webclnt.dll). CreateFile fails

I have an application that creates and edits documents. I need to integrate it with SharePoint, so that users can edit files on SharePoint servers using my application. My environment is Visual C++, non-MFC Windows application. I'm trying out the…
Steve
  • 1,065
  • 15
  • 34
2
votes
0 answers

Cannot read raw sector from SD card, ReadFile() fails with error 87

I've got to read raw data from an SD card with no filesystem. This data is created by an embedded system. My code used to work, but at some point in time it stopped working and now ReadFile() fails with error 87 (ERROR_INVALID_PARAMETER) which is…
François
  • 171
  • 2
  • 10
2
votes
2 answers

C++ CreateFile and fopen functions preemptively reading entire remote file

While doing performance analysis on some source code, I noticed both CreateFile and fopen to be taking an unusually long time to complete on remote files. Digging in further with wireshark, I discovered that when either of the two functions are…
2
votes
2 answers

Creating separate files

I am looking for a way to create separate files. For example: I have an application which has a form such as name, date etc. and when I press save, I want to save all the information in that form of the user into a file. Each time the form is filled…
Aneesa
  • 123
  • 3
  • 10