에 의해 체포되지 않은 : et Wi ndow Te xt는() 오류를 던지고 나는 내부 예외로 던진 다음 오류 얻을 et Wi ndow Te xt는 아래의 코드를 실행하면 시도/캐치
가 { "보호 된 메모리를 읽거나 쓰려고 시도합니다. 이것은 종종 다른 메모리가 손상되었음을 나타냅니다 "} 나는이 개 질문이[DllImport("user32.dll", EntryPoint = "GetWindowTextLength", SetLastError = true)]
internal static extern int GetWindowTextLength(IntPtr hwnd);
[DllImport("user32.dll", EntryPoint = "GetWindowText", SetLastError = true)]
internal static extern int GetWindowText(IntPtr hwnd, ref StringBuilder wndTxt, int MaxCount);
try{
int strLength = NativeMethods.GetWindowTextLength(wndHandle);
var wndStr = new StringBuilder(strLength);
GetWindowText(wndHandle, ref wndStr, wndStr.Capacity);
}
catch(Exception e){ LogError(e) }
:.
- 왜 오류가 시도 캐치에 의해 체포되지 않는를?
는 이러한 외부 메소드를 호출하기 때문에 문제를 일으키는 것을 시도/캐치
건배
catch (예외 e)를 잡아서는 안됩니까? – hatchet
예, 질문에 오타가 있습니다. –
GetWindowTExt (wndHandle, wndStr, wndStr.Capacity)를 시도 할 수 있습니까? 또한 NativeMethods.GetWindowTextLength (wndHandle)가 예외를 throw하는 것일 수 있습니까? – hatchet