Created
January 2, 2016 22:01
-
-
Save kumatti1/87336685526e1e032650 to your computer and use it in GitHub Desktop.
GetProcessHandleFromHwndは、Hookから。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <Shlobj.h> | |
#include <Exdisp.h> | |
#pragma comment(lib,"oleacc.lib")//自前 | |
#pragma comment(lib,"ole32.lib") | |
#pragma comment(lib,"user32.lib") | |
#pragma comment(lib,"shell32.lib") | |
#pragma comment(lib,"shdocvw.Lib")//自前 | |
extern "C" HRESULT __stdcall SHGetIDispatchForFolder( | |
ITEMIDLIST *pidl, | |
void** ppv | |
); | |
extern "C" HANDLE WINAPI GetProcessHandleFromHwnd( | |
_In_ HWND hwnd | |
); | |
void hoge() | |
{ | |
ITEMIDLIST *pidl; | |
HRESULT hr = SHGetSpecialFolderLocation(0, CSIDL_PERSONAL, &pidl); | |
IDispatch *pDisp; | |
hr = SHGetIDispatchForFolder(pidl, (void**) &pDisp); | |
IWebBrowser2 *pBrowser; | |
HWND hwnd; | |
if (pDisp){ | |
pDisp->QueryInterface(IID_PPV_ARGS(&pBrowser)); | |
if (pBrowser){ | |
pBrowser->get_HWND((SHANDLE_PTR *)&hwnd); | |
HANDLE hProcess = GetProcessHandleFromHwnd(hwnd); | |
if(hProcess){ | |
WaitForSingleObject(hProcess, INFINITE); | |
CloseHandle(hProcess); | |
pBrowser->Release(); | |
MessageBoxW(0,L"閉じられた(`・ω・´)ゞ", L"", MB_OK); | |
} | |
} | |
pDisp->Release(); | |
} | |
ILFree(pidl); | |
} | |
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