|
resolution:
READ from whatever starting pointing from your file, save to buffer, then add whatever character you want at the beginning of the buffer. then WRITE the buffer to your file, this way you can insert...
cfile_object.Seek( insIndex, CFile::begin );
int flen = cfile_object.GetLength();
char *fBuf= new char[flen];
UINT file = cfile_object.Read(fBuf,flen);
fBuf[file] = '\0';
txtInsert = txtInsert + fBuf;
cfile_object.Seek( insIndex, CFile::begin );
cfile_object.Write(txtInsert, szSize + file);
cfile_object.Close();
modified on Tuesday, September 28, 2010 2:53 AM
|
|
|
|
|
As I explained in my previous answer there is no 'insert' facility in file I/O, it has to be implemented by reading the data into memory, modifying the memory buffer(s) and rewriting all of the file from the point of insertion.
The line
fBuf[file] = '\0';
will cause random memory corruption.
I am not sure what the line
txtInsert = txtInsert + fBuf;
is supposed to do, but I doubt that it is what you expect.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Well i have to agree with everything that you have written, i am totally new in visual C++... unlike the .NET that i came from, coding is more easier there, but MFC just gives me what i needed, MFC gives me "CONTROL OVER MY CODE"
i am very thankful about your comments, i got a good hint how to control my Project...
thanks a lot for posting,.
the bigger problem that i face now is how to SORT the record on the CFile., i needed real time sorting for my main project.. every-time a user input is made, the record should be automatically sorted A-Z..
how to sort:
BANANA
APPLE
ORANGE
MANGO
PINEAPPLE
and i got NO idea how to do that, any help would be very much appreciated
|
|
|
|
|
loid grey manuel wrote: i got NO idea how to do that
Well, this is the place we all had to start from, but it does require you to spend some time learning. If you are serious about writing C++ programs then you should learn some of the features that come with it, such as the Standard C++ Library[^]. There are also lots of useful classes in MFC if you are using those libraries; Here[^] is an article that should help you with your sorting problem. In either (or both) case(s) you should get familiar with the MSDN[^] site to help you find answers to many of the problems you will meet on the way.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I am calling HttpOpenRequest API in BHO code. Which is works correctly in
IE6,IE7 and IE8. But HttpOpenRequest failed on IE9.
I am calling it as
d_hHTTPRequest=::HttpOpenRequest(d_hHTTPConnection,
"GET", // HTTP Verb
a_szURI, // Object Name
"HTTP/1.0", // Version
"", // Reference
&szAcceptType, // Accept Type
dwFlag,
0); // context call-back point
Is there any change required for IE9 while using HttpOpenRequest API.
|
|
|
|
|
you might find you get a better result if you explains this
am 2009 wrote: But HttpOpenRequest failed on IE9
a bit more - what was the failure/how did it manifest itself (etc) ... oh, and, please put code inbetween the correct tags to make it more readable - <pre> </pre> or simply use 'code block' from the message editor
'g'
|
|
|
|
|
I am calling win32 HttpOpenRequest API in my ATL COM code. It failed when called HttpOpenRequest. This is ATL COM win32 windows application hence there is not any refereence of
and
tag.
|
|
|
|
|
am 2009 wrote: This is ATL COM win32 windows application hence there is not any refereence of
I meant, when you post code on this forum for others to read, put it in the correct tags
am 2009 wrote: It failed when called HttpOpenRequest
so you have said - you still have not answered what error code it fails with - so no one here can help you since they cannot guess what is happening
'g'
|
|
|
|
|
d_hHTTPRequest=::HttpOpenRequest(d_hHTTPConnection,"GET",a_szURI,HTTP_VERSION ," ",&szAcceptType,dwFlag,0);
Above code is failed in IE9
|
|
|
|
|
you keep missing this VERY IMPORTANT POINT
WHAT DID THE CODE FAIL WITH ?
WHAT WAS THE ERROR CODE ??
|
|
|
|
|
Hi,
Actually i HttpOpenRequest() function failed, i,e. application crash,hence
GetLastError() not called. Before caliing GetLastError() code crash. This is happened with only IE9. otherwise code runs correctly on IE7 and IE8.
|
|
|
|
|
Anyone holds info about native
c++ implementation of delegates
in the upcoming C++0x standard ?
just curious...
|
|
|
|
|
|
Actually, my question stems from some articles
published in codeproject about "fast" c++ delegates
and the innards of pointers to member functions
(i.e. methods).
A functor is probably not resembling this. The most
significant contribution is Boost.Function and Signals.
As there has been significant discussion of the
memory usage of Boost.Function and how to improve it,
I was curious about the standard, as many parts
of boost are under review to be included in the
standard.
Cheers
|
|
|
|
|
I'm writing a plug-in for an NLE, and I wish to forcibly resize my window to fill the area that is available. The PlugInPP class is defined as such:
class ATL_NO_VTABLE CPluginPP :
public CComObjectRootEx<CComMultiThreadModel>,
public CComCoClass<CPluginPP, &CLSID_PluginPP>,
public IPropertyPageImpl<CPluginPP>,
public CDialogImpl<CPluginPP>
In order to get the sizing messages for the parent window, I have sub-classed it, and when I see a WM_SIZE message, I do the following:
::MoveWindow( Main_zMappingArray[ 0 ].hDialogWnd,
0,
0,
LOWORD( lParam ),
HIWORD( lParam ),
TRUE );
My PlugInPP::OnSize method gets called with the new size, no problem there. However, there is immediately another WM_SIZE message setting back the original sizes or the dialog resource.
I'm beginning to think that the silly buggers have subclassed the PlugInPP window and resize it whenever they see a WM_SIZE message, but that seems like an awful lot of work to do in a situation where the window is by no means resize-able.
Give the ATL::CDialogIMpl and ATL::IPropertyPageImpl base classes, I'm wondering if there's a trick to resizing them, or a trick to preventing them from being resized that I can opt out of.
Otherwise, I guess I'm stuck with subclassing my own window again, and just eating the WM_SIZE messages, and hope that works.
CraigL
|
|
|
|
|
Hoping someone can still provide some help here, this is some update on what I've been finding; but one Q at a time so it doesn't seem so haphazard.
When I subclass the propertypage/dialog, the previous proc address I get is an address well within the range that the Modules tab in VSW shows me user32.dll was loaded, so from that I can be fairly certain that the containing application is NOT subclassing it and simply re-initiating a MoveWindow whenever it sees a specific message.
Is this correct? Or if it is not a safe assumption, any pointers on where/how to figure out who all is busy subclassing and 'walk the tree'?
Thanks,
CraigL
|
|
|
|
|
Well, I did finally manage to figure it out. The containing app was moving it, but using the IPropertyPageImpl::Move method. Why they didn't see fit to call it MoveWindow like every other single thing in windows, is beyond me.
If I'd been able to figure out how to configure a breakpoint for whenever my DLL was entered, I'd have found it in no time.
CraigL
|
|
|
|
|
Craig Longman wrote: If I'd been able to figure out how to configure a breakpoint for whenever my DLL was entered, I'd have found it in no time.
Well, you can temporarily insert DebugBreak() into the code next time...
|
|
|
|
|
Thanks, but that actually wouldn't have helped. The point was I didn't know where the host app was calling in. So, short of adding in a call like that to every method, as well as every method of every base class, there was no solution that I could program in.
Breaking on MyDLL.dll!* is pretty much the only solution. Even the Class::* didn't work, as the parser failed to find some of the templatized based classes. Again, manually going through each and every base and adding breakpoints in would have caught them for each class that I tediously added them all in, but I was really hoping to get a better idea of when anything was called by the host app.
|
|
|
|
|
Hi
I have created BHO add ons for internet explorer. When I debug this add ons on vista IE7 then it debug correctly, but when I debug this on IE9 on windows vista , it can not be debug and no break point get invoked. So is there any setting required for this.
I also observed that BHO add ons can debug only on default browser come with windows OS. i.e win XP IE6, vista IE7 and windows 7 IE8, if user upgrade browser then BHO can not debug.
Please send me setting required for debuging.
|
|
|
|
|
Set HKCU/Software/Microsoft/Internet Explorer/Main/TabProcGrowth to 0 and check if you can debug correctly.
|
|
|
|
|
Thanks Rejeesh !!
|
|
|
|
|
I call DeviceIoControl() as below:
err = DeviceIoControl(hVolume,IOCTL_SCSI_PASS_THROUGH_DIRECT,(PVOID)sptd_sb, (DWORD)sizeof(sptd_sb),(PVOID)sptd_sb,(DWORD)sizeof(sptd_sb),dwBytesReturned,NULL);
which sptd_sb is a _SCSI_PASS_THROUGH_DIRECT_AND_SENSE_BUFFER.
in most of the DVD Rom and CD Rom it works well and it fills in sptd_sb but in some of them like ASUS CD s400/A ATA Device it doesn't and sptd_sb is empty while the return value is 1 and GetLastError is 0 in both situation.
does anybody have anyidea about it?
thanks in advance
|
|
|
|
|
Hey everybody!
Is there a way to get access rights out of a process HANDLE ?
Thanks!
|
|
|
|
|
|