access violation at 0x00000000
-
Hi,Everyone: i'm running a program as form-based, Doc/view struct. i create a thread in the initialization of the program, and in thread, we use while(1) circulation. it runs well usually, but we'll get unexpected error dialog, (and program shut down), this is following error infomation: "access violation at 0x00000000: read of address 0x00000000". Process Stopped. Can any one of you give me some suggestions? Thanks! ________________________________________ Many nights we've prayed with no proof anyone could hear, we were moving moutains long before we knew we could! Yet now i'm standing here, although we know there's much to fear, hope seemed like summer bird too swiftly flown away ... There can be miracles! When you believe, though hope is frail, it's hard to kill! Who knows what miracles, you can achieve! When you believe, somehow you will ... YOU WILL WHEN YOU BELIEVE
-
Hi,Everyone: i'm running a program as form-based, Doc/view struct. i create a thread in the initialization of the program, and in thread, we use while(1) circulation. it runs well usually, but we'll get unexpected error dialog, (and program shut down), this is following error infomation: "access violation at 0x00000000: read of address 0x00000000". Process Stopped. Can any one of you give me some suggestions? Thanks! ________________________________________ Many nights we've prayed with no proof anyone could hear, we were moving moutains long before we knew we could! Yet now i'm standing here, although we know there's much to fear, hope seemed like summer bird too swiftly flown away ... There can be miracles! When you believe, though hope is frail, it's hard to kill! Who knows what miracles, you can achieve! When you believe, somehow you will ... YOU WILL WHEN YOU BELIEVE
In My CvcydcjDoc Class, i have such kind of memory to store data.
class CvcydcjDoc : public CDocument { protected: // create from serialization only CvcydcjDoc(); DECLARE_DYNCREATE(CvcydcjDoc) // Attributes public: struct MEM_MEMORY{ int State;// char szBz[100];// int nCjzcs; // int nSbzcg; // int nZdcjcs; // char szZje[12]; // int nCjcgcs; // int nZdcjcgcs; // int nCjymcs; // int nZdcjsbcs;// char szRowid[20]; char szCjzt[2];// ... }; MEM_MEMORY memRead[2000];
and in my thread, i access data using this way: 1. First i get the Doc pointer:CMainFrame* pMainFrmWnd = (CMainFrame*)AfxGetMainWnd(); ASSERT(pMainFrmWnd != NULL); CvcydcjView* pMyView = NULL; CWnd* pchildWnd = pMainFrmWnd->GetWindow(GW_CHILD); ASSERT(pchildWnd->GetSafeHwnd() != NULL); //while(pchildWnd->GetSafeHwnd() != NULL) //{ // ASSERT(pchildWnd->GetSafeHwnd() != NULL); // if(pchildWnd->GetRuntimeClass()->m_lpszClassName == "CvcydcjView") // { pMyView = (CvcydcjView*)pchildWnd; // break; // } // pchildWnd = pchildWnd->GetWindow(GW_HWNDNEXT); //} ASSERT(pMyView != NULL); CListCtrl* pList = (CListCtrl*)pMyView->getItem(IDC_LIST_DIAL); CListCtrl* pListMsg = (CListCtrl*)pMyView->getItem(IDC_LIST_MESSAGE); CStatic* pCjcount = (CStatic*)pMyView->getItem(IDC_CJCOUNT); CStatic* pCjymcount = (CStatic*)pMyView->getItem(IDC_CJYMCOUNT); CStatic* pCjcgcount = (CStatic*)pMyView->getItem(IDC_CJCGCOUNT); CStatic* pCjcscount = (CStatic*)pMyView->getItem(IDC_CJCSCOUNT); CvcydcjDoc* pMydoc = (CvcydcjDoc*)lp;
then i manipulate that data in this way:... strcpy(pMydoc->memRead[nRecNumber].szCjzjhm,str); ...
i don't know whether it's the problem or not... Hope someone can help me,,, Thx! ________________________________________ Many nights we've prayed with no proof anyone could hear, we were moving moutains long before we knew we could! Yet now i'm standing here, although we know there's much to fear, hope seemed like summer bird too swiftly flown away ... There can be miracles! When you believe, though hope is frail, it's hard to kill! Who knows what miracles, you can achieve! When you believe, somehow you will ... YOU WILL WHEN YOU BELIEVE -
Hi,Everyone: i'm running a program as form-based, Doc/view struct. i create a thread in the initialization of the program, and in thread, we use while(1) circulation. it runs well usually, but we'll get unexpected error dialog, (and program shut down), this is following error infomation: "access violation at 0x00000000: read of address 0x00000000". Process Stopped. Can any one of you give me some suggestions? Thanks! ________________________________________ Many nights we've prayed with no proof anyone could hear, we were moving moutains long before we knew we could! Yet now i'm standing here, although we know there's much to fear, hope seemed like summer bird too swiftly flown away ... There can be miracles! When you believe, though hope is frail, it's hard to kill! Who knows what miracles, you can achieve! When you believe, somehow you will ... YOU WILL WHEN YOU BELIEVE
This kind of error can occur when the instruction pointer (IP) gets confused when returning from a message handler. One way to fix this is to make sure all your custom message handlers are in the format
LRESULT MyClass::OnMyMessage(WPARAM wp, LPARAM lp)
. Make sure you declare both the WPARAM and the LPARAM on all you message handlers even if you think they are not needed. Also have them return LRESULTs not voids. HTH
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
Honoured as one of The Most Helpful Members of 2004
-
This kind of error can occur when the instruction pointer (IP) gets confused when returning from a message handler. One way to fix this is to make sure all your custom message handlers are in the format
LRESULT MyClass::OnMyMessage(WPARAM wp, LPARAM lp)
. Make sure you declare both the WPARAM and the LPARAM on all you message handlers even if you think they are not needed. Also have them return LRESULTs not voids. HTH
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
Honoured as one of The Most Helpful Members of 2004
Thanks,PJ Arends! But in my program i didn't use message handlers :doh: (i planned to use once, but now i didn't use it. Maybe cos i remained the definition?? )
#define WM_OPENRECORD WM_USER + 100 // #define WM_STARTCALL WM_USER + 101 //
and i found i made a stupid mistake:while(1) { pRs = new CADORecordset(pAdoDb); while(DB_CONNECTED) { Dosomething(); if(DB_problem)break; } }
it seemed i forgot to "delete pRs"!while(1) { pRs = new CADORecordset(pAdoDb); while(DB_CONNECTED) { Dosomething(); if(DB_problem)break; } // 20050131 Modified by Dick delete pRs; }
maybe this cause the problem? i'm not sure, now i'm letting the program run and watch whether i get next error. (if i do get, i'll go to ask you again,hope you don't feel it's a trouble ;P ) Thank you sooooooooo much! :) Have a good day!! ________________________________________ Many nights we've prayed with no proof anyone could hear, we were moving moutains long before we knew we could! Yet now i'm standing here, although we know there's much to fear, hope seemed like summer bird too swiftly flown away ... There can be miracles! When you believe, though hope is frail, it's hard to kill! Who knows what miracles, you can achieve! When you believe, somehow you will ... YOU WILL WHEN YOU BELIEVE