Я попробовал приложение Compile win32 с Mingw-W64.
, но оно повышает ошибку
undefined reference to __imp_CoCreateInstance' on mingw-w64< /code> < /code>. < /p>
My Mingw-w64, установленная в каталоге C: \ mingw64.
и заданные параметры для компиляции.g++ -L C:\mingw64\x86_64-w64-mingw32\lib -lole32 hello.cpp -o hello
< /code>
Как я могу исправить эту ошибку?#include
#include
#include
#include
#include
#include
#include
#include
HRESULT InitializeUIAutomation(IUIAutomation **ppAutomation)
{
return CoCreateInstance(CLSID_CUIAutomation, NULL,
CLSCTX_INPROC_SERVER, IID_IUIAutomation,
reinterpret_cast(ppAutomation));
}
void show_error(HRESULT hr)
{
if (hr != S_OK)
{
std::string s = std::system_category().message(hr);
const char *err = s.c_str();
printf("%s\n", err);
}
}
int main()
{
printf("Hello world from windows2\n");
IUIAutomation **ppAutomation;
IUIAutomation *pAutomation;
IUIAutomationElement *root;
IUIAutomationElement *start_button;
IUIAutomationElement3 *start_button3;
IUIAutomationCondition *start_button_cond;
VARIANT start_button_v;
wchar_t *start_button_autoid = L"StartButton";
InitializeUIAutomation(ppAutomation);
pAutomation = *ppAutomation;
HRESULT hr = pAutomation->GetRootElement(&root);
show_error(hr);
start_button_v.vt = VT_BSTR;
start_button_v.bstrVal = start_button_autoid;
pAutomation->CreatePropertyCondition(UIA_AutomationIdPropertyId, start_button_v, &start_button_cond);
hr = root->FindFirst(TreeScope_Descendants, start_button_cond, &start_button);
show_error(hr);
start_button3 = reinterpret_cast(start_button);
start_button3->ShowContextMenu();
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... -mingw-w64