틱 이벤트마다 그림 상자에 새 그림을로드하는 VB.NET 양식 응용 프로그램을 만들었습니다. 그러나 내 컴퓨터의 디스플레이가 꺼지면 exe의 메모리 사용이 서서히 올라갑니다. 잠깐 후에 마우스를 움직이면 화면이 정상적으로 갑자기 꺼집니다. 그러나 화면을 끈 상태로두면 메모리 사용량이 계속해서 증가하여 결국 메모리 부족 예외가 발생합니다. 또한 그림 상자 이미지가 큰 빨간색 X가됩니다.화면이 꺼져있을 때 그림 상자 메모리 오버플로
화면이 꺼지는 것을 어떻게 감지합니까? - done
msg에서 POWERBROADCAST_SETTING 구조체 (lParam) 데이터를 어떻게 가져 옵니까?
http://msdn.microsoft.com/en-us/library/aa373247.aspx
http://msdn.microsoft.com/en-us/library/aa372723.aspx
Declare Function RegisterPowerSettingNotification Lib "user32" (ByVal hRecipient As IntPtr, ByRef PowerSettingGuid As Guid, ByVal Flags As Int32) As IntPtr
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim GG As System.Guid
System.Guid.TryParse("02731015-4510-4526-99e6-e5a17ebd1aea", GG)
RegisterPowerSettingNotification(Me.Handle, GG, 0)
'...
End Sub
Protected Overrides Sub WndProc(ByRef msg As System.Windows.Forms.Message)
'MessageBox.Show(msg.Msg)
If msg.WParam = &H8013 Then
Console.WriteLine(msg.ToString)
End If
MyBase.WndProc(msg)
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'code to load some image using PictureBox1.Load()
End Sub
콘솔 출력 :
MSG = 0x218 (WM_POWERBROADCAST) HWND = 0x9108a WPARAM = 0x8013 LPARAM = 0x57f5080 결과 = 0x0으로
MSG = 0x218 (WM_POWERBROADCAST) HWND = 0x9108a WPARAM = 0x8013 LPARAM = 0x57f50e0 결과 = 0x0으로
MSG = 0x218 (WM_POWERBROADCAST) HWND = 0x9108a WPARAM = 0x8013 LPARAM = 0x57f4d20 결과 = 0x0으로
MSG = 0x218 (WM_POWERBROADCAST) HWND = 0x9108a WPARAM = 0x8013 LPARAM = 0x57f5020 결과 = 0x0으로 01,238의 MSG = 0x218 (WM_POWERBROADCAST) HWND = 0x9108a WPARAM = 0x8013 LPARAM = 0x57f4d60 결과 = 0x0으로
MSG = 0x218 (WM_POWERBROADCAST) HWND = 0x9108a WPARAM = 0x8013 LPARAM = 0x57f5180 결과 = 0x0으로
서식 미안 .. .just이 사이트에 가입했습니다.
편집 : 이것은 작동하는 것 같습니다.
Public Structure PB_S
Public PowerSetting As Guid
Public DataLength As UInteger 'dword (32-bit unsigned int)
Public Data As Byte 'uchar
End Structure
Dim P_inst As PB_S
P_inst = CType(Marshal.PtrToStructure(msg.LParam, GetType(PB_S)), PB_S)
콘솔 P_inst의 재료를 프린트 :
MSG = 0x218 (WM_POWERBROADCAST) HWND = 0x14a10fe WPARAM = 0x8013 LPARAM = 0x295048 결과 = 0x0으로
0
4
02731015-4510-4526 -99e6-e5a17ebd1aea
MSG = 0x218 (WM_POWERBROADCAST) HWND = 0x14a10fe WPARAM = 0x8013 LPARAM = 0x295048 결과 = 0x0으로
1
01,235,4
02731015-4510-4526-99e6-e5a17ebd1aea
일부 코드는 아마도? –