Jump to content

Creating and passing a class as a DLL Param


dddienst
 Share

Recommended Posts

Ok, I am trying to evaluate the Screen OCR SDK and I am having some trouble because the primary function I want to call in there DLL needs to be passed a pointer to a class. I can see that AutoIt supports DLL Calls and even some support for creating Structures to pass to DLL functions but how do I Create load and pass a class?

Here is a snipit from the header file they give to use with the DLL.

class TextractSource {
 public:
  TextractSource();
  TextractSource& BmpFile(const char *bmpFileName);
  TextractSource& Wnd(HWND);
  TextractSource& Rect(int ax, int ay, int bx, int by);
  TextractSource& DesktopWnd();
  TextractSource& TopWnd(const char *windowClass, const char *windowText);
  TextractSource& DeepWnd(const char *windowClass, const char *windowText);
  TextractSource& SubWnd(const char *windowClass, const char *windowText);
  TextractSource& SubDeepWnd(const char *windowClass, const char *windowText);
  TextractSource& FindLargestWindow();

  const char *BmpFileName; // used if != NULL
  HWND W; // used if != NULL
  int AX, AY, BX, BY; // used if BmpFileName == NULL and Wnd == NULL
};

TextractExport TextractSuccess Textract(TextractSource&, TextractDest&, 
  TextractDestFormat);

I have only included one class for brevity but TextractDest is also a class. TextractSuccess is just a long.

Thanks,

dddienst

P.S. I see many here prefer to use Tesseract but I am using Win7 which that has trouble with so I wish to try this method. OR would it be better to use VB and access both AutoIt and ScreenOCR with COM interfaces since both also have support for that method. I just don't what to make things more complex then they need to be. :)

Link to comment
Share on other sites

$tTextractSource = DllStructCreate("ptr BmpFileName;hwnd W;int AX;int AY;int BX;int BY;")
$pTextractSource = DllStructGetPtr($tTextractSource)
$aRes = DllCall("dllname.dll", "int:cdecl", "Textract", "ptr", $pTextractSource, "ptr", $pTextractDest)

Several things are assumed here: TextractSuccess is an enumeration (int), that class is a simple one, no polymorphism is involved and that the calling convention is __cdecl. Change the necessary fields.

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

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