bub Posted August 27, 2011 Posted August 27, 2011 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!!!
ProgAndy Posted August 27, 2011 Posted August 27, 2011 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
smashly Posted August 27, 2011 Posted August 27, 2011 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(); } #endifDllCall("hw.dll", "none:cdecl", "HelloWorld") Works for me using CodeBlocks/GCC compiler
Shaggi Posted August 27, 2011 Posted August 27, 2011 (edited) #ifdef BUILD_DLL #define DLL_EXPORT extern "C" __declspec(dllexport) __cdecl #else #define DLL_EXPORT __declspec(dllimport) #endif Edited August 27, 2011 by Shaggi Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG
bub Posted August 28, 2011 Author Posted August 28, 2011 returns error!I removed DLL_EXPORT and is compiledBut... Autoit don't work D:the DLL is not called =(
funkey Posted August 28, 2011 Posted August 28, 2011 Forget Dev-C++ and install Code:Blocks. This is much better than Dev-C++. Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning.
bub Posted August 28, 2011 Author Posted August 28, 2011 one day I installed CodeBlocks evil.and it stopped working ...has ceased to compiled any project.always returns this error:do not need to reinstall, I tried several times.I gave up.
bub Posted August 28, 2011 Author Posted August 28, 2011 (edited) I solved! I had to fill in the X86 version Autoit -.- " Edited August 28, 2011 by bub
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now