a | b | |
---|
| 0 | + | #include "main.h" |
---|
| 0 | + | #include <windows.h> |
---|
| 0 | + | #include <commctrl.h> |
---|
| 0 | + | |
---|
| 0 | + | VOID ThreadProc(); |
---|
| 0 | + | LRESULT CALLBACK DLL_EXPORT LvmProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
---|
| 0 | + | BOOL CALLBACK EnumCW(HWND hwnd, LPARAM lParam); |
---|
| 0 | + | |
---|
| 0 | + | HMODULE hDll; |
---|
| 0 | + | DWORD g_ThreadId; |
---|
| 0 | + | WNDPROC oldProc; |
---|
| 0 | + | HWND lvmHwnd = NULL; |
---|
| 0 | + | |
---|
| 0 | + | extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) |
---|
| 0 | + | { |
---|
| 0 | + | switch (fdwReason) |
---|
| 0 | + | { |
---|
| 0 | + | case DLL_PROCESS_ATTACH: |
---|
| 0 | + | { |
---|
| 0 | + | |
---|
| 0 | + | //MessageBox(0, "attached.", "msg", MB_OK | MB_ICONINFORMATION); |
---|
| 0 | + | hDll = hinstDLL; |
---|
| 0 | + | DisableThreadLibraryCalls(hDll); |
---|
| 0 | + | CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)&ThreadProc, NULL, NULL, &g_ThreadId); |
---|
| 0 | + | |
---|
| 0 | + | } |
---|
| 0 | + | break; |
---|
| 0 | + | |
---|
| 0 | + | case DLL_PROCESS_DETACH: |
---|
| 0 | + | // detach from process |
---|
| 0 | + | break; |
---|
| 0 | + | |
---|
| 0 | + | case DLL_THREAD_ATTACH: |
---|
| 0 | + | // attach to thread |
---|
| 0 | + | break; |
---|
| 0 | + | |
---|
| 0 | + | case DLL_THREAD_DETACH: |
---|
| 0 | + | // detach from thread |
---|
| 0 | + | break; |
---|
| 0 | + | } |
---|
| 0 | + | return TRUE; // succesful |
---|
| 0 | + | } |
---|
| 0 | + | |
---|
| 0 | + | LRESULT CALLBACK DLL_EXPORT LvmProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
---|
| 0 | + | { |
---|
| 0 | + | |
---|
| 0 | + | if(uMsg == LVM_INSERTITEM) |
---|
| 0 | + | MessageBox(0, "success", "msg", MB_OK); |
---|
| 0 | + | |
---|
| 0 | + | } |
---|
| 0 | + | |
---|
| 0 | + | VOID ThreadProc() |
---|
| 0 | + | { |
---|
| 0 | + | HWND mtp = FindWindow(NULL, "MTP"); |
---|
| 0 | + | EnumChildWindows(tmgr, EnumCW, NULL); |
---|
| 0 | + | |
---|
| 0 | + | if(lvmHwnd == NULL) |
---|
| 0 | + | { |
---|
| 0 | + | MessageBox(0, "lvm control not found", "msg", MB_OK); |
---|
| 0 | + | } else { |
---|
| 0 | + | |
---|
| 0 | + | oldProc = (WNDPROC) SetWindowLong(lvmHwnd, GWL_WNDPROC, (LONG) LvmProc); |
---|
| 0 | + | |
---|
| 0 | + | |
---|
| 0 | + | |
---|
| 0 | + | } |
---|
| 0 | + | } |
---|
... | |
---|