PDA

View Full Version : How to create dllmain?



freiza
24th February 2015, 13:32
When ever I create project using Library->C++ library in qtcreator it gives me a class

#ifndef UNTITLED_H
#define UNTITLED_H

#include "untitled_global.h"

class UNTITLEDSHARED_EXPORT Untitled
{

public:
Untitled();
};

#endif // UNTITLED_H

How do I create a project using dllmain?

BOOL WINAPI DllMain(HINSTANCE module_handle, DWORD reason_for_call, LPVOID reserved)
{
if (reason_for_call == DLL_PROCESS_ATTACH) // Self-explanatory
{}
return true;
}

Is there any way to execute dll functions when I attach qt created dll to another process?
I want to perform same task as DLL_PROCESS_ATTACH does but with the dll created using qt creator.

ChrisW67
24th February 2015, 20:12
If you have used the Library, C++ Library then Qt Creator arranges qmake to link a generic DllMain that does Qt library setup on load.

If you want a completely non-Qt project, as it seems from your other post, then create your basic source file and Makefile and use the Qt Creator wizard to Import Project, Import Other Project.you get complete control of everything in your project.

freiza
24th February 2015, 21:01
Sorry for being such a noob. But how do I create a makefile?
Never created a makefile.
Are there any tool to create makefile? Or sources?

Btw, Is there any way in qt sdk so that dll auto attaches itself to the process similarly as dllmain?

ChrisW67
25th February 2015, 11:15
A Qt project with TEMPLATE = lib and static not in CONFIG will generate a DLL from your sources and link it to a suitable DllMain() on Windows.

If you need to extend or modify the DllMain() then you need to build your C project from the ground up, including your own DllMain(). A Makefile is something you write to define the rules for building the project to the make utility (Qmake writes one on your behalf when you are using qmake).