Does anyone have an example of building a complete WIN32 Windows application as a dll?
I would like to export a function, call it through rundll32 and have a complete Windows application with decorations, menus, boosters and all.
I know about the calling convention for rundll32:
void CALLBACK TestEntryW(HWND hWnd, HINSTANCE hInst, LPWSTR pszCmdLine, int nCmdShow);
I can infer a MessageBox from this function with the command: rundll32.exe test3.dll,TestEntry other params and args
I can load resources from my DLL by getting the DLL handle via GetModuleHandle("test3.dll") and using this as hInst in my LoadString calls. It seems to work for LoadIcon and LoadAccelerators , but I don't have a job yet (baby steps ..).
I can register a Windows class through RegisterClassEx using these lines and icons, but I have to use the parent hInst or I get ERROR_CANNOT_FIND_WND_CLASS when calling CreateWindow . I think this was expected.
However, when I try to use this class in CreateWindow , it returns NULL, which means GetLastError .
I can get the hInst window class passed from rundll32 using GetWindowsLong(hWnd, GWL_ATOM) . Using this for lpClassName, I can pull out decorated windows minus menus and accelerators, but it's a bit scared, since the rundll window class is usually used only for message queues. I tried to subclass the window using SetWindowsLong to replace WndProc and call CallWindowProc instead of DefWindowProc in my WndProc dll.
I am prevented from being unable to debug it in MSVC ++ 2010 Express. I replaced the arguments of the project and the project team with the corresponding entries so that it runs correctly, but it does not complain about the lack of debugging information for rundll32.exe, but breakpoints, etc. Does not work.
Any ideas? Am I on the right track?