SendMessage and error 0xC0000005
- i have a problem at
program compiles, butcase 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; }
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.
答案
- 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日 20:39
全部回复
pp.user.VideoTimeoutAc what is it?
You got access violation trying to retrieve it.
- pp is global variable, and .user.VideoTimeoutAc one of its parametres
POWER_POLICY pp;
- 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.
- 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 - to fill POWER_POLICY struct i call ReadPwrScheme function.
i think that "(LPCWSTR)" before argument convert argument, or I am not right? - i just disclose variable of POWER_POLICY type...
- are there any other ways to realize a conclution of VideoTimeoutAc to edit control?
- 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日 20:39
- Thx, Nikita L, you helped mr very much.
it's really works...

