|
Excellent! That worked perfectly.
Thanks again
|
|
|
|
|
I am trying to let a media player control play back a movie continuously unless stopped by user, however, after 23 minutes, the application got a "stack overflow" error.
Anybody can help on this by giving me some ideas on this and related issues? - "stack overflow" and how the MFC/C++ deal with this?
Thanks
JW
DJ
|
|
|
|
|
|
NT/2k/XP have a 1MB stack limit, though I believe it can be extended. However, I can't conceive of a reason to do so. The only reason you would hit this limit are doing huge allocations on the stack with alloca() or other means or you have a recursive function. I'll place bets on the latter.
Note, this is an SEH exception (vs. C++ exception) which you can catch and handle to help direct you to the offending code.
|
|
|
|
|
I will be trying to catch and handle the exception.
But, for this case, it is not anything codes wrong, I just wanted to use a Media Player Control to play back a movie continuously, or for ever unless stopped. The applicaiton could run about 22 munitues before the expection popped up.
For applying Windows Controls, seems I have no way to find out how the Control deal with the Stack. Any more suggestions?
THanks
JW
DJ
|
|
|
|
|
I will be trying to catch and handle the exception.
But, for this case, it is not anything codes wrong, I did not allocate huge blocks on the Stack, nor using recursive functions.
I just wanted to use a Media Player Control to play back a movie continuously, or for ever unless stopped. The applicaiton could run about 22 munitues before the expection popped up.
For applying Windows Controls, seems I have no way to find out how the Control deal with the Stack. Any more suggestions?
THanks
JW
DJ
|
|
|
|
|
The only reference I could find on the web is that the older control has an unchecked strcpy in it which can overright the stack. This is a third way to overflow the stack: create an artificial recursive function, but it's rare since it usually throws other types of exceptions (though I've had it happen to me.)
Could their also be a callback not being handled/exited correctly (it's not these controls have the greatest of documentation for their esoteric aspects)?
|
|
|
|
|
The exact message for the exception is :
Unhandled exception in VTS_01_ALL.exe(MSDXM.ocx):0xC00000FD: Stack Overflow.
DJ
|
|
|
|
|
CreateProcessAsUser driving me crazy
I need to have my program launch another program (test.exe) as another user (dummyuser). My code works until I get to the point of actually launching the test.exe program. At that point I get a 0x522 error - A required privilege is not held by the client.
If I log in as dummyuser, the I can run the test.exe program without problem. So, I believe the user has the permissions it needs
I've also tried an example from MSDN, and two from bulletin boards. All have the same problem.
My code relies on default values for some of the gory details, like winstation and desktop. The sample code I tried implemented them in detail with the same result. So, I don't think that's the problem.
I can't understand the difference between what my program does and what happens if I login in as dummyuser.
Here's my latest code:
code:--------------------------------------------------------------------------------
HANDLE h;
if( !LogonUser("dummyuser","dummydomain","dummypassword" ,LOGON32_LOGON_INTERACTIVE,LOGON32_PROVIDER_DEFAUL
T, &h))
{
DWORD dwErr = GetLastError();
return FALSE;
}
char * buffer = (char *) malloc(256);
DWORD size = 256;
if (GetUserName(buffer,&size))
{
TRACE0( buffer); /// This shows my original user name
TRACE0("\r\n");
}
if (!ImpersonateLoggedOnUser(h))
{
DWORD dwErr = GetLastError();
return FALSE;
}
size = 256;
if (GetUserName(buffer,&size))
{
TRACE0( buffer); /// This shows current user is dummyuser
TRACE0("\r\n");
}
STARTUPINFO st;
memset(&st,0,sizeof(st);
st.cb = sizeof(st);
//"\\Odyctx00\dDesktop\odyssey17.exe"
PROCESS_INFORMATION pi;
if (!CreateProcessAsUser(h,"C:\\test.exe" ,"",
NULL,NULL,FALSE,0,NULL,NULL,&st, &pi))
{
DWORD dwErr = GetLastError(); /// dwErr = 0x522
return FALSE;
}
--------------------------------------------------------------------------------
Thanks for any help or advice on this one. Its been driving me nuts.
|
|
|
|
|
I have two threads that need to insert new items to the same tree control on win nt.
If the windows tree control thread safe or should I synchronize the insert operation ?
Actually it would be easier to ask it like this.
Is ::InsertItem api that is used to insert new items thread safe ?
Does windows synchronize the operation ?
Thanks,
Orcun Colak
|
|
|
|
|
If you are using MFC, the objects are not thread-safe at the object level, only at the class level.
|
|
|
|
|
If you use SendMessage or PostMessage the control is thread-safe, because Windows guarantees that message handling is thread-safe. The MFC objects that wrap controls (like CTreeCtrl ) do not work across thread boundaries.
Software Zen: delete this;
|
|
|
|
|
TN062: Message Reflection for Windows Controls
RE: _EX version of things:
"If the handler returns TRUE, the message will be handled by the parent as well, while a call that returns FALSE does not allow the parent to handle it."
According to my own experiments, they have it backwards. - Parent handler will run when FALSE is returned!
Can anyone confirm this?
|
|
|
|
|
My MSDN for .NET says:
If the handler returns FALSE, the message will be handled by the parent as well, while a call that returns TRUE does not allow the parent to handle it. Note that the reflected message is handled before the notification message.
...and this is right, so you are right as well.
Regards,
BB
|
|
|
|
|
Hi i have the below piece of code which
i use to query a table in my database with ado
however i would like to know how many records this query pulls back
does any one know how to do it, im a bit of a novice, i know its something
to do with using RecordCount, but im stuck on how to use it
thanks
si
strSQL.Format("Select * from temp2 where surname like '"+m_eind_searchnme+"'");
_variant_t vstrSQL;
vstrSQL.ChangeType(VT_BSTR);
vstrSQL = strSQL;
MySet.CreateInstance(__uuidof(Recordset));
MySet->Open(vstrSQL,MyDb.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
|
|
|
|
|
RecordCount doesn't always work and I think it has to do with the database. However, if you want to know all the records that you have pulled there are two different ways (in case RecordCount doesn't work).
// The first one is to iterate throuch each recordset
// pRs is an object of RecordsetPtr_
pRs->MoveFirst()
nCounter = 0;
while( pRs->GetEOF() == FALSE )
{
nCounter++;
pRs->MoveNext();
}
// The second method is to use SQL statements by using
SELECT COUNT(*) AS Total FROM Table WHERE condition
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Hi,
I am trying to create a grid control using CListCtrl and my main problem right now is getting the control to display the cells in the first columns as button.
I'm not sure if this is the right way, maybe there is a way to create header for the rows just like the columns.
ANy ideas on how to do this.
Thanks in advance.
|
|
|
|
|
Try the customdraw service. You will have total freedom for drawing the first column cells however you like.
|
|
|
|
|
I'm already using Custom Draw, but I'm not sure on how to create row headers.
Thanks
|
|
|
|
|
As we all know, when windows loading, explorer.exe will initialize the desktop,taskbar etc.
I write a progrom which uses system tray icon.But there is a problem. when the explorer.exe is killed or error corrupt, when the taskbar is reinitialized, the icon which added by my program is dispeared.
How can I get the notification when the explorer.exe is initialized, So as I can put my icon on system tray again just like the system process "Sound.exe" or "Network"?
Thanks.
|
|
|
|
|
Just register TaskbarCreated, it sent every time top explorer restarted
|
|
|
|
|
|
Hi, everyone!
Sometimes we use pointer as the parameter type and sometimes
we use reference as the parameter type.
I think using reference is better than using object directly.
Since it can save memory and operation (assignment operator).
But what about pointer V.S. reference? I want to know in which
case should I use pointer and in which case should I use reference.
Here are two samples,
Using reference,
--------
ostream& operator << (ostream&, ObjectType);
--------
Using pointer
--------
MemPoolAddSize (char*, size_t)
--------
I want to know your suggestions about pointer v.s. reference.
What is the general consideration about when using pointer and
when using reference?
Thanks in advance,
George
|
|
|
|
|
I use a rule from Scott Meyers: if the referenced-to object must always exist, use a reference; if you want to allow for a non-existing reference (NULL), use a pointer. Note that in your case the only way to use C strings is through a pointer to char.
|
|
|
|
|
That's a very good description!
Scott Meyers rules I like his books
Daniel
---------------------------
Never change a running system!
|
|
|
|