Skip to content

Instantly share code, notes, and snippets.

@kumatti1
Created January 5, 2016 23:00
Show Gist options
  • Save kumatti1/9b0ca38d319d0e5a4122 to your computer and use it in GitHub Desktop.
Save kumatti1/9b0ca38d319d0e5a4122 to your computer and use it in GitHub Desktop.
ウィザード起動
#include <windows.h>
#include <stdio.h>
#include <comdef.h>
#pragma comment(lib,"ole32.lib")
#pragma comment(lib,"user32.lib")
#define ss L"Microsoft.Display"
interface IUnk : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE Func(LPWSTR s, int arg1, int arg2, int arg3) = 0;
};
CLSID clsid = { 0x6622D85, 0x6856, 0x4460, 0x8D, 0x0E1, 0x0A8, 0x19, 0x21, 0x0B4, 0x1C, 0x4B };
IID iid = { 0x0D11AD862, 0x66DE, 0x4DF4, 0x0BF, 0x6C, 0x1F, 0x56, 0x21, 0x99, 0x6A, 0x0F1 };
HRESULT hoge()
{
HRESULT hr;
try {
IUnk *pUnk;
hr = CoCreateInstance(clsid, 0, CLSCTX_INPROC_SERVER, iid, (void**) &pUnk);
if (FAILED(hr))
{
_com_issue_error(hr);
}
hr = pUnk->Func(ss, 0, 0, 0);
pUnk->Release();
}
catch (_com_error& e) {
hr = e.Error();
MessageBoxA(0, e.ErrorMessage(), "", MB_OK);
}
return hr;
}
int CALLBACK WinMain(
_In_ HINSTANCE hInstance,
_In_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow
)
{
CoInitialize(nullptr);
hoge();
CoUninitialize();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment