|
Hi,
I am working on a problem has to do with manipulating large files. Essentially, the program will open up any give files and append, insert, and delete data from the file at random position.
What is the most efficient solution?
I have tried memory mapping, but it does not work as expect. Memory mapping works only when the program change a byte in the file. It does not work for inserting and delete bytes from the file at random position.
Thanks,
Kuphryn
|
|
|
|
|
Unfortunately there are no direct API's for inserting into and deleting parts from a file, file mapping is not be advisable because of large files.
Help yourself with constructing new files from the needed parts of your original files/data.
If your files are large compared to the available memory then you should use in a loop small chunks of data (~1MB) at a time in order to avoid unnecessery memory overhead.
Use SetFilePointer to mark the position of current reading/writing operation.
In order to not block the UI, put the whole operation into a worker thread.
Peter Molnar
|
|
|
|
|
|
I'm pretty much a complete newbie to the programming scene. I can't for the life of me work out how to play a wave file. Preferably during the startup of the application but even if it was on the press of a button. I have read about the PlaySound and DirectSound classes/functions (whatever they are) but cannot get them to work. Also i have come across what looks like a really good class (cSound) for download on this website but apparently it doesnt work in Windows XP, and i cant get that to work either. I need to know everything i would need to do (initialisation and all that) coz im completely lost and this is getting very frustrating. even a link to a class i can use or step by step tutorial would be a big help.
o and im using VC++.net
Cheers
jace
|
|
|
|
|
Whether you beleive or not it is really as easy to play a wave file from your app as writing the following:
sndPlaySound("c:\\yourwavetoplay.wav",SND_ASYNC);
Put it into your OnInitDialog override to play it on application startup.
However, in order to use it, you have to add the windows multimedia library to your project
So, BEFORE you call the above line, add to your code:
#include "mmsystem.h"
#pragma comment(lib,"Winmm.lib")
Peter Molnar
|
|
|
|
|
does anyone know the code for a calculator like the one microsoft uses in the accessories file I am interested in how they get the plus and equal buttons to add the values using only one edit box.
thanks JKohm
|
|
|
|
|
They use a spare variable in addition to the display, and also an operation variable (i.e. three variables). By clicking on an operation button (+,-,*,/) the contents of the display are put into the spare variable, and the the button is stored in the operation variable.
The equal sign calculates: spare variable OPERAND display, where OPERAND is the operation variable.
Peter Molnar
|
|
|
|
|
I haved binded the MSHFlexGrid with a recordset, and now I want the result that if I scroll the mouse wheel, the record showed in the MSHFlexGrid would scroll(like the effect as we scroll the mouse wheel while we read a web page,the scrollbar move up or down);I have coded below:
BOOL Class::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
// TODO: Make the mouse wheel take the MSHFlexGrid scroll
this->m_cHFlexGridPerform.SetScrollTrack(true);
//Would u tell me how can I make it work please
return CFormView::OnMouseWheel(nFlags, zDelta, pt);
}
thank you in advance;
|
|
|
|
|
//code
Bitmap *bmp;
bmp=Bitmap::FromHICON(imglist.ExtractIcon(0));
grapics->DrawImage(bmp,x1,y1,x2,y2);
//imagelist is globe variable
Upwards code,Memory leak out,why?
|
|
|
|
|
Bitmap *bmp; is a pointer to a bitmap ... u havnt allocated any memory for the actual bitmap
"there is no spoon" biz stuff about me
|
|
|
|
|
Wrong with imglist.ExtractIcon(0)?
|
|
|
|
|
In MFC for VC++ 6.0, how can I get information about the processor on the current computer such as the name and speed of the processor? How can I find out how much RAM the computer has and how much disk space is available on the primary drive?
|
|
|
|
|
|
Thank you! I can understand how to use those functions but how would I access the data in
HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor ?
|
|
|
|
|
That's just a regular registry key. If you haven't used the registry before, there are many articles here on CP on the registry and wrapper classes for reading it.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
|
I need to get the titles of the history list of a running web browser control.The IE browser can Show the titles of visited web pages in it's drop-down buttons like "Back" and "Forward".How can I do that just like IE?
|
|
|
|
|
You cannot, because the IWebBrowser2 interface does not allow you to do this.
The only thing you can do is navigating the webbrowser to the last or next item:
CComQIPtr<IWebBrowser2> pBrowser(pView->GetHtmlDocument());
pBrowser->GoBack();
pBrowser->GoForward();
If you want the same with IE, then first create an interface IShellWindows, find a connection point to DShellWindowsEvents, after which you enumerate all open shell windows. If the specified shell window supports (i.e. can succesfully be QueryInterface-d for) IWebBrowser2 then you have valid pointer.
Peter Molnar
|
|
|
|
|
i am a collegestudent in China,i does a hard work to learn vc++ well,now I encountered cwindowdc but i have no ideas about it ,please give me some detail device or example ,thanks alot!
besides,i want to know how to learn vc++ very well.
|
|
|
|
|
Hi,
I need to implement Undo/Redo feature in a simple Notepad application. Is this task involve SaveDC() and RestoreDC() APIs??
Note: Solution should only be in Win32 APIs. No MFC please. (It is the requirement.)
|
|
|
|
|
ummmmm think about it for a minute
savedc() etc is dealing with the device context u have drawn into ... ie, a grafics surface in effect
this has NOTHING to do with the text u are displaying which should come from ur document in the doc / view model
when a user makes an edit to the document u need to save the changes to the doc data and be able to restore / remove those changes
"there is no spoon" biz stuff about me
|
|
|
|
|
i need a function the removes a char array from another. here is the description:
textString = new char[ strlen(ptr) + 1 ]
void remove(int startPos, int numToRemove);
// Removes the indicated number of characters from the text,
// starting at the indicated position. This involves allocating
// a new (smaller) array and copying characters from the original
// array into it, not including the ones to be removed.
the remove function removes characters from the array given an int staring position and an into number to remove
for example:
char* textString[] = "I like stinky cheese";
remove(7,7);
cout<<textString;
would yield: "I like cheese"
|
|
|
|
|
We are not here to do your homework. Shows us what you have done so far and then we might be able to help you.
|
|
|
|
|
ive been working on this forever. this is all i came up with:
void text::remove(int startPos, int numToRemove) {
char* temp = new char[strlen(textString) - numToRemove];
for (int i = 0; i <strlen(textString); i++) {
if (i != startPos) {
temp[i] = textString[i];
}
else {
i += (numToRemove -1);
}
}
textString = temp;
}
it doesnt work though. it seems to remove everything after startPos regardless of numToRemove
|
|
|
|
|
nevermind. i got it. this code seems to work:
void text::remove(int startPos, int numToRemove) {
char* temp = new char[strlen(textString) - numToRemove];
for (int i = 0; i <strlen(textString); i++) {
if (i < startPos) {
temp[i] = textString[i];
}
else if (i>startPos) {
temp[i-numToRemove] = textString[i];
}
else {
i += (numToRemove -1);
}
}
textString = temp;
}
|
|
|
|