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
4
votes
3 answers

Objective-C. Create file at path which doesn't exist?

For example if I want to write file.txt into /folder1/folder2/folder3/ and noone of folders exists. Is it the only way to create them manually?
user2083364
  • 744
  • 1
  • 7
  • 20
4
votes
2 answers

CreateFile in Kernel32.dll returns an invalid handle

I'm trying to create a safe file handle for "C:" using the CreateFile method of kernel32.dll which always returns me an invalid handle. Any help on what am i doing wrong here?"C: CreateFile( lpFileName: "C:", dwDesiredAccess:…
4
votes
1 answer

Can CreateFile() Open one file at the same time in two different thread

Can CreateFile() Open one file at the same time in two different thread void new_function(void * what) { HANDLE h = CreateFile("c:\\tmp", GENERIC_ALL,FILE_SHARE_WRITE | FILE_SHARE_READ , NULL, OPEN_EXISTING,…
StevenWang
  • 3,625
  • 4
  • 30
  • 40
4
votes
1 answer

'Access is denied' error when calling CreateFile from a UMDF driver (C++)

I am creating a UMDF driver which needs to change the brightness of the LCD back light. The following line of code works in a Console App and successfully returns a handle to the device: HANDLE hDevice = CreateFile(L"\\\\.\\LCD", GENERIC_READ |…
Simon
  • 41
  • 1
  • 2
4
votes
2 answers

Open Directory Using CreateFile

I am trying to utilize the CreateFile function to access directory information. I am recieving a win32 error code of 5 however, which means Access Denied. Please advise. CreateFile(path, GENERIC_READ, FILE_SHARE_READ, IntPtr.Zero, OPEN_EXISTING,…
Trent Seed
  • 344
  • 5
  • 16
3
votes
4 answers

Device simulation on COM port

I have a device that sends data to COM port. And I'd like to simulate this device when it's not plugged in. I thought that this can be accomplished by simply sending data to a specific COM port: int main() { char *port = "\\\\.\\COM40"; …
AlexP
  • 1,416
  • 1
  • 19
  • 26
3
votes
1 answer

What is the purpose of CopyFileEx's COPY_FILE_OPEN_SOURCE_FOR_WRITE?

Win32 CopyFileEx and CopyFile2 both have an option flag COPY_FILE_OPEN_SOURCE_FOR_WRITE where the docs state: COPY_FILE_OPEN_SOURCE_FOR_WRITE 0x00000004 The file is copied and the original file is opened for write access. Now, this sounds…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337
3
votes
1 answer

How to set filename for zwcreatefile function?

Suppose I want to open file c:/test.txt That's how I do it at the moment, and it does not work: RtlInitUnicodeString(&uniName, L"\\SystemRoot\\test.txt"); // InitializeObjectAttributes(&obj_atr, &uniName, OBJ_CASE_INSENSITIVE /*|…
szefitoo
  • 99
  • 6
3
votes
1 answer

CreateFile Hook

I am trying to Create a Hook for CreateFile, so when a process tryies to create a file the hookdll we created will notify the user that: "this process xx.exe trying to create xx.exe, Do you want to proceceed?" So far i am here, So What i need to…
Ismail Dz
  • 67
  • 1
  • 10
3
votes
7 answers

How to FTP constantly incoming files

Ok, here's the situation... I have an application that generates about 8 files per second. Each file is 19-24kb. This generates about 10 to 11 MB per minute. This question is not about how to ftp, because I have that solution already... The…
Dave_P
  • 174
  • 2
  • 16
3
votes
1 answer

CreateFile always returns error 5 (Access is denied) when trying to open directory for reading

I want to open directory handle so that I can watch that directory for file changes. I have written a simple class wrapper over the winapi, and this is how I set the directory path before starting the watch: bool SetDirectory(const std::string&…
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
3
votes
1 answer

Open FILE* using CreateFile

Is there a way to create stdio's FILE* structure on the basis of a handle returned by WinAPI's CreateFile in C++?
Serge Rogatch
  • 13,865
  • 7
  • 86
  • 158
3
votes
3 answers

How would I create a text file in Delphi

I have a program where users register for my program and a text file is created for them. I have tried using the CreateFile function but am not sure on the parameters. How would I create a textfile for each user as they register using this, or any…
joel_kruger
  • 115
  • 2
  • 3
  • 6
3
votes
6 answers

Adding timestamp and custom name to a File uploaded via PHP

I was looking for a way to add a timestamp and a custom name to a file uploaded to my server via php. I does some readings on $_FILE[] to understand its arguments, but the official PHP docs give no detailed explanation. This is the code I use to…
Edmond Tamas
  • 3,148
  • 9
  • 44
  • 89
3
votes
6 answers

Reopening serial port fails if not closed properly with CloseHandle

I am working with USB device on Windows that is seen as a virtual serial port. I can communicate with the device using CreateFile and ReadFile functions, but in some cases my application does not call CloseHandle (when my application in development…
superg
  • 379
  • 1
  • 6
  • 19