|
I just moved some code from a CWinThread into a new thread (standard thread) and am now getting stack overflows (while accessing a COM engine -- "DesktopSearch").
Any clues for me?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc.</A>
|
|
|
|
|
Have you initialized com for the new thread?
John
|
|
|
|
|
absolutely!
I played with different CoInit calls to see if WDS would behave better...
But, I am CoInit'ing in the thread...
What are the issues that surround stack and threads? Is this additional stuff surrounding COM and/or DCOM?
Thanks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc.</A>
|
|
|
|
|
In windows, if u have specified initial size of the stack, in bytes. The system rounds this value to the nearest page. If this parameter is zero, the new thread uses the default size for the executable. may be u ur program requires more stack or encoutering with some loops which do some allocation. Pls check ur code.
SaRath
"D on't blindly follow rules you read somewhere without verifying that it makes sense for your situation!"
|
|
|
|
|
Hi ~
I have an MFC application using automation that needs to open an access database, perform a query to get a recordset and then copy the recordset to Excel. I found an article on the microsoft site that explains how to do it, but I am getting an error = "The server threw an exception"
The article is at: support.microsoft.com/kb/243394/en-us
I am using Visual C++ 6.0 and Excel/Access 2003 (although my file is Access 2000 format).
Any ideas on what I might need to do to fix it? Thanks so much for your help!
Jen
|
|
|
|
|
Have you single-stepped through the code to find which statement is throwing the exception?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
I have to write a clinet/server application with sockets and the client use CODBC classes to conect to a local .mdb file and i don't know what to choose for server implementation .
I have tried CDAO clases but DAO doesn't suport multithreading
Please can anyone tell me what I have to use so i can connect to a db engine o server application and be able to use multithreading?
Eg the server thread
UINT ServerThread (LPVOID pParam)
{
threadstruct* ts = (threadstruct*)pParam;
char buffer[BUFFERSIZE];
int size = BUFFERSIZE;
int blabla=0;
cout << "a new client";
while(1)
{
int sz = ts->pSock->Recv(buffer,size,ts->indice);
if(sz == 0)
{
ts->pSock->ServerClose(ts->indice);
delete ts;
return 0;
}
if (sz>3)
{
CMyMessage msg(buffer);
switch(msg.GetMyMsgType())
{
case 0:
cout << endl;
cout << msg.GetMyMsgComm() << " -> " << msg.GetMyMsgText() << endl;
if (!strcmp(msg.GetMyMsgComm(),".SD4P"))
{
CString strComm;
strComm.Format(".SD4P");
CString strText;
strText.Format("return .SD4P");
CMyMessage msg(strText.GetBuffer(strText.GetLength()),strText.GetLength(),strComm.GetBuffer(strComm.GetLength()),strComm.GetLength(),0);
char buffer1[253];
int size1;
msg.GetMyMsg(buffer1,&size1);
ts->pSock->Send(buffer1,size1,ts->indice);
// here i have to implement a db connection to extract some fields and to send the obtained data to client. CArticolSet is a CDAO inheritance and does not work
/*WaitForSingleObject(hMutex1, INFINITE);
CArticolSet* artset = new CArticolSet();
artset->GetDefaultDBName();
artset->GetDefaultSQL();
artset->Open();
artset->Close();
ReleaseMutex(hMutex1);
delete artset;
*/
}
|
|
|
|
|
I've done this very thing -- with ADO
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc.</A>
|
|
|
|
|
Use ADO or ODBC for multithreaded database access. It is possible (as I have done this in the past) with DAO but why waste time with technology that microsoft has quit developing 5 years ago...
John
-- modified at 22:07 Wednesday 31st May, 2006
|
|
|
|
|
Are the client and the server on the same machine?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
CString LString;
CString Win = GetWinampPath();
Win.Replace("Winamp.exe","winamp.ini");
AfxMessageBox(Win);
CStdioFile file;
CString Filepath = Win;
const int sz =100;
char buf[sz];
if (file.Open(Filepath,CFile::modeReadWrite|CFile::modeNoTruncate|CFile::modeCreate))
{ // what i have to add here?
file.ReadString(buf,100);
LString = (LPTSTR)buf;
if ( LString == "minimized=0")
{
file.Remove(LString);
file.WriteString("minimized=1");
}
}
file.Close();
|
|
|
|
|
Hi
I am not able to answer as per your question.
From your code it seems that you want to change the settings of INI file.
Then why not to try the functions ?
GetPrivateProfileInt
SetPrivateProfileInt
GetPrivateProfileString
SetPrivateProfileString etc...
Regards
Anil
|
|
|
|
|
oh ?
I got the winamp.ini file:
...
...
...
...
minimized=0 //the part i want to remove
...
...
Files.ini have different act than .txt etc?
|
|
|
|
|
In that case the above code seams a lot of things missing
What I think of is that in stead of using CStdioFile you use CFile.
In CFile you can read the whole file into a CString.
Then use CString remove command to remove the part of the string you want to remove.
Then write the string back to the file.
Other method is use a temporary file and read one line and write to temp file, Except the line you want to remove.
Then copy the temp file to .ini file.
Regards
Anil
|
|
|
|
|
thx
|
|
|
|
|
Immunity18 wrote: file.ReadString(buf,100);
Why use char here? A CString object (e.g., LString ) is a much better choice.
If you are changing the contents of a .ini file, why not use the appropriate functions?
GetPrivateProfileString()
WritePrivateProfileString()
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
i'll try that althought its first time i hear about these functions ( i am a (very) bit newbie
|
|
|
|
|
Hi all =)
Is there a way of forcing the operator new to fail?? I need to test something...
Best regards [[]]
hint_54
-- modified at 18:06 Wednesday 31st May, 2006
Oh.. and one more thing =D
If I overload the operator new then the class constructors will not be called when memory is allocated for them. How do I make it call the constructor?
Peace =)
hint_54
|
|
|
|
|
hint_54 wrote:
If I overload the operator new then the class constructors will not be called when memory is allocated for them. How do I make it call the constructor?
Placement new? new (ptr_to_memory) Class(args)
--
100% natural. No superstitious additives.
|
|
|
|
|
Overloading the new should not effect whether the constructor is called.
Steve
|
|
|
|
|
Yes.. It's working now, but it didn't work at first.. Don't know why..
regards
hint_54
|
|
|
|
|
hint_54 wrote: If I overload the operator new then the class constructors will not be called when memory is allocated for them.
How are you verifying this?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
I add a printf to the constructor.
But I don't get it.. it wasn't calling it and now it is! It must have been something else..
regards
hint_54
|
|
|
|
|
I am using this code to create a modeless dialog.
dlg.Create(CMainDialog.IDD, GetDesktopWindow());
dlg.ShowWindow(SW_SHOW);
However, It closes the modeless dialog as soon as it opens. Why is this? I get the debug message "Warning: calling DestroyWindow in CDialog::~CDialog --OnDestroy or PostNcDestroy in derived class will not be called"
Sorry for another stupid question. I swear I will catch on sooner or later.
Hey Maybe it will give you a chance to feel good about being able to answer an easy question, though make me feel even more stupid
-Brandy
|
|
|
|
|
Are you istantiating the dlg object inside a class method? If so, the problem is that as soon as the method exits, the dlg object gets destructed and your dialog is gone. The dlg object needs to live as long as you want the dialog to be displayed.
|
|
|
|