createfile

CreateFile fails on opening fs driver

Hello, i'm trying to communicate with my filesystem driver. I can start the driver with OpenSCManager, CreateService and OpenService but when i'm trying to use "CreateFile", it always says Errorcode 2 (I think it's file not found etc.). This is the whole code: using System; using System.Diagnostics; using System.Collections; using Syst...

Is it possible to change HANDLE that has been opened for synchronous I/O to be opened for asynchronous I/O during its lifetime?

Dear all, Most of my daily programming work in Windows is nowadays around I/O operations of all kind (pipes, consoles, files, sockets, ...). I am well aware of different methods of reading and writing from/to different kinds of handles (Synchronous, asynchronous waiting for completion on events, waiting on file HANDLEs, I/O completion p...

Implementing a virtual file by overriding Win32 File API

Is there any way to override Win32 File API such as CreateFile()? I want my app to see a virtual file solely for my app, however, the virtual file does not exist actually. ...

How to obtain the first cluster of the directory's data in FAT using C# (or at least C++) and Win32API?

So I have a FAT drive, lets say H: and a directory 'work' (full path 'H:\work'). I need to get the NUMBER of the first cluster of that directory. The number of the first cluster is 2-bytes value, that is stored in the 26th and 27th bytes of the folder enty (wich is 32 bytes). Lets say I am doing it with file, NOT a directory. I can use...

calling CreateFile, specifying FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE.

Before I describe my problem, here is a description of the program I'm writting: This is a C++ application. The purpose of my program is to create file on RAM memory. I read that if specify FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE when creating file it will be loaded direct to the RAM memory. One of blogs that talk about ...

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 crashes). After that all calls to CreateFile fail (ERROR_ACCESS_DENIED), and the only solu...

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? ...

How to create an sql script file in TFS 2008 at designated directory automatically for developers to add sql script?

Hi all, I have just revised my question. Actually i wan to create an empty txt/.sql file in TFS 2008 Source Control server at designated directory/folder where developers can add sql script for their part of development. I need this file to be created automatically each time our nightly build script runs. I have created directories or...

Cocoa Createfileapath

hello, I am trying to create a file on mac os. the data from the file will be accessed by the app. but how to create a file having read permission on all accounts. Currently the app can read data in admin account only. I am using following syntax: BOOL B = [fm createFileAtPath:p1 contents:data attributes:nil]; is it something to do w...

php create file with given size

Hello, How can i create in PHP a file with a given size (no matter the content) Mike I have to create a file bigger than 1GB. Arround 4-10GB maximum ...

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 Win32 function that does this for me? Again, please note that it's in 'C' (not C++) and I ...

Opening a handle to flash drive gives me an "Access Denied" error code

Hello, I would like to know why when I try to create a handle to a USB flash drive, I receive a path not found error. HANDLE aFile = CreateFile(_T("\\\\.\\F:\\"), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (aFile == INVALID_HANDLE_VALUE) { printf("\n"); printf("Bad handle val...

WriteFile() call works on x86, but not x64. Getting error code 6 -- The handle is invalid using VB.NET

I am using CreateFile, WriteFile and ReadFile API calls to write some data to a USB device. The code I have works perfectly on 32 bit systems. CreateFile gets a handle to the device, pass that handle and some data to WriteFile and read from that handle with ReadFile. My problem is, the same code does not work on a 64 bit system. The err...

C# Disk Seek/Position Change Lag using CreateFile Function

I'm currently using the CreateFile function to read a disk using a BinaryReader, and it seems as though whenever I seek or change the position of my stream, it can take anywhere from 200 milliseconds to 900 milliseconds. The code is basically exactly what you'd think it would be... for (int i = 0; i < f.BlocksOccupied.Length - 1; i++) ...

Converting a string to LPCWSTR for CreateFile() to address a serial port

I seem to be having a bit of a TEXT / UNICODE problem when using the windows CreateFile function for addressing a serial port. Can someone please help point out my error? I'm writing a Win32 console application in VC++ using VS 2008. I can create a handle to address the serial port like this: #include <iostream> #include <windows...

Create a new file and write text in Javascript

Hello, I have a website on my own Windows Server 2008 R2. On it a user can write a text on a textarea, hit "Create file" and then: function myFunction() { var s=""; var dict = {}; var data = (s + "").split(""); [...] // More Javascript stuff here } There is a default file on my server called default.js which content ...