I am using ShFileOperation to copy files to an SD card and it is working fine, almost!
I have some large files, 5GB and greater. When the SD card is empty this all progresses fine. But, when I am updating the files on the SD c ard, ShFileOperation will check remaining disk size and if the file is larger than free-space it will show a "No room" dialog and abort.
The problem arises when the file will be overwriting an existing one and is probably only 3MB or 4MB larger with new stuff. The ShFileOperation does not first check if the destination file exists before checking for disk space.
I have checked all available Flags on the MSDN site and the only one I can find is FOF_NOERRORUI but that is a little too brutal and totalitarian for me. Killing off all error messages just to overcome one problem.
Is there any way I can get ShFileOperation to not do that disk-space check, but still declare serious errors if they occur?
Thanks.
Is there any way I can get ShFileOperation to not do that disk-space check, but still declare serious errors if they occur?
You can use FOF_NOERRORUI to suppress the error UI. Which is indeed exactly what you want. But then you need to provide UI for any errors, since you asked the system not to. That flag essentially means, "let me take charge of reporting errors."
In this situation, I would suggest using CopyFileEx() for each file, utilizing its progress callback to update your own progress dialog as needed.
Related
I recently tried to host a little web interface from my ESP8266. But something kept failing until I realized that a bigger file (around 10kb) was corrupt. Well, not really corrupt, but simply incomplete. And no matter how I changed it, the file was always cut off after a certain amount of characters.
My compiled NodeMCU firmware is about 649kb in size, so there should easily be enough space. I mean my board has at least 4MB of storage (32m), so that should be plenty to store my lua, html and css files!
I used Esplorer to upload the files btw.
So what exactly is the limit here?
Is it a memory issue? A flash storage issue? An issue related to Esplorer?
Is it somehow possible to get bigger files onto my board?
edit:
I should mention that uploading the init.lua file always worked even if it was around 10kb. Maybe the uploading mechanism is different for the init.lua file?
Alright, here's the long form of my comment above. My best guess is (was) that this be an issue with ESPlorer. Whenever I look at its source code I'm actually surprized how well it usually works.
At https://frightanic.com/iot/tools-ides-nodemcu/ I compiled a list of tools and IDEs for NodeMCU. I suggest you pick a different uploader and try again. The NodeMCU-Tool for example is solid and it's definitely a lot better maintained than ESPlorer is.
How can I uses commands to check that the size of new file is significantly smaller than the one it's replacing?
I have a batch file running every night which, amongst other things, calls an application UpdVMem.exe which creates a cut down members database VMembers.Adt from the main file Members.Adt. This file is then moved to remotes sites with the same script.
On a few sites, at periodic intervals the VMembers.Adt will be corrupted. I have no idea why, as we've ruled out the table being locked for editing (by my Delphi Membership software). It will be often deceptively appear the same size but contains less than half the records.
Even better would be a set of commands which could detect this corruption or a failure in the execution of UpdVMem.exe, as the size alone is not the best indicator.
Thanks
You can use the ERRORLEVEL command to check the exit code of UpdVMem.exe in batch file. If the UpdVMem.exe is developed by you then you can use the Halt procedure to send "meaningful error codes" to the batch file (ie when you catch some exception when creating the VMembers.Adt file).
I have a project in Delphi7. Its is rather large consisting of 40 odd forms and frames.
Recently, the compiler only allows me to compile the project once so i can run it, then every re-compile the IDE hangs and i have to end the Delphi process. Before this occurs, my CPU goes to 50% (on dual core machine) so my deduction is the compilation process has gone into an infinite loop. The Executable it produces is not runnable and usually at a fixed size after it hangs.
I was wondering how i can go about finding where this inconsistency in my project is. Other projects do not suffer from this same issue.
You can use Process Explorer to discover what compiler is doing (reading a file, or ...).
Check the QC 3807 issue.
Check the system resources - free disk space, memory. Clean the temp folder. Check the disk for errors. Do you have antivirus running ? If yes, then try to turn it off.
Use "process of elimination", to see if it's something in your code.
First, make a backup of where you are, or save to your CVS (you ARE using version control, right? RIGHT? good.) Revert your branch to an earlier version where it worked. See if that works. If so, merge half of the changes from the present-day version. If that works, try the other half. Keep cutting things in half, and you'll find the code that causes the problem, by process of elimination.
Or, it may turn out to be something in the configuration. Carbonite may be your friend here.
You can either:
Enable "Compilation progress display" in the "Environment Options" window, in the "Preferences" tab.
Use the command line compiler bcc32.exe to have a detailed console output.
Both will let you know which file is hanging the compiler.
Take a look at the great Delphi Speed Up tool, which allows e.g. to abort CodeCompletion and HelpInsight by ESC/mouse move.
I want to dump a process image on the disk and then execute it
i listed the process modules
i used readprocessmemory to read the memory range of the exe
but when i try to execute it fails.how can i solve this?
thanks
You can't.
When you load a PE into memory, (I assume you're using MapAndLoad from ImageHlp.pas,) it loads the modules into memory and loads the data, but it doesn't go through and realign all the pointers the way the standard Windows Loader does.
The pointers in the app are all going to be relative addresses that don't actually point to what they're supposed to point to.
If you know enough about how RVAs and mappings work, you can analyze the code, but you can't actually execute it.
I'm using Delphi 2007. Sometimes properties linking to components get lost. This is typically Action properties and lookupdatasets. I have a few times had some emergency bug fixes and sent out a version to customers with a somewhat catastrophic result due to this :-)
Anyone know a way to verify that properties that are supposed to be set really are set, or a way to prevent this from happening?
You can assign such values in code, obviously.
More importantly though, you have to diff every file before committing to sourcecontrol. Always.
Make sure your dfm-files is text, not binary. Then it will be easy to see unwanted changes before check-in/commit.
Diffing everything have stopped a lot of potential blunders for me.
An automatic build and test-system would also give you some confidence in what you deliver.
You've received several good answers about how to detect when this does happen (up voted). But one way to prevent it from happening (sometimes) is to make sure that you have added all of the referenced units to your DPR. If you open a form, for example, which contains components that reference other components on a data module, and that data module has not been added to the DPR/project, you're almost guaranteed to have the IDE remove those references, because it removes references which it cannot determine are valid. If, on the other hand, the data module is in the DPR, then the IDE will be able to find it, and it is less likely to remove the references in the first place
Unfortunately, it still happens from time to time, so you still need to take the precautionary measures detailed in the other answers. But this will make things better, if you don't already do this.
Create dunit test project.
Run test before release.
Sound all bells when test fails.
You want a way to verify if the values are set correctly. Well, you can use unit tests for this. Just initiate a form, compare the properties and done.
Comparing the dfm's is also a good way ofcourse but it does not take into account changes due to changed defaults or changes in the code.
When you add a form, data module or frame to a project, the IDE inserts a little comment "tag" after the unit name in the dpr file. It has been my experience that if for any reason this tag is not present, the IDE is more prone to losing cross-module component references.
I wholeheartedly support the idea of always viewing differences before each commit to version control, if you are using such as thing.
I hate to say this but Source Code Control can help in these situations. Even with an emergency bug fix you should be checking everything into a source code repository (Perforce is my personal favorite). In a small fix you could see by what files have changed whether you have any changes you are not expecting.