|
Here is an hypothesis. It may seem far fetched, it has been proven correct many times already.
A file gets created. By your app or another one, not really relevant.
Pretty soon (very relevant) your app wants to read that file, no problem; wants to modify or delete that file, big problem.
What happens is this: something is also interested in your fresh file, opens it with read intentions, but doing so also locks it for writing and deleting.
Who does this? Any piece of code that wants to help you: an anti-virus package; an automatic indexer; Google Desktop; you name it.
Remedy 1: wait 1 minute. Literally. Let the helpers do their work, then remove the file.
Remedy 2: use a special folder, and put it on the exceptions list of the helper, if you can identify it.
Why the sudden change? did you add such helper? did one of them become slower? did the load of your system increase recently, making everything run a bit slower?
FYI: Windows Explorer is well aware of this phenomenon; if you give it a delete command, which fails, it will not tell you immediately; instead it will retry 5 times at 1 second intervals, and only if that still fails, it will tell you so. (And you can find a patch to modify that "5" in the registry, Google will provide the details).
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Thanks for the helpful suggestions.
It turns out my observations were flawed. The CFile::Remove is working correctly. The data processing has slowed to a crawl and it appeared that the files accumulating was the cause. Instead it is the result.
Have posted a query in the Database forum now.
Thanks again.
Thanx,
>>>-----> MikeO
|
|
|
|
|
Hello folks!
This is -i guess- not possible but i thought i ask maybe some of you know a nice way. I am making a template class and it would be quite convinient if i could pass a string literal to it easily as a template parameter. As we know, string literals can't be template parameters:
template <const char *str>
class TTemplateClass {
const char *GetString() { return str; }
};
class CSubClass: public TTemplateClass<"Hello World">
{
...
};
As i understood, the string literal causes a problem because it is not a named object (this has something to do with internal or external linkage). One can do something like this instead:
template <const char *str>;
class TTemplateClass {
const char *GetString() { return str; }
};
extern const char strHello[] = "Hello World";
class CSubClass: public TTemplateClass<strHello>
{
...
}; This is fine, however, pretty unconvinient that every time you want to use TTemplateClass you will have to declare a char array to be passed as a template parameter. I would rather do something like this:
template <const char *str>;
class TTemplateClass {
const char *GetString() { return str; }
};
class CSubClass: public TTemplateClass<LITERAL_TO_NAMED("Hello World")>
{
...
}; And let the string get "converted" automatically. Does anyone of you know of any trick to achieve this?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
Why do you need to pass the string literal as template argument?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I guess efficiency. Using a method where you customise the class by passing in a string means it has to be stored in a data member. Using a template each instantiation with a specific string has the pointer hardcoded in its implementation.
Steve
|
|
|
|
|
Well, it is a long story, basicly, i want to create a template class that contains some information about the class that inherits from it. All the info is known at the time of declaring the class and is static thoroughout the lifetime of the program. So i thought the simplest way to specify this info would be to make my classes inherit from a template. So i can simply do:
class CSomeClass: public TClassWithInfo<1, 2, 3, "blah">
{
...
};
The template also creates some static members. I could of course go with a simple base class and specify the information in the constructor but this means more work + i loose the "automatic static members creation per parameter combination" feature of the template so i would have to declare/define the static members manually for the subclasses...
class CBaseClass
{
public:
CBaseClass(int one, int two, int three, const char *str);
...
};
class CSomeClass: public CBaseClass
{
public:
CSomeClass();
...
};
...
CSomeClass::CSomeClass()
: CBaseClass(1, 2, 3, "oh my god it is full of starts")
{
...
} Also for this to work i would need to add a constructor to CSomeClass that can "relay" the different values of subclasses of CSomeClass to CBaseClass which means even more work...
class CSOmeClass: public CBaseClass
{
public:
CSomeClass();
CSomeClass(int one, int two, int three, char *str);
...
};
...
CSomeClass::CSomeClass()
: CBaseClass(1, 2, 3, "oh my god it is full of starts")
{
...
}
CSomeClass::CSomeClass(int one, int two, int three, char *str)
: CBaseClass(one, two, three, str)
{
...
}
...
class CSomeOtherClass: public CSomeClass
{
public:
CSomeOtherClass();
...
};
...
CSomeOtherClass::CSomeOtherClass()
: CSomeClass(2, 3, 4, "Yellow submarine")
{
...
} I think with the template solution i could simplify all the coding need for it by just having to use the template when i declare the class and move along...among the info i would like to specify some string(s), these would mostly be used for debugging. Sadly string literals it can't digest. Having to declare an array of chars eash time i use the template in the header of a class and then having to define it somewhere in the class's cpp seems to be the only way now but it decreases the "easy to use"-ability of the whole concept.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
Hey everybody.
I am trying to a call a virtual function directly from the VTable.
I created a COM component using the visual studio (ATL Simple object).
<br />
STDMETHODIMP Ctest_com::print_me(BSTR txt)<br />
{<br />
OutputDebugString(txt);<br />
return S_OK;<br />
}<br />
Now, I am trying this use the COM, but calling the function via VTable:
<br />
typedef HRESULT (STDMETHODCALLTYPE* ptr_print)(BSTR); <br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
CoInitialize(NULL);<br />
<br />
cpp_com_testLib::Itest_com* comobj;<br />
HRESULT hr = CoCreateInstance(__uuidof(cpp_com_testLib::test_com),<br />
NULL,<br />
CLSCTX_INPROC_SERVER,<br />
__uuidof(cpp_com_testLib::Itest_com),<br />
(void**)&comobj);<br />
<br />
int* vptr = (int*)(comobj); <br />
vptr = (int*)*vptr;
int* vproc0 = (int*)vptr[0];
...<br />
...<br />
...<br />
int* vproc7 = (int*)vptr[7];
<br />
ptr_print p = (ptr_print)vproc7;
_bstr_t bstr(_T("MY TEXT!"));<br />
p(bstr);
<br />
comobj->Release();<br />
<br />
CoUninitialize();<br />
<br />
return 0;<br />
}<br />
NOW, here is THE PROBLEM.
When I call "p(bstr)" I do get to "print_me()", BUT the parameter "txt" is not passed to the function correctly (I sends a whole different address, so it is a BAD POINTER).
ANY IDEAS????
THANKS A LOT IN ADVANCE!
|
|
|
|
|
I probably shouldn't encourage this sort of low level hackery, it'll only hurt someone you work with one day...
However, why what you're up to won't work is due to the "this" pointer. All C++ member function calls have an implied first parameter which is the address of the object the function is invoked on. So if you write:
a->b( c );
the compiler converts this to:
<class of="" a="">::b( &a, c );
So in your case if you call:
p( &comobj, bstr );
it might all start working swimmingly.
Oh, and if it does don't tell anyone I told you or generations of coders will be cursing my name for spreading low level hacks around.
Cheers,
Ash
|
|
|
|
|
Great answer. Including all of the "It wasn't me who told you how to do this".
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
|
|
|
|
|
It works! That's so awesome!
I'm just asking to get the whole idea of that interface, COM and vtable stuff better.
Thanks a lot !
|
|
|
|
|
I was hoping that it was just to get an idea of what's going on under the covers, glad I could help.
Cheers,
Ash
|
|
|
|
|
hi i would to create a tools to make life easy.
i would like to join a few basic setup file on fresh installed pc's.
but i only wanna do a few click and not look @ the screen @ the each of each individual setup file.
i would program the order how to execute, open the setup file from known feeware /media software / ccleaner / etc, and programaticly click the button of the setup file.
there use to be a very known free anti spam / add program from the netherlands with did this.
it's easy to check the open processes for names.
but what to do next, if you have the handle of the setup file windows?
how do i make the very wel known 'next' button go click?
i have pretty wide knowlegde of visual c#, i have done some Nokia Qt c++, made a custom control draw control in like 2 days or so.
but not to much ms vc++, accept some mfc years ago.
the idea is, the app has to run on 1 minute old fresh windows installation.
so i would like to try it in c++.
how to scan all the processes running by 'username' in proceslist?
to get handle of the window, to find handle of the wanted button, checkboxes?
another posibility is to make the mouse move and click, since you know the the setup windows location.
set Focus, you probably can send a winproc message to the operation system and make it click.
read updates from progres bars, panel change.
could anyone help me solf this problem, ith any usefull info.
thank you
Bad = knowing 2 much
|
|
|
|
|
Hi,
While displaying values in CListCtrl it is not displaying values for certain
columns what is the problem
I am using SetItemText() function for setting values.
For few columns it is working for few columns it is not working
what is the problem.
Can any one please me.
Regards,
Sakhalean.
|
|
|
|
|
Please post the relevant code.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
Here m_ListInfoCtrl is a varible for CListCtrl
ie dialog listcontrol and a dialog variable
while( !m_pFrame->m_DbMgr.m_Rs.IsEof() )
{
m_pFrame->m_DbMgr.m_Rs.GetFieldValue( "LruIndex", nLruIndex );
strTemp.Format( "%d", nLruIndex );
m_pFrame->m_nLruIndex = nLruIndex;
m_ListInfoCtrl.InsertItem( nLruIndex-1, strTemp );
//---- LRU Name ------------
m_pFrame->m_DbMgr.m_Rs.GetFieldValue( "LruName",strLruName );
m_ListInfoCtrl.SetItemText( nLruIndex-1, 1, strLruName );
//----- MIl Bus ----------------
m_pFrame->m_DbMgr.m_Rs.GetFieldValue( "MilBus", strTemp );
strTemp.Insert( 0, " " );
m_ListInfoCtrl.SetItemText( nLruIndex-1, 3, strTemp );
m_pFrame->m_DbMgr.m_Rs.MoveNext();
}
}catch( CADOException& e )
{
strSql = "CSIRBaseView::UpdateListControl():GetFieldValue "+e.GetErrorMessage();
MessageBox( strSql );
}return FALSE;
Here firt two columns are coming ie LRUIndex and LRUName
but the third column MilBus is not displaying the value.
|
|
|
|
|
m_ListInfoCtrl.SetItemText( nLruIndex-1, 3, strTemp );
should be
m_ListInfoCtrl.SetItemText( nLruIndex-1, 2, strTemp );
I'm pretty sure.
|
|
|
|
|
Hi,
I have used
//---- LRU Type -----------
m_pFrame->m_DbMgr.m_Rs.GetFieldValue( "LruType", nLruType );
strTemp = m_pFrame->m_strLruType[nLruType-7001];
m_ListInfoCtrl.SetItemText( nLruIndex-1, 2, strTemp );
column 2 for LRU Type
I have used here 7 columns
all columns it is showing the values but for column 3 only
it is not showing the value.
Please help me.
|
|
|
|
|
/----- MIl Bus ----------------
m_pFrame->m_DbMgr.m_Rs.GetFieldValue( "MilBus", strTemp );
strTemp.Insert( 0, " " );
m_ListInfoCtrl.SetItemText( nLruIndex-1, 3, strTemp );
That is your original code. Notice that you're inserting a space into the string, and that's it. This is why nothing is showing in the column. All you're doing is inserting nothing... or more to the point, you're inserting nothing that can be seen by the naked eye.
Try putting an "A" or "Test" or something into that string, to double check that the code is working correctly. Because at this point, I think it is.
|
|
|
|
|
Scratch what I said before, I didn't look closer. I feel stupid.
Ok so honestly you probably don't even need the strTemp.Insert(...) call. If you take that out, see what happens. I'm betting that it'll work. The reason why I say this is because the " " is null-terminated. Though this shouldn't matter, I think that's what the problem is. I'm betting that if you take the Insert call out, then you'll be left with whatever value strTemp holds originally from the GetFieldValue(...) call.
|
|
|
|
|
Sakhalean wrote: m_ListInfoCtrl.InsertItem( nLruIndex-1, strTemp );
int x = m_ListInfoCtrl.InsertItem(nLruIndex-1, strTemp);
...
m_ListInfoCtrl.SetItemText(x, 1, strLruName);
m_ListInfoCtrl.SetItemText(x, 2, strTemp);
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
He was having a problem with the column. Indexing for columns is the second argument for SetItemText.
When inserting an item, the item text defaults to column 0 (first column).
Setting item text is then indexed in the second argument, so the first function call to SetItemText is correct (index number 1). The second function call was incorrect, because there are only 3 columns, and there is no "column 3".
His problem was that he used index 3.
|
|
|
|
|
josda1000 wrote: His problem was that he used index 3.
Possibly, but the bigger issue was the he was not using the return value from InsertItem() . If the list control has the either of the LVS_SORTxxx styles, then calling InsertItem(nLruIndex-1, ...) does not guarantee that the newly inserted item will be at position nLruIndex-1 .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Good point. I think both points are valid then.
|
|
|
|
|
Hi,
I am adding one .lib dependency with my project using vs2008 and its conficting with MSVCR90.DLL.
Linker Error is: error LNK2005: __amsg_exit already defined in msvcrtd.lib(MSVCR90D.dll)
How can I resolved that?
|
|
|
|
|
What library or .lib ar you adding to the project?
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
|
|
|
|
|