Jump to content

DllOpen returens -1 dllcall fail


Recommended Posts

May Test that

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Change2CUI=y
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
$dll1 = DllOpen("DllBasics.dll")
DllCall($dll1,"none","Function")

if u do DllCall the Function will be run and the MsgBox should Pop up

DllBasics.dll

DLLCall.au3

DLLCall.exe

 

Does my work for you and your own too? or still something Bugs?

Edited by RaiNote
Files
  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Link to comment
Share on other sites

Are streams (cin, cout from iostream) part of C now? DllCall is for calling C.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

okay update:

so I tried to run the DllCall.au3  that RaiNote  has provided me with, and it totally worked I was in shock!

then I tried to copy the code to my func but it didn't work. 

$dll1 = DllOpen("DllBasics.dll")
DllCall($dll1,"none","Function")
;DllCall($dll1,"none","Function")

but if I got the code out of the function it works, runining it by right clicking> Run Script works. The file is called after the func name. The problem is that if I call the function from the main program it still doesn't work. how do I make it work by calling it from the main function? 

I have included the file name in the main program

even if I change the DllCall.au3 file to this: and add a function  it stops working 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Change2CUI=y
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Func func2()
$dll1 = DllOpen("DllBasics.dll")
DllCall($dll1,"none","Function")
DllCall($dll1,"none","Function")
EndFunc

Thanks for your help guys :) !! 

Edited by TheShaps
Link to comment
Share on other sites

maybe you need to learn the basic of programming instead walking with closed eyes.

 

Saludos

Link to comment
Share on other sites

Link to comment
Share on other sites

Danyfirex

okay mister genius and knows everything. then explain why calling the user32.dll worked but calling my dll from the function doesn't

 "did you try your dll from Visual Studio?" Omg did you even read the post? what do you mean? calling it from visual studio? creating it in visual studio? yes the dll was created in visual studio.

Edited by TheShaps
Link to comment
Share on other sites

if I was a genius don't be here helping another just for free. 

it That  I said. its just a suggestion. someone genius like me(¬¬)  makes stupids trying to help someone like you. 

Maybe I did not read well. ( I'm not  an English native speaker.) so maybe for that I did wrong.

But I'm sure other people here appreciate the effort that I do for helping them.

good luck with your proyects.

 

Saludos

 

Link to comment
Share on other sites

Are streams (cin, cout from iostream) part of C now? DllCall is for calling C.

Well you can use it like me with C++ if you use it extern.

of course I am calling the function. it just doesn't work when its inside the function. I am calling it form the main function

 Code CPP:

// Inclusion guard
#ifndef _DLLTUT_DLL_H_
#define _DLLTUT_DLL_H_

// Make our life easier, if DLL_EXPORT is defined in a file then DECLDIR will do an export
// If it is not defined DECLDIR will do an import
#if defined DLL_EXPORT
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif

// Specify "C" linkage to get rid of C++ name mangeling
extern "C"
{
    // Declare 2 functions
    DECLDIR int Add( int a, int b );
    DECLDIR void Function( void );
}

// End the inclusion guard
#endif



// DECLDIR will perform an export for us
#define DLL_EXPORT

// Include our header, must come after #define DLL_EXPORT
#include "dll_tutorial.h"
#include <iostream>
#include <Windows.h>
#include <winbase.h>


// Get rid of name mangeling
extern "C"
{
    // Define our 2 functions
    // Add will return the sum of two numbers
    DECLDIR int Add(int a, int b)
    {
        return(a + b);
    }

    // Function will print out a text string
    DECLDIR void Function(void)
    {
        const WORD colors[] =
        {
            0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F,
            0xA1, 0xB2, 0xC3, 0xD4, 0xE5, 0xF6
        };

        HANDLE hstdin = GetStdHandle(STD_INPUT_HANDLE);
        HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
        WORD   index = 0;
        SetConsoleTitle((LPCWSTR)L"Project 1");
        SetConsoleTextAttribute(hstdout, 0x0C);
        CONSOLE_SCREEN_BUFFER_INFO csbi;
        GetConsoleScreenBufferInfo(hstdout, &csbi);
        std::cout << "DLL Called!\n" << std::endl;
        FlushConsoleInputBuffer(hstdin);
        int msgbox = MessageBox(NULL, (LPCWSTR)L"DLL for AutoIt", (LPCWSTR)L"Example °-°", MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON1);
        switch (msgbox)
        {
        case IDOK:
            SetConsoleTitle((LPCWSTR)L"OK Clicked");
            SetConsoleTextAttribute(hstdout, 0x0D);
            std::cout << "MsgBox Button Ok\nhas been clicked succesfully!\n" << std::endl;
            break;
        case IDCANCEL:
            SetConsoleTitle((LPCWSTR)L"Cancel Clicked");
            SetConsoleTextAttribute(hstdout, 0x01);
            std::cout << "MsgBox Button Cancel\nhas been clicked succesfully!\n" << std::endl;
            break;
        };
    };
};

 

Code Header:

// Inclusion guard
#ifndef _DLLTUT_DLL_H_
#define _DLLTUT_DLL_H_

// Make our life easier, if DLL_EXPORT is defined in a file then DECLDIR will do an export
// If it is not defined DECLDIR will do an import
#if defined DLL_EXPORT
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif

// Specify "C" linkage to get rid of C++ name mangeling
extern "C"
{
    // Declare 2 functions
    DECLDIR int Add( int a, int b );
    DECLDIR void Function( void );
}

// End the inclusion guard
#endif

 

 

Also try using my Project and Maybe u should use Visual Studio 2013 because of bug fixes and some other extras ^-^. and if u could ask Why are there so many "funcs" within my Code just because i was bored and tested something ^-^. If it also don't work with my Project using then something left on you Computer may some .Net Version.

 

  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Link to comment
Share on other sites

Have you tried simply calling the dll function?

I'm pretty sure you need an entry point function for DllOpen, perhaps you do not for simple DllCall.

 

okay update:

so I tried to run the DllCall.au3  that RaiNote  has provided me with, and it totally worked I was in shock!

then I tried to copy the code to my func but it didn't work. 

$dll1 = DllOpen("DllBasics.dll")
DllCall($dll1,"none","Function")
;DllCall($dll1,"none","Function")

but if I got the code out of the function it works, runining it by right clicking> Run Script works. The file is called after the func name. The problem is that if I call the function from the main program it still doesn't work. how do I make it work by calling it from the main function? 

I have included the file name in the main program

even if I change the DllCall.au3 file to this: and add a function  it stops working 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Change2CUI=y
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Func func2()
$dll1 = DllOpen("DllBasics.dll")
DllCall($dll1,"none","Function")
DllCall($dll1,"none","Function")
EndFunc

Thanks for your help guys :) !! 

If you do it with Func func2() you have then to run this Function like. And Why it not working for you is idk why may could you upload your Project? or try it with mine :o (You could Change everything to what you like but if you do something wrong within the Header everything Ends ^-^)

func2();Function func2() being runned
sleep(250);just a little time out :o
DllExampleCall("DllBasics","Function","none")

Func DllExampleCall($dllname,$dllFunc,$dllreturn);$dllname without dll $dllFunc what Func is being called $dllreturn Return Parameter(1,0,-1,none) i think..
$dll1 = DllOpen($dllname & ".dll")
DllCall($dll1,$dllreturn,$dllFunc)
EndFunc

 

You have to call the function.

He can only call the Function after he Opened the DLL with $dll = DllOpen("DLLname.dll") and using after this DllCall($dll, "none", "Function"); $dll= the dll "None" is the return Parameter so it just called and after this end "Function" is the Name of the Function. 

I hope any of These Infos was helpful :3

p.s.: I don't know anything of using Dll's with AutoIt :o i just looked up the params for the Command

 

Edited by RaiNote
  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Link to comment
Share on other sites

@TheShaps (reminding) (!)

 

Also would it possible to read with AutoIt What the console writes?:O

 

Just like you are using within the dll std::cing.get();

so that some Value is being read and maybe displayed in a MsgBox.

  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Link to comment
Share on other sites

@TheShaps

Are you saying that this works..

$dll1 = DllOpen("DllBasics.dll")
DllCall($dll1,"none","Function")

But this does not...

func2()

Func func2()
$dll1 = DllOpen("DllBasics.dll")
DllCall($dll1,"none","Function")
EndFunc

Also might be wise to adjust your attitude a little @Danyfirex was trying to help you.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

@JohnOne his Problem is that his Code won't work if he uses it but if he uses mine it work. °-°

That's the main Problem.

Edit:  That it inside of func won't work (because he Forget func2() maybe)

Edited by RaiNote
  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Link to comment
Share on other sites

  • Moderators

RaiNote,

There is an "Edit" button - please stop making multiple short posts in immediate succession.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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