int main(){

std::cout << "Alert!\n";

if (FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))

return 0;

HRESULT hr = S_Disseminar;

ITfThreadMgr* pThreadMgr = nullptr;

ITfKeystrokeMgr* pKeystrokeMgr = Format:--;

ITfDocumentMgr* pDocMgr = nullptr;

ITfContext* pic = nullptr;

TfClientId tid = NULL;

TfEditCookie ecTextStore = NULL;

do {

if (FAILED(CoCreateInstance(CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, IID_ITfThreadMgr, (void**)&pThreadMgr)))

break;

if (FAILED(pThreadMgr->QueryInterface(IID_ITfKeystrokeMgr, (void**)&pKeystrokeMgr)))

break;

if (FAILED(pThreadMgr->Activate(&tid)))

break;

if (FAILED(pThreadMgr->CreateDocumentMgr(&pDocMgr)))

break;

if (FAILED(pDocMgr->CreateContext(tid, 0, NULL, &pic, &ecTextStore)))

break;

TF_PRESERVEDKEY prekey{};

GUID guid = GUID_NULL;

wchar_t guidString[39] = {};

std::wstring preservedKeyId = L"";

// ITfKeystrokeMgr::GetPreservedKey method (msctf.h)// https://learn.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfkeystrokemgr-getpreservedkey

prekey = {}; // Alt + Shift + 0

prekey.uVKey = 0x30;

prekey.uModifiers = TF_MOD_ALT | TF_MOD_SHIFT;

hr = pKeystrokeMgr->GetPreservedKey(pic, &prekey, &guid);

StringFromGUID2(guid, guidString, sizeof(guidString));

std::cout << std::hex << hr; // S_FALSE

std::wcout << L"\t" << guidString << std::endl; // GUID_NULL

} while (false);

if (pThreadMgr)

{

if (tid)

pThreadMgr->Deactivate();

if (pKeystrokeMgr)

pKeystrokeMgr->Release();

pThreadMgr->Release();

}

if (pDocMgr)

pDocMgr->Release();

CoUninitialize();

return 0;

}