|
Hi,
I want to know how to invalidate (close) all open file handles for a particular drive,
opened by any process. How can I do it? I had read about this in MSDN or on internet
few months ago, but don't remember how to do it.
Please help me out.
|
|
|
|
|
There is an application called 'TaskManager Extension' which is opensource article downloadable from CodeProject. You may like to check out this since it is able to find all the handles of the process. It is most likely that you would be able to implement the same trick in your application also.
|
|
|
|
|
Hello All
Is there a way to do disk partitioning functions using C/C++.. such as resize a partition, create a new one etc.. I dont care how long and complicated it is! :p
Thanks for your help!
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
If I wanted to do that I'd probably hit Google for the Gnome Partition Editor and see if the source is downloadable anywhere. It's the business when it comes to playing roulette with partition tables and it's free
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thank you, Matthew I will look at that (y)
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
Hi,
I have a project I'm working on using GLUT, openGL and a few libraries. Now I'm trying to add sockets to it and whenever I include winsock2.h (haven't even written any relevant code) syntax error : ',' at some line which is meaningless appears. The code compiles and runs if I don't include winsock2.h
I'm using VC++ 2005. I have ws2_32.lib set up to link. I'm not including windows.h, MFC support. I just can't figure out what's wrong. Example code for winsock compiles and works.
As an aside can anyone point to a cross platform sockets library? I think GTK has one but it's way too big.
|
|
|
|
|
Found the problem, I called one of my variables "far" which turns out to be #defined somewhere
Still open to suggestions on portable socket library. I just don't want to mess around with it.
|
|
|
|
|
I expect you probably need to include windows.h before winsock2.h.
If you're looking for a cross platform sockets library I'd start with BSD sockets, probably in netBSD these days. It's where Microsoft started when they needed to 'source' a socket implementation for Win95 or so the rumour goes.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
No, in fact you need to include winsock2.h before windows.h because windows.h includes old winsock.h which interferes with the new one. Also winsock2.h may include windows.h anyway on line:
#ifndef _INC_WINDOWS
#include <windows.h>
#endif
I will check out the BSD sockets thing...thanks.
|
|
|
|
|
You're right, I'd forgotten about that particular peculiarity. One of my first tasks in paid software development was to change a project from winsock to winsock2. Amazing how quickly I forget things
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
I spent way too much time on this problem, that's why I know
|
|
|
|
|
I'm working on an application that captures uncompressed video from 2 high resolution (1024x768) video cameras at 30 fps. In order to stream to the hard drive without dropping frames, I need to maintain an average transfer rate of ~47 megabytes per second. The drives I am using are rated to be able to handled a sustained write of 75 megabytes per second all the way to the end.
However, simply writing data with fwrite and timing the performance, I am coming no where near the necessary level of performance.
If anyone out there has any experience with high performance file writing, I'd love to get some tips/pointers on ways to increase write speed.
Adam Kraver
www.captivemotion.com
|
|
|
|
|
I believe the way to get the fastest file throughput is to use Overlapped I/O along with the NO_BUFFERING flag when the file is created/opened with CreateFile(...) . There are some gotchas with buffer size and alignment, but if you are good enough to be streaming real-time video, it is likely nothing that you cannot handle!
Also, just because your drive can go that fast does not mean that your system can. Other factors (the drive controller being used, any hardware caching, what other stuff your system is doing).
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Yes, James is correct.. If you are using a SATA disk, it can transfer up to 150MB of data/sec, and a SATA II disk will do up to 300MB of data/sec so you have to be careful with this.. if it is an ATA disk, then you're looking at up to 133MB of data/sec.. FireWire external HDDs can transfer up 800MB of data/sec..
Bearing these in mind also note that Windows schedules other tasks and so it uses the disk(s) for these aswell so writing to a "non-Windows" disk (i.e. a disk which doesnt have the running Windows on it) and a disk which is also not being accessed will improve data-transfer rate.. Also check your motherboard FSB.. this will also affect the speed of data transfer to and from the hard disks..
Hope this helps!
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
James, thanks for the hint! So far, using CreateFile and WriteFile with NO_BUFFERING, I'm getting the performance I was expecting (and so far, the performance that it looks like I need).
Of course, I'm testing this in a small test app, so I'm not sure what the final results will be in the capture app, but the results are quite promising.
|
|
|
|
|
Programatically you can acheive this by implementing multithreading. Put the code of writing to disk in separate thread.
Regards,
Paresh.
|
|
|
|
|
Before using CreateFile and WriteFile, I had done that, but unfortunately, the performance of fwrite couldn't keep up with my transfer needs (it runs about 1/2 to 1/4 the speed of WriteFile when using unbuffered writes, even when there is no other real load on the CPU).
|
|
|
|
|
I am having trouble converting from a unicode string to a single-byte string. Our application is a C++ COM server that is called from a .NET client. The COM object needs to be able to convert the strings it receives from Unicode to single-byte. To do this, I wrote this function:
CString ConvertBSTRToString(BSTR bstrSrc)
{
CString strDest = "";
char* szDest = NULL;
int nSrcLen = 0;
int nDestLen = 0;
nSrcLen = lstrlenW(bstrSrc);
if (nSrcLen > 0)
{
int nCodePage = GetACP();
nDestLen = WideCharToMultiByte(nCodePage, 0, bstrSrc, nSrcLen, NULL, 0, NULL, NULL);
if (nDestLen > 0)
{
szDest = (char*)HeapAlloc(GetProcessHeap(), 0, nDestLen + 1);
WideCharToMultiByte(nCodePage, 0, bstrSrc, nSrcLen, szDest, nDestLen, NULL, NULL);
szDest[nDestLen] = '\0';
strDest = szDest;
HeapFree(GetProcessHeap(), 0, szDest);
}
}
return strDest;
}
I initially tested this function on my system, which is setup with the Latin 1 code page (1252). I also setup my machine to allow for Russian input (1251). To test, I changed the above function to hard-code the code page to 1251 (instead of the GetACP() call). When I pass a string from the .NET client to the COM object, it performs the conversion to single-byte correctly. Of course the converted string does not look like the original Russian string since the code page running on my machine is 1252, but comparing the 1251 and 1252 code page shows that the characters in the string have the correct value.
The problem comes in when I try to test the COM object on a Russian OS. When I do this the call to WideCharToMultiByte simply returns "?????". I assume the "?" is the default character the routine uses when it cannot perform the conversion correctly. I don't understand why this conversion fails? I verified that the code page being returned by GetACP() on the Russian system is 1251.
I also did another test where I hard-coded the code page used in the conversion to be ISO 8859-5 (28595) on the Russian system. The conversion here was successful. I don't understand why the conversion would work for this Cyrillic code page, but not the Cyrillic code page that is the active code page on the system.
Thanks for any advice. I know there is something I'm just not understanding about how this works.
|
|
|
|
|
if you're using ATL there is a much simpler way!
look for "ATL 7.0 String Conversion Classes and Macros" in msdn
Yours Truly, The One and Only!
|
|
|
|
|
I want launch another application, like notepad.exe or xxx.bat, in my VC application. I knew there is API can do it. but after searching on Web I could not find it. Please tell me what API is it.
Thank you.
Richard
|
|
|
|
|
One way is to use CreateProcess()[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Thanks,I overlooked the docs."
|
|
|
|
|
or ShellExecute() or _spawn().
|
|
|
|
|
Yeah - I chose the first link I saw that had info on running both exes and batch files
Cheers,
MArk
Mark Salsbery
Microsoft MVP - Visual C++
"Thanks,I overlooked the docs."
|
|
|
|
|
|
This link is pretty helpful. thank for all your guys' answer.
|
|
|
|