Jump to content

Create Dll from Dev-c++ and reclame


bub
 Share

Recommended Posts

Cpp file:

#include "dll.h" 
#include <windows.h> 
#include <stdio.h> 
#include <stdlib.h> 

DLLIMPORT void HelloWorld () 
{ 
    MessageBox (0, "Hello World", "Hi", 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: 
        break; 

      case DLL_PROCESS_DETACH: 
        break; 

      case DLL_THREAD_ATTACH: 
        break; 

      case DLL_THREAD_DETACH: 
        break; 
    } 

    /* Returns TRUE on success, FALSE on failure */ 
    return TRUE; 
}

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); 


#endif /* _DLL_H_ */

Script AU3 :

#RequireAdmin
$hDll = DllOpen(@ScriptDir&"\Prog1.dll")
DllCall($hDll,"none:cdecl","HelloWorld")
DllClose($hDll)

Don't work o.O

Help me!!!

Link to comment
Share on other sites

If you want to use cdecl, you have to add extern "C" and __cdecl to your function signature

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Hi,

DLL.cpp

#include "DLL.h"

void DLL_EXPORT HelloWorld()
{
    MessageBox(0, "Hello World", "Hi", MB_OK | MB_ICONINFORMATION);
}

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
    switch (fdwReason)
    {
        case DLL_PROCESS_ATTACH:
            // attach to process
            // return FALSE to fail DLL load
            break;

        case DLL_PROCESS_DETACH:
            // detach from process
            break;

        case DLL_THREAD_ATTACH:
            // attach to thread
            break;

        case DLL_THREAD_DETACH:
            // detach from thread
            break;
    }
    return TRUE; // succesful
}

DLL.h

#ifndef _DLL_H_
#define _DLL_H_

#include <windows.h>

#ifdef BUILD_DLL
    #define DLL_EXPORT __declspec(dllexport)
#else
    #define DLL_EXPORT __declspec(dllimport)
#endif

extern "C"
{
void DLL_EXPORT HelloWorld();
}

#endif
DllCall("hw.dll", "none:cdecl", "HelloWorld")

Works for me using CodeBlocks/GCC compiler

Link to comment
Share on other sites

Forget Dev-C++ and install Code:Blocks. This is much better than Dev-C++.

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...