CStringArray problem
-
Hi all, I have a trouble with CStringArray class, it is so difficult to me that I'd like to get help from you. My project has a DLL and a Exe file. In the DLL, threre is a function that used to get a list of strings, I use CStringArray to get the list strings. For example : __declspec( dllexport ) void GetCStringArr(CStringArray* pCStringArr) { CString cstrText; for (int i=0; i< 100;i++) { cstrText.Format("%d",i); pCStringArr->SetAtGrow(i,cstrText); } } In the application project, I call GetCStringArr function to get the list string, after calling GetCStringArr function, I have the needed list string and can access all strings in the list(CStringArray),everthing is OK but when I release the CStringArray object, my project has a exception : // m_ArrText is a CStringArray object, it is a member variant of //CTestCstringArrDlg class void CTestCstringArrDlg::OnGetButton() { GetCStringArr(&m_ArrText); for (int i=0;i<10;i++) { MessageBox(m_ArrText.GetAt(i)); } CTestCstringArrDlg.RemoveAll(); // This line code has exception } If I declare, use and release CStringArray variant in only application or only in Dll, everything is OK. I don't known why when I declare CStringArray in App but add it's item string in Dll, I can get all Item string in CStringArray but when I release CStringArray I alway have problem. Please help me to solve the problem!:(
-
Hi all, I have a trouble with CStringArray class, it is so difficult to me that I'd like to get help from you. My project has a DLL and a Exe file. In the DLL, threre is a function that used to get a list of strings, I use CStringArray to get the list strings. For example : __declspec( dllexport ) void GetCStringArr(CStringArray* pCStringArr) { CString cstrText; for (int i=0; i< 100;i++) { cstrText.Format("%d",i); pCStringArr->SetAtGrow(i,cstrText); } } In the application project, I call GetCStringArr function to get the list string, after calling GetCStringArr function, I have the needed list string and can access all strings in the list(CStringArray),everthing is OK but when I release the CStringArray object, my project has a exception : // m_ArrText is a CStringArray object, it is a member variant of //CTestCstringArrDlg class void CTestCstringArrDlg::OnGetButton() { GetCStringArr(&m_ArrText); for (int i=0;i<10;i++) { MessageBox(m_ArrText.GetAt(i)); } CTestCstringArrDlg.RemoveAll(); // This line code has exception } If I declare, use and release CStringArray variant in only application or only in Dll, everything is OK. I don't known why when I declare CStringArray in App but add it's item string in Dll, I can get all Item string in CStringArray but when I release CStringArray I alway have problem. Please help me to solve the problem!:(
-
Hi all, I have a trouble with CStringArray class, it is so difficult to me that I'd like to get help from you. My project has a DLL and a Exe file. In the DLL, threre is a function that used to get a list of strings, I use CStringArray to get the list strings. For example : __declspec( dllexport ) void GetCStringArr(CStringArray* pCStringArr) { CString cstrText; for (int i=0; i< 100;i++) { cstrText.Format("%d",i); pCStringArr->SetAtGrow(i,cstrText); } } In the application project, I call GetCStringArr function to get the list string, after calling GetCStringArr function, I have the needed list string and can access all strings in the list(CStringArray),everthing is OK but when I release the CStringArray object, my project has a exception : // m_ArrText is a CStringArray object, it is a member variant of //CTestCstringArrDlg class void CTestCstringArrDlg::OnGetButton() { GetCStringArr(&m_ArrText); for (int i=0;i<10;i++) { MessageBox(m_ArrText.GetAt(i)); } CTestCstringArrDlg.RemoveAll(); // This line code has exception } If I declare, use and release CStringArray variant in only application or only in Dll, everything is OK. I don't known why when I declare CStringArray in App but add it's item string in Dll, I can get all Item string in CStringArray but when I release CStringArray I alway have problem. Please help me to solve the problem!:(
It might be because of the EXE and DLL being built with different options or defines... Does
sizeof(CString)
give the same result in both the EXE and DLL? -- jlr http://jlamas.blogspot.com/[^] -
Thanks for your help, I have tried to do as your comment, it is useful for me and is my need. Thank you very much.:)
-
Hi all, I have a trouble with CStringArray class, it is so difficult to me that I'd like to get help from you. My project has a DLL and a Exe file. In the DLL, threre is a function that used to get a list of strings, I use CStringArray to get the list strings. For example : __declspec( dllexport ) void GetCStringArr(CStringArray* pCStringArr) { CString cstrText; for (int i=0; i< 100;i++) { cstrText.Format("%d",i); pCStringArr->SetAtGrow(i,cstrText); } } In the application project, I call GetCStringArr function to get the list string, after calling GetCStringArr function, I have the needed list string and can access all strings in the list(CStringArray),everthing is OK but when I release the CStringArray object, my project has a exception : // m_ArrText is a CStringArray object, it is a member variant of //CTestCstringArrDlg class void CTestCstringArrDlg::OnGetButton() { GetCStringArr(&m_ArrText); for (int i=0;i<10;i++) { MessageBox(m_ArrText.GetAt(i)); } CTestCstringArrDlg.RemoveAll(); // This line code has exception } If I declare, use and release CStringArray variant in only application or only in Dll, everything is OK. I don't known why when I declare CStringArray in App but add it's item string in Dll, I can get all Item string in CStringArray but when I release CStringArray I alway have problem. Please help me to solve the problem!:(