views:

211

answers:

2

The reason why it should be empty is because I need to write it in C:

http://stackoverflow.com/questions/951516/what-good-ides-are-availble-for-c/951582#951582

But how to write a dll from scratch?

+1  A: 

Windows DLL are written using this skeleton

#include <windows.h>

BOOL WINAPI DllMain(
  __in  HINSTANCE hinstDLL,
  __in  DWORD fdwReason,
  __in  LPVOID lpvReserved
){
   switch(fdwReason){
      case DLL_PROCESS_ATTACH:
           break;
      case DLL_PROCESS_DETACH:
           break;
      case DLL_THREAD_ATTACH:
           break;
      case DLL_THREAD_DETACH:
           break;
   }
   return 0;
}

See here on the MSDN for this and an example of it here. Here is a tutorial on creating a DLL. A more in-depth tutorial can be found here.

Hope this helps, Best regards, Tom.

tommieb75
How to write a dll that can be used in *nix environment?
I think you should post a separate question for this as the context is very different from writing a dll in Visual Studio.
tommieb75
+2  A: 

Use File -> New project -> Visual C++ -> Win32 project
Select application type DLL and additional options Empty project.

Edit:

To get a C template the easiest way is to not check Empty project and then convert the project:

  1. Rename the CPP-files to C (right click on them in the solution explorer)
  2. Remove StdAfx.cpp
  3. In Project -> {project} Properties change
    Configuration Properties -> C/C++ -> Precompiled headers
    You can choose to not use pre-compiled headers or you can change it to Create new ones.
  4. Build your project
  5. Add the meat to the template

For pointers on how to write the DLL code google for dll sample code

Peter Olsson
You answered my question?
No, sorry. I guess I'm too used to answer the question on how to get started. I have edited the answer.
Peter Olsson