forked from Public-Mirror/Textractor
add error handling in clipboard copier
This commit is contained in:
parent
c39356473d
commit
1d17902c64
@ -4,12 +4,12 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
|||||||
{
|
{
|
||||||
if (sentenceInfo["current select"] && sentenceInfo["hook address"] != -1)
|
if (sentenceInfo["current select"] && sentenceInfo["hook address"] != -1)
|
||||||
{
|
{
|
||||||
|
if (!OpenClipboard(FindWindowW(NULL, L"Textractor"))) return false;
|
||||||
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, (sentence.size() + 2) * sizeof(wchar_t));
|
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, (sentence.size() + 2) * sizeof(wchar_t));
|
||||||
memcpy(GlobalLock(hMem), sentence.c_str(), (sentence.size() + 2) * sizeof(wchar_t));
|
memcpy(GlobalLock(hMem), sentence.c_str(), (sentence.size() + 2) * sizeof(wchar_t));
|
||||||
GlobalUnlock(hMem);
|
|
||||||
OpenClipboard(0);
|
|
||||||
EmptyClipboard();
|
EmptyClipboard();
|
||||||
SetClipboardData(CF_UNICODETEXT, hMem);
|
SetClipboardData(CF_UNICODETEXT, hMem);
|
||||||
|
GlobalUnlock(hMem);
|
||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user