|
The other way out is click on 'CANCEL' button to debug.
Before that copy the source code on the machine where you get the above crash.
Open the project in visual studio and build the project in 'DEBUG' mode.
Now run the application and click 'CANCEL' button to debug when the above error occurs.
When OS asks for debugger to attache, provide the running instance of the visual studio, that will take you to the point where the access violation is raised.
|
|
|
|
|
this error because i am creating multiple thread using AfxBeginThread() see below
my code :
WSADATA wsaData;
WSAStartup(0x0101, &wsaData );
struct sockaddr_in stSockaddr_in;
struct sockaddr stSockaddr;
SOCKET sock;
fd_set readfds1;
FD_ZERO( &readfds1);
//create listening socket
sock = socket(AF_INET,SOCK_STREAM,0);//create socket
//sets the family,port and the addrees
stSockaddr_in.sin_family = AF_INET;
stSockaddr_in.sin_addr.s_addr = INADDR_ANY;
stSockaddr_in.sin_port = htons(9000)
//Use bind to establish the local association of the socket by assigning a local name to an unnamed socket
int nRet = bind(sock, (LPSOCKADDR)&stSockaddr_in, sizeof(struct sockaddr));//bind
//listen function places a socket a state where it is listening for an incoming connection
if(listen( sock, MAX_CONNECTS ) < 0)//listen
{
//listen error
return 0;
}
SOCKET ret_sock;
//accept the connection
ret_sock = accept(sock,&stSockaddr,NULL);
if(INVALID_SOCKET != ret_sock)
{
char szBuffer[MAX_BUF_LEN];
//to receive the configuration data
int iLength = recv( ret_sock,(char*) szBuffer, MAX_BUF_LEN, 0 );
szBuffer[iLength] = 0;
CString csBuffer;
int iLen = strlen(szBuffer);
WCHAR wcStr[MAX_DATA_SIZE];
memset(wcStr,'\0',sizeof(WCHAR)*MAX_DATA_SIZE);
mbstowcs( wcStr,szBuffer,iLen);
csBuffer.Format(L"%s",wcStr);
////////////////////////////////////////////////////////////////////////
if(!csBuffer.IsEmpty())//data is not empty
{
CWinThread *Thread = NULL;
Thread = AfxBeginThread(func,(LPVOID)&someValue,THREAD_PRIORITY_NORMAL,0,0,NULL); //Here only i am getting the apllication error (Not Creating Multiple thead)
}
}
How to resolve this problem ?
|
|
|
|
|
To fix: Run your app under the debugger, check the call stack when it breaks.
|
|
|
|
|
it breaks in afxBeginthread creation only?
|
|
|
|
|
Why does it break?
What source line does it break on? What module?
If it breaks because of an assert, what does the assert statement say?
If it breaks because of a null pointer, what is the pointer supposed to be pointing to?
How do you expect us to help you when you don't give us all the details?
|
|
|
|
|
i have created parent thread,
AfxBeginThread(parent,this,THREAD_PRIORITY_NORMAL,0,0,NULL);
declaration :
class CTestApp : public CWinApp
{
public:
static UINT parent(LPVOID lpParam);
static UINT child(LPVOID lpParam);
/////////////////////////////////////////////////////////////////////////////
definition:
UINT CTestApp::parent(LPVOID lpParam) //multiple client request the parent
{
//.....
//listening socket and create new thread
if(!csBuffer.IsEmpty())//data is not empty
{
CWinThread *Thread = NULL;
Thread = AfxBeginThread(child,(LPVOID)&someValue,THREAD_PRIORITY_NORMAL,0,0,NULL); //Here only i am getting the apllication error (Not Creating Multiple thead)
}
return 1;
}
UINT CTestApp::child(LPVOID lpParam) //mulitple times its has to created
{
//do stuff
return 1;
}
i hope this time i have given clearly my problem. I am tryng to create a multiple threads
-- Modified Monday, January 24, 2011 11:08 AM
|
|
|
|
|
So have you stepped into AfxBeginThread() to see what is going on?
"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
|
|
|
|
|
Hi all,
i have an edit box,when i paste some data of diffrent laguage like chines its correctly visible on dialog box.
but i m GetDlgItemText this value here all values ar display in ???????? this format.
please tell me how can i get same value after GetDlgItemText in application.
thanks in advance
|
|
|
|
|
This is most likely due to you only using the ASCII character set.
You need to select "Use Unicode Character Set" from the Project Properties>General>Character Set
|
|
|
|
|
there is any other option that work for it with Multi byte character set option.
|
|
|
|
|
Absolutely. I prefer Unicode because it is easier to work with.
|
|
|
|
|
actually i worked with multibyte and if now i change it there is so many error comes.
|
|
|
|
|
If you are not changing your application to unicode than use
GetDlgItemTextW and CStringW.
May be this will solve your problem.
I believe in LOVE AT FIRST SITE...
Bcoz I have loved my Mother...
even since I opened my eyes...(ICAN)
|
|
|
|
|
Hi There,
Recently I'm trying allegro game programming library. I wanted to implement a multi-threaded program using allegro. But when I try to compile it, it give me an error "conflicting declaration 'typedef struct tagBITMAP BITMAP'". When I remove the Header file windows.h, this error message is not displayed. So that mean I can't use windows.h and allegro.h same time.
Please give me a comment regarding this problem.
Thank you verymuch
Thil
|
|
|
|
|
|
Thank you very much Andrew. I did it. but I couldn't find a solution. That's why I posted that question.
Thanks again. If you have a solution please let me know.
Thil
|
|
|
|
|
|
I find some code to set it.
But there no image appear in the CListCtrl's column.
HDITEM headerItem;
headerItem.mask = HDI_FORMAT;
CHeaderCtrl* pHeaderCtrl = GetHeaderCtrl();
if(iColumn != m_iCurrentSortItem) {
pHeaderCtrl->GetItem(m_iCurrentSortItem, &headerItem);
headerItem.fmt &= ~(HDF_IMAGE | HDF_BITMAP_ON_RIGHT);
pHeaderCtrl->SetItem(m_iCurrentSortItem, &headerItem);
m_iCurrentSortItem = iColumn;
m_imlHeaderCtrl.DeleteImageList();
}
if(iColumn >= 0 && pHeaderCtrl->GetItem(iColumn, &headerItem)) {
m_atSortArrow = atType;
HINSTANCE hInstRes = AfxFindResourceHandle(MAKEINTRESOURCE(m_atSortArrow), RT_BITMAP);
if (hInstRes != NULL){
HBITMAP hbmSortStates = (HBITMAP)::LoadImage(hInstRes, MAKEINTRESOURCE(m_atSortArrow), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS);
if (hbmSortStates != NULL){
CBitmap bmSortStates;
bmSortStates.Attach(hbmSortStates);
CImageList imlSortStates;
if (imlSortStates.Create(14, 14, ILC_COLOR32 | ILC_MASK, 1, 0)){
VERIFY( imlSortStates.Add(&bmSortStates, RGB(255, 0, 255)) != -1 );
(void)pHeaderCtrl->SetImageList(&imlSortStates);
m_imlHeaderCtrl.DeleteImageList();
m_imlHeaderCtrl.Attach(imlSortStates.Detach());
}
}
}
headerItem.mask |= HDI_IMAGE;
headerItem.fmt |= HDF_IMAGE | HDF_BITMAP_ON_RIGHT;
headerItem.iImage = 0;
pHeaderCtrl->SetItem(iColumn, &headerItem);
}
|
|
|
|
|
Check this link->[^]
I believe in LOVE AT FIRST SITE...
Bcoz I have loved my Mother...
even since I opened my eyes...(ICAN)
|
|
|
|
|
Isn't imlSortStates going out of scope? I would make that object a member of the dialog.
"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
|
|
|
|
|
I use the Shell_NotifyIcon(NIM_ADD, &m_nidIconData) to add a tray icon for my application. The Icon is added. but when Mouse moved over this icon, the icon disappear. Is there any other statements needed to write?
modified on Monday, January 24, 2011 9:33 PM
|
|
|
|
|
Sounds like the application that installed the icon is no longer running and didn't remove the icon. Explorer realises something's wrong when you interact with the icon and it attempts to communicate with the controlling procress (and fails).
Steve
|
|
|
|
|
Is your application running ? Make sure that your application is running when icon disappears.
|
|
|
|
|
Yes, My application is running when tray icon appear and disappear.
|
|
|
|
|
OK, so you say the process that installed the icon (by calling <a href="http://msdn.microsoft.com/en-us/library/bb762159%28v=vs.85%29.aspx">Shell_NotifyIcon</a>[<a href="http://msdn.microsoft.com/en-us/library/bb762159%28v=vs.85%29.aspx" target="_blank" title="New Window">^</a>] ) is still running. This would suggest that the window handle (the hWnd member of the NOTIFYICONDATA[^] structure) you passed when adding it is no longer valid (the window has been destroyed).
Steve
|
|
|
|