Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Please what is wrong with this my MFC code, what am I doing wrong?

Please what is wrong with this my MFC code, what am I doing wrong?

Scheduled Pinned Locked Moved C / C++ / MFC
c++questionjsonhelp
10 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gbenbam
    wrote on last edited by
    #1

    Normally, I code using win32 API. I just moved to MFC. I wrote this MFC code for a wizard but keep getting exceptions thrown. A first chance exception to be precise. My wizard is contained in an MFC extension dll. The wizard is lunch from an handler of CMainFrame. The CMainFrame from which the wizard is lunched is:

    void CMainFrame::OnAddClassInfo()
    {
    CWinApp *pWinApp = AfxGetApp();

    FirstPage firstPage;
    ClassNameA className;
    ClassTerm classTerm;
    ClassSubjects classSubjects;
    ClassStaff classStaff;
    StopPage stopPage;
    
    className.SetAccess(m\_szAccessUsername,m\_szAccessPassword);
    className.SetClassInfo(m\_iClassTypeID, m\_iClassID);
    stopPage.SetClassInfoCombo(&m\_wndToolBar.m\_ArmName,&m\_wndToolBar.m\_ClassName,&m\_wndToolBar.m\_Session);
    
    CString stWizard;
    stWizard.LoadString(pWinApp->m\_hInstance,IDS\_CLASSINFO\_WIZARD,(WORD)LANGUAGE);
    
    ClassInfo ClassInfoWizard(stWizard,this);
    
    firstPage.SetPointer(reinterpret\_cast(&ClassInfoWizard));
    className.SetPointer(reinterpret\_cast(&ClassInfoWizard));
    classTerm.SetPointer(reinterpret\_cast(&ClassInfoWizard));
    classSubjects.SetPointer(reinterpret\_cast(&ClassInfoWizard));
    classStaff.SetPointer(reinterpret\_cast(&ClassInfoWizard));
    stopPage.SetPointer(reinterpret\_cast(&ClassInfoWizard));
    
    
    ClassInfoWizard.AddPage(&firstPage);
    ClassInfoWizard.AddPage(&className);
    ClassInfoWizard.AddPage(&classTerm);
    ClassInfoWizard.AddPage(&classSubjects);
    ClassInfoWizard.AddPage(&classStaff);
    ClassInfoWizard.AddPage(&stopPage);
    
    ClassInfoWizard.SetWizardMode();
    if(ClassInfoWizard.DoModal() == ID\_WIZFINISH)
    {
    	m\_eClassInfoView\_State = ENABLE;
    	m\_eClassInfoChange\_State = ENABLE;
    
    	m\_eStudentInfoAdd\_State = ENABLE;
    
    	m\_eGradeInfoAdd\_State = ENABLE;
    }
    

    }

    The output window show the following error messages: First-chance exception at 0xfefefefe in SchPedestal.exe: 0xC0000005: Access violation. Unhandled exception at 0xfefefefe in SchPedestal.exe: 0xC0000005: Access violation. The program '[1456] SchPedestal.exe: Native' has exited with code -1073741819 (0xc0000005). Note: ClassInfo inherits from CPropertySheet, while the other objects inherit from CPropertyPage.

    J D 3 Replies Last reply
    0
    • G Gbenbam

      Normally, I code using win32 API. I just moved to MFC. I wrote this MFC code for a wizard but keep getting exceptions thrown. A first chance exception to be precise. My wizard is contained in an MFC extension dll. The wizard is lunch from an handler of CMainFrame. The CMainFrame from which the wizard is lunched is:

      void CMainFrame::OnAddClassInfo()
      {
      CWinApp *pWinApp = AfxGetApp();

      FirstPage firstPage;
      ClassNameA className;
      ClassTerm classTerm;
      ClassSubjects classSubjects;
      ClassStaff classStaff;
      StopPage stopPage;
      
      className.SetAccess(m\_szAccessUsername,m\_szAccessPassword);
      className.SetClassInfo(m\_iClassTypeID, m\_iClassID);
      stopPage.SetClassInfoCombo(&m\_wndToolBar.m\_ArmName,&m\_wndToolBar.m\_ClassName,&m\_wndToolBar.m\_Session);
      
      CString stWizard;
      stWizard.LoadString(pWinApp->m\_hInstance,IDS\_CLASSINFO\_WIZARD,(WORD)LANGUAGE);
      
      ClassInfo ClassInfoWizard(stWizard,this);
      
      firstPage.SetPointer(reinterpret\_cast(&ClassInfoWizard));
      className.SetPointer(reinterpret\_cast(&ClassInfoWizard));
      classTerm.SetPointer(reinterpret\_cast(&ClassInfoWizard));
      classSubjects.SetPointer(reinterpret\_cast(&ClassInfoWizard));
      classStaff.SetPointer(reinterpret\_cast(&ClassInfoWizard));
      stopPage.SetPointer(reinterpret\_cast(&ClassInfoWizard));
      
      
      ClassInfoWizard.AddPage(&firstPage);
      ClassInfoWizard.AddPage(&className);
      ClassInfoWizard.AddPage(&classTerm);
      ClassInfoWizard.AddPage(&classSubjects);
      ClassInfoWizard.AddPage(&classStaff);
      ClassInfoWizard.AddPage(&stopPage);
      
      ClassInfoWizard.SetWizardMode();
      if(ClassInfoWizard.DoModal() == ID\_WIZFINISH)
      {
      	m\_eClassInfoView\_State = ENABLE;
      	m\_eClassInfoChange\_State = ENABLE;
      
      	m\_eStudentInfoAdd\_State = ENABLE;
      
      	m\_eGradeInfoAdd\_State = ENABLE;
      }
      

      }

      The output window show the following error messages: First-chance exception at 0xfefefefe in SchPedestal.exe: 0xC0000005: Access violation. Unhandled exception at 0xfefefefe in SchPedestal.exe: 0xC0000005: Access violation. The program '[1456] SchPedestal.exe: Native' has exited with code -1073741819 (0xc0000005). Note: ClassInfo inherits from CPropertySheet, while the other objects inherit from CPropertyPage.

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      Please edit your post and remove at least the repeated lines, or better all message lines except the first two exceptions. The other lines are not related to your problem.

      G 1 Reply Last reply
      0
      • G Gbenbam

        Normally, I code using win32 API. I just moved to MFC. I wrote this MFC code for a wizard but keep getting exceptions thrown. A first chance exception to be precise. My wizard is contained in an MFC extension dll. The wizard is lunch from an handler of CMainFrame. The CMainFrame from which the wizard is lunched is:

        void CMainFrame::OnAddClassInfo()
        {
        CWinApp *pWinApp = AfxGetApp();

        FirstPage firstPage;
        ClassNameA className;
        ClassTerm classTerm;
        ClassSubjects classSubjects;
        ClassStaff classStaff;
        StopPage stopPage;
        
        className.SetAccess(m\_szAccessUsername,m\_szAccessPassword);
        className.SetClassInfo(m\_iClassTypeID, m\_iClassID);
        stopPage.SetClassInfoCombo(&m\_wndToolBar.m\_ArmName,&m\_wndToolBar.m\_ClassName,&m\_wndToolBar.m\_Session);
        
        CString stWizard;
        stWizard.LoadString(pWinApp->m\_hInstance,IDS\_CLASSINFO\_WIZARD,(WORD)LANGUAGE);
        
        ClassInfo ClassInfoWizard(stWizard,this);
        
        firstPage.SetPointer(reinterpret\_cast(&ClassInfoWizard));
        className.SetPointer(reinterpret\_cast(&ClassInfoWizard));
        classTerm.SetPointer(reinterpret\_cast(&ClassInfoWizard));
        classSubjects.SetPointer(reinterpret\_cast(&ClassInfoWizard));
        classStaff.SetPointer(reinterpret\_cast(&ClassInfoWizard));
        stopPage.SetPointer(reinterpret\_cast(&ClassInfoWizard));
        
        
        ClassInfoWizard.AddPage(&firstPage);
        ClassInfoWizard.AddPage(&className);
        ClassInfoWizard.AddPage(&classTerm);
        ClassInfoWizard.AddPage(&classSubjects);
        ClassInfoWizard.AddPage(&classStaff);
        ClassInfoWizard.AddPage(&stopPage);
        
        ClassInfoWizard.SetWizardMode();
        if(ClassInfoWizard.DoModal() == ID\_WIZFINISH)
        {
        	m\_eClassInfoView\_State = ENABLE;
        	m\_eClassInfoChange\_State = ENABLE;
        
        	m\_eStudentInfoAdd\_State = ENABLE;
        
        	m\_eGradeInfoAdd\_State = ENABLE;
        }
        

        }

        The output window show the following error messages: First-chance exception at 0xfefefefe in SchPedestal.exe: 0xC0000005: Access violation. Unhandled exception at 0xfefefefe in SchPedestal.exe: 0xC0000005: Access violation. The program '[1456] SchPedestal.exe: Native' has exited with code -1073741819 (0xc0000005). Note: ClassInfo inherits from CPropertySheet, while the other objects inherit from CPropertyPage.

        J Offline
        J Offline
        Jochen Arndt
        wrote on last edited by
        #3

        If you expect the error to be in the posted code, set a breakpoint on top and use the debugger to step through the instructions until the error occurs. Then check your variables to find out which is generating the access violation.

        1 Reply Last reply
        0
        • G Gbenbam

          Normally, I code using win32 API. I just moved to MFC. I wrote this MFC code for a wizard but keep getting exceptions thrown. A first chance exception to be precise. My wizard is contained in an MFC extension dll. The wizard is lunch from an handler of CMainFrame. The CMainFrame from which the wizard is lunched is:

          void CMainFrame::OnAddClassInfo()
          {
          CWinApp *pWinApp = AfxGetApp();

          FirstPage firstPage;
          ClassNameA className;
          ClassTerm classTerm;
          ClassSubjects classSubjects;
          ClassStaff classStaff;
          StopPage stopPage;
          
          className.SetAccess(m\_szAccessUsername,m\_szAccessPassword);
          className.SetClassInfo(m\_iClassTypeID, m\_iClassID);
          stopPage.SetClassInfoCombo(&m\_wndToolBar.m\_ArmName,&m\_wndToolBar.m\_ClassName,&m\_wndToolBar.m\_Session);
          
          CString stWizard;
          stWizard.LoadString(pWinApp->m\_hInstance,IDS\_CLASSINFO\_WIZARD,(WORD)LANGUAGE);
          
          ClassInfo ClassInfoWizard(stWizard,this);
          
          firstPage.SetPointer(reinterpret\_cast(&ClassInfoWizard));
          className.SetPointer(reinterpret\_cast(&ClassInfoWizard));
          classTerm.SetPointer(reinterpret\_cast(&ClassInfoWizard));
          classSubjects.SetPointer(reinterpret\_cast(&ClassInfoWizard));
          classStaff.SetPointer(reinterpret\_cast(&ClassInfoWizard));
          stopPage.SetPointer(reinterpret\_cast(&ClassInfoWizard));
          
          
          ClassInfoWizard.AddPage(&firstPage);
          ClassInfoWizard.AddPage(&className);
          ClassInfoWizard.AddPage(&classTerm);
          ClassInfoWizard.AddPage(&classSubjects);
          ClassInfoWizard.AddPage(&classStaff);
          ClassInfoWizard.AddPage(&stopPage);
          
          ClassInfoWizard.SetWizardMode();
          if(ClassInfoWizard.DoModal() == ID\_WIZFINISH)
          {
          	m\_eClassInfoView\_State = ENABLE;
          	m\_eClassInfoChange\_State = ENABLE;
          
          	m\_eStudentInfoAdd\_State = ENABLE;
          
          	m\_eGradeInfoAdd\_State = ENABLE;
          }
          

          }

          The output window show the following error messages: First-chance exception at 0xfefefefe in SchPedestal.exe: 0xC0000005: Access violation. Unhandled exception at 0xfefefefe in SchPedestal.exe: 0xC0000005: Access violation. The program '[1456] SchPedestal.exe: Native' has exited with code -1073741819 (0xc0000005). Note: ClassInfo inherits from CPropertySheet, while the other objects inherit from CPropertyPage.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Your page variables (i.e., the ones used by AddPage()) should be members of CMainFrame, not local to OnAddClassInfo(). What type of object is ClassInfo? Other than that, you need to step through the code using the debugger. You might be better served by letting the MFC framework create a wizard-based app for you. You can customize it from there.

          "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

          "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

          G 1 Reply Last reply
          0
          • J Jochen Arndt

            Please edit your post and remove at least the repeated lines, or better all message lines except the first two exceptions. The other lines are not related to your problem.

            G Offline
            G Offline
            Gbenbam
            wrote on last edited by
            #5

            How do I edit my post? I'd like to but do not know how to go about it.

            J 1 Reply Last reply
            0
            • D David Crow

              Your page variables (i.e., the ones used by AddPage()) should be members of CMainFrame, not local to OnAddClassInfo(). What type of object is ClassInfo? Other than that, you need to step through the code using the debugger. You might be better served by letting the MFC framework create a wizard-based app for you. You can customize it from there.

              "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

              "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

              G Offline
              G Offline
              Gbenbam
              wrote on last edited by
              #6

              ClassInfo inherits from CPropertyPage, while the other objects inherit from CPropertyPage. The program successfully displays the wizards start page, but once I click next, this access violation occurs Debugging shows that the access violation occurred in the following function:

              int ClassName::LoadSchoolName()
              {
              CComboBox *pSchoolName = (CComboBox *)GetDlgItem(IDC_COMBO1);

              char szString\[100\];
              TCHAR szString1\[100\];
              INT\_PTR iSchInfoID;
              		
              try
              {
              	//Get database path
              	char szDatabaseFile\[100\];
              	GetDatabaseA(szDatabaseFile,sizeof(szDatabaseFile));
              	
                  //open database
              	CppA::CppSQLite3DB db;
              	db.open(szDatabaseFile);
              		
              	StringCbCopyA(szString,sizeof(szString),"SELECT SchInfoID,SchName,SchCity,SchState,SchCountry FROM SchInfo");
              	CppA::CppSQLite3Query q  = db.execQuery(szString);
              	if(q.fieldIsNull(0))
              	{
              		return 0;
              	}
              	
              	//Gets first row
              	//q.First();
              	
              	size\_t size;
              	const char \*p;
              	
              	 while (!q.eof())
              	 {
              		 TCHAR szMySchName\[50\],szMySchCity\[20\],szMySchState\[20\],szMySchCountry\[20\];
              		 long long iSchoolInfoID;
              
              		 for (int fld = 0; fld < q.numFields(); fld++)
              		 {
              		
              			 switch(fld)
              			 {
              			 case 0:
              				 {
              		
              					iSchoolInfoID = q.getInt64Field(0);
              					
              				 }
              				 break;
              			 case 1:
              				 {
              					p = q.getStringField(1);
              					DecryptString(const\_cast(p),szString);
              					mbstowcs\_s(&size,szString1,sizeof szString1,szString,lstrlenA(szString));
              					StringCbCopy(szMySchName,sizeof(szMySchName),szString1);
              
              				 }
              				 break;
              			 case 2:
              				 {
              
              					p = q.getStringField(2);
              					DecryptString(const\_cast(p),szString);
              					mbstowcs\_s(&size,szString1,sizeof(szString1),szString,lstrlenA(szString));
              					StringCbCopy(szMySchCity,sizeof(szMySchCity),szString1);
              				 }
              				 break;
              			 case 3:
              				 {
              					p = q.getStringField(3);
              					DecryptString(const\_cast(p),szString);
              					mbstowcs\_s(&size,szString1,sizeof(szString1),szString,lstrlenA(szString));
              					StringCbCopy(szMySchState,sizeof(szMySchState),szString1);
              
              				 }
              				 break;
              			 case 4:
              				 {
              					p = q.getStringField(4);
              					DecryptString(const\_cast(p),szString);
              					mbstowcs\_s(&size,szString1,sizeof(szString1),szString,lstrlenA(szString));
              					StringCbCopy(szMySchCountry,sizeof(szMySchCountry),szString1);
              
              				 }
              				 break;
              			 }
              		 }
              
              		TCHAR szSchoolName\[100\];
              		StringCbPrintf(szSchoolName,sizeof szSchoolName,\_T("%s,%s,%s,%s"),szMySch
              
              F L 2 Replies Last reply
              0
              • G Gbenbam

                How do I edit my post? I'd like to but do not know how to go about it.

                J Offline
                J Offline
                Jochen Arndt
                wrote on last edited by
                #7

                Below each post are some links like Reply, Email, .... If you are on your own post, there are two additional links: Edit and Delete.

                1 Reply Last reply
                0
                • G Gbenbam

                  ClassInfo inherits from CPropertyPage, while the other objects inherit from CPropertyPage. The program successfully displays the wizards start page, but once I click next, this access violation occurs Debugging shows that the access violation occurred in the following function:

                  int ClassName::LoadSchoolName()
                  {
                  CComboBox *pSchoolName = (CComboBox *)GetDlgItem(IDC_COMBO1);

                  char szString\[100\];
                  TCHAR szString1\[100\];
                  INT\_PTR iSchInfoID;
                  		
                  try
                  {
                  	//Get database path
                  	char szDatabaseFile\[100\];
                  	GetDatabaseA(szDatabaseFile,sizeof(szDatabaseFile));
                  	
                      //open database
                  	CppA::CppSQLite3DB db;
                  	db.open(szDatabaseFile);
                  		
                  	StringCbCopyA(szString,sizeof(szString),"SELECT SchInfoID,SchName,SchCity,SchState,SchCountry FROM SchInfo");
                  	CppA::CppSQLite3Query q  = db.execQuery(szString);
                  	if(q.fieldIsNull(0))
                  	{
                  		return 0;
                  	}
                  	
                  	//Gets first row
                  	//q.First();
                  	
                  	size\_t size;
                  	const char \*p;
                  	
                  	 while (!q.eof())
                  	 {
                  		 TCHAR szMySchName\[50\],szMySchCity\[20\],szMySchState\[20\],szMySchCountry\[20\];
                  		 long long iSchoolInfoID;
                  
                  		 for (int fld = 0; fld < q.numFields(); fld++)
                  		 {
                  		
                  			 switch(fld)
                  			 {
                  			 case 0:
                  				 {
                  		
                  					iSchoolInfoID = q.getInt64Field(0);
                  					
                  				 }
                  				 break;
                  			 case 1:
                  				 {
                  					p = q.getStringField(1);
                  					DecryptString(const\_cast(p),szString);
                  					mbstowcs\_s(&size,szString1,sizeof szString1,szString,lstrlenA(szString));
                  					StringCbCopy(szMySchName,sizeof(szMySchName),szString1);
                  
                  				 }
                  				 break;
                  			 case 2:
                  				 {
                  
                  					p = q.getStringField(2);
                  					DecryptString(const\_cast(p),szString);
                  					mbstowcs\_s(&size,szString1,sizeof(szString1),szString,lstrlenA(szString));
                  					StringCbCopy(szMySchCity,sizeof(szMySchCity),szString1);
                  				 }
                  				 break;
                  			 case 3:
                  				 {
                  					p = q.getStringField(3);
                  					DecryptString(const\_cast(p),szString);
                  					mbstowcs\_s(&size,szString1,sizeof(szString1),szString,lstrlenA(szString));
                  					StringCbCopy(szMySchState,sizeof(szMySchState),szString1);
                  
                  				 }
                  				 break;
                  			 case 4:
                  				 {
                  					p = q.getStringField(4);
                  					DecryptString(const\_cast(p),szString);
                  					mbstowcs\_s(&size,szString1,sizeof(szString1),szString,lstrlenA(szString));
                  					StringCbCopy(szMySchCountry,sizeof(szMySchCountry),szString1);
                  
                  				 }
                  				 break;
                  			 }
                  		 }
                  
                  		TCHAR szSchoolName\[100\];
                  		StringCbPrintf(szSchoolName,sizeof szSchoolName,\_T("%s,%s,%s,%s"),szMySch
                  
                  F Offline
                  F Offline
                  Freak30
                  wrote on last edited by
                  #8

                  You are formatting quite a lot of things into the school name. Maybe you create more than 100 characters and the StringCbPrintf() doesn't add the terminating \0 character in that case. You could try szSchoolName[99] = 0; before calling AddString() and see if that changes anything.

                  The good thing about pessimism is, that you are always either right or pleasently surprised.

                  1 Reply Last reply
                  0
                  • G Gbenbam

                    ClassInfo inherits from CPropertyPage, while the other objects inherit from CPropertyPage. The program successfully displays the wizards start page, but once I click next, this access violation occurs Debugging shows that the access violation occurred in the following function:

                    int ClassName::LoadSchoolName()
                    {
                    CComboBox *pSchoolName = (CComboBox *)GetDlgItem(IDC_COMBO1);

                    char szString\[100\];
                    TCHAR szString1\[100\];
                    INT\_PTR iSchInfoID;
                    		
                    try
                    {
                    	//Get database path
                    	char szDatabaseFile\[100\];
                    	GetDatabaseA(szDatabaseFile,sizeof(szDatabaseFile));
                    	
                        //open database
                    	CppA::CppSQLite3DB db;
                    	db.open(szDatabaseFile);
                    		
                    	StringCbCopyA(szString,sizeof(szString),"SELECT SchInfoID,SchName,SchCity,SchState,SchCountry FROM SchInfo");
                    	CppA::CppSQLite3Query q  = db.execQuery(szString);
                    	if(q.fieldIsNull(0))
                    	{
                    		return 0;
                    	}
                    	
                    	//Gets first row
                    	//q.First();
                    	
                    	size\_t size;
                    	const char \*p;
                    	
                    	 while (!q.eof())
                    	 {
                    		 TCHAR szMySchName\[50\],szMySchCity\[20\],szMySchState\[20\],szMySchCountry\[20\];
                    		 long long iSchoolInfoID;
                    
                    		 for (int fld = 0; fld < q.numFields(); fld++)
                    		 {
                    		
                    			 switch(fld)
                    			 {
                    			 case 0:
                    				 {
                    		
                    					iSchoolInfoID = q.getInt64Field(0);
                    					
                    				 }
                    				 break;
                    			 case 1:
                    				 {
                    					p = q.getStringField(1);
                    					DecryptString(const\_cast(p),szString);
                    					mbstowcs\_s(&size,szString1,sizeof szString1,szString,lstrlenA(szString));
                    					StringCbCopy(szMySchName,sizeof(szMySchName),szString1);
                    
                    				 }
                    				 break;
                    			 case 2:
                    				 {
                    
                    					p = q.getStringField(2);
                    					DecryptString(const\_cast(p),szString);
                    					mbstowcs\_s(&size,szString1,sizeof(szString1),szString,lstrlenA(szString));
                    					StringCbCopy(szMySchCity,sizeof(szMySchCity),szString1);
                    				 }
                    				 break;
                    			 case 3:
                    				 {
                    					p = q.getStringField(3);
                    					DecryptString(const\_cast(p),szString);
                    					mbstowcs\_s(&size,szString1,sizeof(szString1),szString,lstrlenA(szString));
                    					StringCbCopy(szMySchState,sizeof(szMySchState),szString1);
                    
                    				 }
                    				 break;
                    			 case 4:
                    				 {
                    					p = q.getStringField(4);
                    					DecryptString(const\_cast(p),szString);
                    					mbstowcs\_s(&size,szString1,sizeof(szString1),szString,lstrlenA(szString));
                    					StringCbCopy(szMySchCountry,sizeof(szMySchCountry),szString1);
                    
                    				 }
                    				 break;
                    			 }
                    		 }
                    
                    		TCHAR szSchoolName\[100\];
                    		StringCbPrintf(szSchoolName,sizeof szSchoolName,\_T("%s,%s,%s,%s"),szMySch
                    
                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    You seem to be mixing char and TCHAR somewhat indiscriminately, and you should not be using TCHAR as the destination of mbstowcs_s. This may well be where you are going wrong.

                    G 1 Reply Last reply
                    0
                    • L Lost User

                      You seem to be mixing char and TCHAR somewhat indiscriminately, and you should not be using TCHAR as the destination of mbstowcs_s. This may well be where you are going wrong.

                      G Offline
                      G Offline
                      Gbenbam
                      wrote on last edited by
                      #10

                      I found out the problem. I passed the size of the wide-char buffer in bytes to mbstowcs_s rather than the size in WORDS. Immediately I corrected this, everything started working fine. Thanks a lot.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups