Can't access DLL function

2 posts in this topic

#1 ·  Posted (edited)


I have compiled a reference DLL in VS 2015 Community and this  DLL works fine with project for which it is used. There is an interface from which u can access functions in DLL.

Developers stated that this DLL is almost universal and can be used with any language with minor changes.

I am trying to access its function from Autoit script and got an error 3, after calling DLLCall - "function" not found in the DLL file.

Please have a quick look, I feel I miss something in C++ library with exporting functions and I do not know what to add as I am new to C++.

Thank you.

Source files and script also attached.


Here is my script.

Local $dll = DllOpen("C:\Users\Home\Desktop\dll\user.dll")
ConsoleWrite("$dll handle = " & $dll & @CRLF)   ;$dll handle = 1

Local $result = DllCall($dll, "double:cdecl", "ProcessQuery", "str", "dll$mynumber")
If @error > 0 Then ConsoleWrite("Error: " & @error & @CRLF)    ;Error = 3

If IsArray($result) Then
    ConsoleWrite("Array returned!" & @CRLF & "dll$mynumber: " & result[1])
    ConsoleWrite("$result is not array. : " & $result  & @CRLF)  ;$result = 0


And here is dll source. As I understand, function "ProcessQuery" exported with help of DLL_IMPLEMENTS


// This file is part of the OpenHoldem project
//   Download page:
//   Forums:      
//   Licensed under GPL v3:
// Purpose: Very simple user-DLL as a starting-point
// This Header defines an interface
// Functions and data-types must exactly match.

#ifndef _INC_USER_H
#define _INC_USER_H

// Import and export directives
// for use by this DLL and by OpenHoldem
#ifdef USER_DLL
#define DLL_IMPLEMENTS extern "C" __declspec(dllexport)
#define EXE_IMPLEMENTS extern "C" __declspec(dllimport)
#define DLL_IMPLEMENTS extern "C" __declspec(dllimport)
#define EXE_IMPLEMENTS extern "C" __declspec(dllexport)

// Number of saved table-states
// This number must not be changed, as we do a "& 0xFF"
// at various places to normalize the index.
const int kNumberOfHoldemStatesForDLL = 256;

// SHoldemePlayer
// used for sequence of 256 consequive table-states
// !!!! Needs 2 more cards for Omaha, if not entirely removed
struct holdem_player {
    char            m_name[16]          ;       //player name if known
    double          m_balance           ;       //player balance 
    double          m_currentbet        ;       //player current bet
    unsigned char   m_cards[2]          ;       //player cards
    unsigned char   m_name_known    : 1 ;       //0=no 1=yes
    unsigned char   m_balance_known : 1 ;       //0=no 1=yes
    unsigned char   m_fillerbits    : 6 ;       //filler bits
    unsigned char   m_fillerbyte        ;       //filler bytes

struct holdem_state {
    char            m_title[64]         ;       //table title
    double          m_pot[10]           ;       //total in each pot
    unsigned char   m_cards[5]          ;       //common cards
    unsigned char   m_is_playing    : 1 ;       //0=sitting-out, 1=sitting-in
    unsigned char   m_is_posting    : 1 ;       //0=autopost-off, 1=autopost-on
    unsigned char   m_fillerbits    : 6 ;       //filler bits
    unsigned char   m_fillerbyte        ;       //filler byte
    unsigned char   m_dealer_chair      ;       //0-9
    holdem_player   m_player[10]        ;       //player records

// Functions implemented and exported by the DLL,
// imported by OpenHoldem
DLL_IMPLEMENTS double __stdcall ProcessQuery(const char* pquery);
DLL_IMPLEMENTS void __stdcall DLLOnLoad();
DLL_IMPLEMENTS void __stdcall DLLOnUnLoad();

// Functions implemented and exported by OpenHoldem,
// imported by the DLL
EXE_IMPLEMENTS double __stdcall GetSymbol(const char* name_of_single_symbol__not_expression);
EXE_IMPLEMENTS void*  __stdcall GetPrw1326();
EXE_IMPLEMENTS char*  __stdcall GetHandnumber();
EXE_IMPLEMENTS void   __stdcall ParseHandList(const char* name_of_list, const char* list_body);
EXE_IMPLEMENTS char*  __stdcall ScrapeTableMapRegion(char* p_region, int& p_returned_lengh);
EXE_IMPLEMENTS void   __stdcall SendChatMessage(const char *message);
EXE_IMPLEMENTS void   __stdcall WriteLog(char* format, ...);

// Variables exported by OpenHoldem
// avoiding the message-mess of WinHoldem,
// no longer sending any state-messages
EXE_IMPLEMENTS extern holdem_state state[kNumberOfHoldemStatesForDLL];
EXE_IMPLEMENTS extern int state_index;

#endif // _INC_USER_H


user.cpp    Here is dll$mynumber parameter.

// This file is part of the OpenHoldem project
//   Download page:
//   Forums:      
//   Licensed under GPL v3:
// Purpose: Very simple user-DLL as a starting-point
// Required OpenHoldem version: 7.7.6

// Needs to be defined here, before #include "user.h"
// to generate proper export- and inport-definitions
#define USER_DLL

// #define OPT_DEMO_OUTPUT if you are a beginner 
// who wants to see some message-boxes with output of game-states, etc.
// It is disabled upon request, 
//   * as it is not really needed
//   * as some DLL-users don't have MFC (atlstr.h) installed

#include "user.h"
#include <conio.h>
#include <windows.h>

#include <atlstr.h>

// Supporting macros
#define HIGH_NIBBLE(c)  (((c)>>4)&0x0F)
#define LOW_NIBBLE(c)     ((c)&0x0F)

// Card macro
#define RANK(c)         ( ISKNOWN(c) ? HIGH_NIBBLE(c) : 0 )
#define SUIT(c)         ( ISKNOWN(c) ? LOW_NIBBLE(c) : 0 )
#define ISCARDBACK(c)   ((c) == CARD_BACK)
#define ISUNKNOWN(c)    ((c) == CARD_UNDEFINED)
#define ISNOCARD(c)     ((c) == CARD_NOCARD)
#define ISKNOWN(c)      (!ISCARDBACK(c) && !ISUNKNOWN(c) && !ISNOCARD(c))

// ProcessQuery()
//   Handling the lookup of dll$symbols
DLL_IMPLEMENTS double __stdcall ProcessQuery(const char* pquery) {
    if (pquery==NULL)
        return 0;
    if (strncmp(pquery,"dll$mynumber",13)==0) {
        return 12345.67;
    return 0;

// OnLoad and OnUnload()
//   called once and at the beginning of a session
//   when the DLL gets loaded / unloaded
//   Do initilization / finalization here.

DLL_IMPLEMENTS void __stdcall DLLOnLoad() {
        MessageBox(NULL, "event-load", "MESSAGE", MB_OK);

DLL_IMPLEMENTS void __stdcall DLLOnUnLoad() {
        MessageBox(NULL, "event-unload", "MESSAGE", MB_OK);

// DLL entry point
//   Technically required, but don't do anything here.
//   Initializations belong into the OnLoad() function,
//   where they get executed at run-time.
//   Doing things here at load-time is a bad idea,
//   as some functionalitz might not be properly initialized   
//   (including error/handling).
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
  switch (ul_reason_for_call)   {
        case DLL_PROCESS_ATTACH:
        case DLL_THREAD_ATTACH:
        case DLL_THREAD_DETACH:
        case DLL_PROCESS_DETACH:
  return TRUE;


Edited by likehu

Share this post

Link to post
Share on other sites


A with all your threads so far, this request is obviously for help with a poker gamebot. As such it is not permitted by the topic=169097]Forum rules[/topic] - thread locked.

And if you continue to post on this subject we may begin to question your membership of this community - the rules are quite clear, so please follow them.



Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:


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


Share this post

Link to post
Share on other sites
This topic is now closed to further replies.

  • Similar Content

    • Trisha
      By Trisha
      I tried (using AutoIt) to automate a scenario where i  have to open IE with specific URL on my extranet(Xen Desktop or Citrix ) ,from there i need to download  file and then through WinSCP; I  have to move that file to another location that can be access from my Local system using VMWare.
      I did as far as the above step. Now i want to navigate from my extranet to my local desktop system. But i am not able to move  from there.Mouse click is also not working.Please find the below screenshot highlighted in YELLOW.

    • bbk4163
      By bbk4163
      I am getting "array variable has incorrect number of subscripts dimension range exceeded" error while executing exe. Not sure what is wrong here. 
      #include <MsgBoxConstants.au3> SelectWindowBasedOnTitle() Func SelectWindowBasedOnTitle()     $winList = WinList()     $wTitle = CheckWindows($winList)    IF $wTitle == "Choose File to Upload" Then             IE()    ElseIf $wTitle == "Open" Then             Chrome()    Else             FireFox()    EndIf EndFunc Func CheckWindows($aArray)     For $i = 1 To Ubound($aArray) - 1         If WinActive($aArray[$i][1]) Then $wTitle= $aArray[$i][0] ;MsgBox(0, "Window Check", $aArray[$i][0] & " is active.")     Next     Return $wTitle EndFunc Func Example()     $wText = WinGetText("[ACTIVE]") EndFunc Func IE()     ControlFocus("Choose File to Upload","","Edit1")     ControlSetText("Choose File to Upload","","Edit1",$CmdLine[1])     ControlClick("Choose File to Upload","","Button1") EndFunc Func Chrome()     ControlFocus("Open","","Edit1")     ControlSetText("Open","","Edit1",$CmdLine[1])     ControlClick("Open","","Button1") EndFunc Func FireFox()     ControlFocus("File Upload","","Edit1")     ControlSetText("File Upload","","Edit1",$CmdLine[1])     ControlClick("File Upload","","Button1") EndFunc  
    • TheWizEd
      By TheWizEd
      How do I work with 2D arrays.  I've tried this but get errors.
      Local $aTest[4][4] = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]
      ;$aTest[0][] = [10,11,12]  ; Error at []
      Local $sTest = ""
      For $i = 0 To UBound($aTest)-1
        Local $aExtract = _ArrayExtract($aTest,$i,$i)
        $sTest = $sTest & MyTest($aExtract)
      Func MyTest($aTemp)
        ; Error at    v $aTemp
        Return String($aTemp[0]) & " - " & String($aTemp[1]) & " - " & String($aTemp[2]) & @CRLF
    • Valnurat
      By Valnurat
      If I use this code:
      #include <IE.au3> #include <MsgBoxConstants.au3> Local $sServiceTAG = "9S1Y3J2" Local $oIE = _IECreate("" & $sServiceTAG & "/warranty?ref=captchasuccess",Default,0,0) _IELoadWait($oIE) Local $oTds = _IETagNameGetCollection($oIE, "td") For $oTd In $oTds If StringStripWS($oTd.innertext, 7) = "NBD ProSupport" Then $sShipdate = StringStripWS($oTd.NextElementSibling.InnerText, 7) ExitLoop EndIf Next _IEQuit($oIE) MsgBox($MB_SYSTEMMODAL, "Warranty", $sShipdate) My messagebox is empty, but if I use the link first:
      and then use my code I get results.
      Can someone help so I don't need to use the link first.
    • Valnurat
      By Valnurat
      I have this:
      november 08, 2015
      How can I convert it to:
      I don't see any convert option from month name to a number.
      Thank  you