createfile

USB VCP connection fails occasionally

女生的网名这么多〃 提交于 2019-12-11 15:52:24
问题 My question is quite simple: I operate 20 CP210x (Silicon Lab) devices over an industrial 20 Port USB Hub. In one of about 1000 trials to open the port I get a problem: The call to CreateFile(portName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); is blocking and doesn't return. In this case it doesn't help to repeat or to restart my software. Only plugging out/in the device helps. Of course the port name is including backslashes, as required for higher COM Port numbers. The

How do I write to a file in php?

☆樱花仙子☆ 提交于 2019-12-11 14:12:15
问题 I am getting the source of a page as follows: <? $txt = file_get_contents('http://stats.pingdom.com/file'); echo $txt; ?> and printing it on the screen but to be honest I actually want to replace an existing html file with it every 1 min. (I will be opening the file every 1 min.) How could I do this? 回答1: If you've learned to use file_get_contents() then consider his sister function file_put_contents() $txt = file_get_contents('http://stats.pingdom.com/file'); file_put_contents('/path/to/my

How would I create a text file in Delphi

与世无争的帅哥 提交于 2019-12-11 10:06:40
问题 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 other function? 回答1: Maybe you can create a stringlist and save that to file: procedure MakeAStringlistAndSaveThat; var MyText: TStringlist; begin MyText:= TStringlist.create; try MyText.Add('line 1'); MyText.Add('line 2'); MyText.SaveToFile('c:

CreateFile ,ReadDirectoryChanges issue

纵饮孤独 提交于 2019-12-11 05:56:23
问题 I’m using ReadDirectoryChangesW to spy a folder that I opened with CreateFile , once a file was added I call a function ( OnFileChanged ) that read the size and open it for reading, my application works fine for small sized file but the problem occurs when I try to copy a big file into my folder(7,24 M), and I get Permission denied error after calling fopen to read it. the watching process is based on this void Init(const QString FullPath) { ... hDir = CreateFile( dirPath, // pointer to the

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

余生长醉 提交于 2019-12-11 01:33:00
问题 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 write a little of code to test whether can worked: const int FILE_FLAG_NO_BUFFERING = unchecked((int)0x20000000); [DllImport("KERNEL32", SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)] static extern SafeFileHandle CreateFile(

atomic file creation on Linux?

て烟熏妆下的殇ゞ 提交于 2019-12-10 10:44:22
问题 I need to create a file if it does not exist, in a way that another process trying to create this file would fail. I need the file be considered "created" even before the creating process finished writing the actual data to it. I read about O_EXCL flag to open() , so it seems that the solution exists, I have a few questions however: do you have experience with this technique? How good is it? (I guess I can't have a DB-level atomicity, but but good enough is... well, enough) should I

Windows: How to intercept Win32 disk I/O API

纵然是瞬间 提交于 2019-12-10 10:24:36
问题 On Windows, all disk I/O ultimately happens via Win32 API calls like CreateFile , SetFilePointer , etc. Now, is it possible to intercept these disk I/O Win32 calls and hook in your own code, at run time, for all dynamically-linked Windows applications? That is, applications that get their CreateFile functionality via a Windows DLL instead of a static, C library. Some constraints that I have are: No source code: I won't have the source code for the processes I'd like to intercept. Thread

MS Detours Express 3.0 is not hooking CreateFile win32 API function properly

懵懂的女人 提交于 2019-12-08 12:37:11
问题 I am trying to hook win32 API function "CreateFile" using MS Detours, but when I test it by opening a *.doc file using MS Word, The CreateFile call for DLLs and font files and directories loaded by MS Word are redirected to my detoured function but not for that *.doc file, but when I open a *.txt file using notepad the CreateFile call for that *.txt file comes to my detoured function. I am using following code for hooking CreateFile: static HANDLE (WINAPI *Real_CreateFile)(LPCWSTR lpFileName,

Open Directory Using CreateFile

*爱你&永不变心* 提交于 2019-12-07 16:40:47
问题 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, FILE_FLAG_BACKUP_SEMANTICS, IntPtr.Zero); This is the call being made, and as noted in the documentation the 'FILE_FLAG_BACKUP_SEMANTICS' is being used. The DLL import seems to be working fine and looks like the following: [DllImport("kernel32.dll",

atomic file creation on Linux?

丶灬走出姿态 提交于 2019-12-06 04:27:34
I need to create a file if it does not exist, in a way that another process trying to create this file would fail. I need the file be considered "created" even before the creating process finished writing the actual data to it. I read about O_EXCL flag to open() , so it seems that the solution exists, I have a few questions however: do you have experience with this technique? How good is it? (I guess I can't have a DB-level atomicity, but but good enough is... well, enough) should I immediately close the file after open() so that it is considered created, and then reopen it for writing? are