1
다른 프로그램의 서식있는 텍스트 상자에서 텍스트를 검색하기 위해 Windows API를 사용해야하는 경우가 있습니다. 나는 평범한 텍스트가 아닌 ... '풍부한 텍스트'를 얻을 수있는 방법이 있는지 궁금합니다.리치 텍스트에서 가져 오는 pinvoke, sendmessagebystring
이 예제에서 ptrHandle은 서식있는 텍스트 제어 핸들입니다.
if (ptrHandle == null)
return null;
if (ptrHandle == IntPtr.Zero)
return null;
IntPtr ptrLength =
SendMessage(ptrHandle, WM_GETTEXTLENGTH, IntPtr.Zero, IntPtr.Zero);
var nLen = ptrLength.ToInt32();
if (nLen <= 0)
return null;
var strBuffer = new System.Text.StringBuilder(nLen + 1);
SendMessage(ptrHandle, WM_GETTEXT, new IntPtr(nLen + 1), strBuffer);
이것은 모두 C#에서 수행됩니다. 텍스트가 잘 나오지만 형식이 없어지는 등의 문제가 있습니다. 내가 그걸 모두 얻을 수 있기를 바랐다.
젠장. 어떤 방법으로 C++ dll에 동작을 래핑하고 .NET에로드 할 수 있습니까? – Ciel