Sign in to follow this  
Followers 0
bub

Create Dll from Dev-c++ and reclame

9 posts in this topic

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!!!

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

example please

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

#ifdef BUILD_DLL
    #define DLL_EXPORT extern "C" __declspec(dllexport) __cdecl
#else
    #define DLL_EXPORT __declspec(dllimport)
#endif

Edited by Shaggi

Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG

Share this post


Link to post
Share on other sites

returns error!

Posted Image

I removed DLL_EXPORT and is compiled

But... Autoit don't work D:

the DLL is not called =(

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

one day I installed CodeBlocks evil.

and it stopped working ...

has ceased to compiled any project.

always returns this error:

Posted Image

do not need to reinstall, I tried several times.

I gave up.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I solved!

I had to fill in the X86 version Autoit -.- "

Edited by bub

Share this post


Link to post
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
Sign in to follow this  
Followers 0