[GER]Dll-Funktion funzt net

01/05/2009 15:53 deathcruzer#1
habe folgendes problem:
wenn ich die funktion meiner dll mittels cmd aufrufe also rundll32 testdll.dll,HelloWorld

sagt er mir dass der eintrag HelloWorld nicht funzt und auch wenn ich meine dll in andere prozesse injecte wie zb notepad oder eigene progs passiert nichts oder sie stürzen ab.

benutze Windows Vista Home Premium 32bit und dev-c++

hier ist der code der dll
Code:
//dll.h
#ifndef _DLL_H_
#define _DLL_H_

#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */

DLLIMPORT void HelloWorld(void);

class DLLIMPORT DllClass
{
  public:
    DllClass();
    virtual ~DllClass(void);

  private:

};


#endif /* _DLL_H_ */
und dllmain.cpp
Code:
#include "dll.h"
#include <windows.h>

DLLIMPORT void HelloWorld ()
{
    MessageBox (0, "HelloWorld", "HelloWorld", MB_ICONINFORMATION);
}



BOOL APIENTRY DllMain (HINSTANCE hInst     /* Library instance handle. */ ,
                       DWORD reason        /* Reason this function is being called. */ ,
                       LPVOID reserved     /* Not used. */ )
{
    switch (reason)
    {
      case DLL_PROCESS_ATTACH:
           HelloWorld();
        break;

      case DLL_PROCESS_DETACH:
           HelloWorld();
        break;

      case DLL_THREAD_ATTACH:
           HelloWorld();
        break;

      case DLL_THREAD_DETACH:
           HelloWorld();
        break;
    }

    /* Returns TRUE on success, FALSE on failure */
    return TRUE;
}
dazu sollte ich noch sagen dass ich anfänger in sachen dll bin^^
01/05/2009 16:13 schlurmann#2
Was soll die Klasse dort? Und warum willst du HelloWorld importieren? Wenn überhaupt mächte ein Export Sinn. Wenn du nur deine Funktion bei Attach usw. callen willst, reicht das aus:

Code:
#include <windows.h>

void HelloWorld ()
{
    MessageBox (0, "HelloWorld", "HelloWorld", MB_ICONINFORMATION);
}

BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
{
    if(NULL != reason)
        HelloWorld();
    return TRUE;
}
Hier gibt's ein schönes [Only registered and activated users can see links. Click Here To Register...].
01/05/2009 16:29 deathcruzer#3
danke für das tut ich werds mir mal durchlesen gibt soviele tuts und meistens wirds nur flüchtig erklärt