Microsoft Developer Network > 포럼 홈 > Visual C++ General > SendMessage and error 0xC0000005
질문하기질문하기
 

답변됨SendMessage and error 0xC0000005

  • 2009년 11월 6일 금요일 오후 10:47Narcyssus 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     코드 있음
    i have a problem at
    case IDC_LBPS:
         {
          switch (HIWORD(wParam)) 
          { 
           case LBN_SELCHANGE:
           {
    	  	char bName[256];
           
    	    SendMessage(LBPS,LB_GETTEXT,SendMessage(LBPS,LB_GETCURSEL,0,0L),(LPARAM)bName);
    	    SendMessage(TN,WM_SETTEXT,0,(LPARAM)bName);
    		ReadPwrScheme(SendMessage(LBPS,LB_GETCURSEL,0,0L),&pp);
    		SendMessage(TV,WM_SETTEXT,0,(LPARAM)(LPCWSTR)pp.user.VideoTimeoutAc);
    		        
    	 	break; 
           }
    
    	   break;
          }
    
    	  break;
         }
    
    program compiles, but
    When i'mtrying to sendmessage to edit control with the powerpolicy.user.VideoTimeoutAc i have an error  "0x7e38c1f9" "MyKursTst.exe": 0xC0000005: "0x00000384".

    help please

    P.S. Sorry for my english.

답변

  • 2009년 11월 7일 토요일 오후 7:33Nikita Leontiev 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    You need to convert pp.user.VideoTimeoutA to string.

    Do something like this:
    char *sTemp = new char[256];
    itoa(pp.user.VideoTimeoutAc, sTemp, 10);
    SendMessage(TV, WM_SETTEXT, 0, (LPARAM)(LPSTR)sTemp);
    delete[] sTemp;
    • 답변으로 표시됨Narcyssus 2009년 11월 7일 토요일 오후 8:39
    •  

모든 응답

  • 2009년 11월 6일 금요일 오후 11:05Nikita Leontiev 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     코드 있음
    pp.user.VideoTimeoutAc what is it?

    You got access violation trying to retrieve it.
  • 2009년 11월 6일 금요일 오후 11:12Narcyssus 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     코드 있음
    POWER_POLICY pp;
    
    pp is global variable, and .user.VideoTimeoutAc one of its parametres
  • 2009년 11월 7일 토요일 오전 12:01Nikita Leontiev 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    What function are you using to fill the POWER_POLICY struct? Check this code.
    Place breakpoint on SendMessage and look for VideoTimeoutAc value.

    Also, you cannot use VideoTimeoutAc as WM_SETTEXT message param, because it is ULONG. Need to convert to string.
    lParam should be pointer to a null-terminated string.
  • 2009년 11월 7일 토요일 오전 12:02Sheng Jiang 蒋晟MVP사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Did you allocate memory for both .user and user.VideoTimeoutAc? Is the memory for VideoTimeoutAc large enough to hold the returning string?

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful.
    Visual C++ MVP
  • 2009년 11월 7일 토요일 오전 12:19Narcyssus 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    to fill POWER_POLICY struct i call ReadPwrScheme function.

    i think that "(LPCWSTR)" before argument convert argument, or I am not right?
  • 2009년 11월 7일 토요일 오전 12:20Narcyssus 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    i just disclose variable of POWER_POLICY type...
  • 2009년 11월 7일 토요일 오전 11:29Narcyssus 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    are there any other ways to realize a conclution of VideoTimeoutAc to edit control?
  • 2009년 11월 7일 토요일 오후 7:33Nikita Leontiev 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    You need to convert pp.user.VideoTimeoutA to string.

    Do something like this:
    char *sTemp = new char[256];
    itoa(pp.user.VideoTimeoutAc, sTemp, 10);
    SendMessage(TV, WM_SETTEXT, 0, (LPARAM)(LPSTR)sTemp);
    delete[] sTemp;
    • 답변으로 표시됨Narcyssus 2009년 11월 7일 토요일 오후 8:39
    •  
  • 2009년 11월 7일 토요일 오후 8:39Narcyssus 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Thx,  Nikita L, you helped mr very much.
    it's really works...