Jump to content

DllCall crashes AutoIt


vaprog
 Share

Recommended Posts

I'd like to create a command line wrapper for a dll which remote controls PowerPoint Viewer.

I cannot figure out how to call the dll so it does not crash the interpreter.

here's my code:

ConsoleWrite('PPT2BMP v0.01' & @CRLF);
Local $hDll = DllOpen('F:TEMPOpenLP-1.9.8-setup{app}pluginspresentationslibpptviewlibpptviewlib.dll')
If $hDll = -1 Then
  ConsoleWriteError('DLL nicht geladen: ' & @error & ' ' & @extended & @CRLF);
  exit
EndIf
DLLCall($hDll, 'none:cdecl', 'SetDebug', 'BOOL', True)
If @error Then
  ConsoleWriteError('DLLCall Fehler: ' & @error & ' ' & @extended & @CRLF);
  Exit
EndIf
Local $iState = DLLCall($hDll,'BOOL:cdecl','CheckInstalled')
If @error Then
  ConsoleWriteError('DLLCall Fehler: ' & @error & ' ' & @extended & @CRLF);
  Exit
EndIf
ConsoleWriteError('Returned install state: ' & $iState[0] & @CRLF);
If $iState[0] Then
  ConsoleWrite('PowerPoint Viewer ist installiert' & @CRLF)
Else
  ConsoleWrite('PowerPoint Viewer ist nicht installiert' & @CRLF)
EndIf
DLLClose($hDll);
ConsoleWriteError('DLL closed' & @CRLF);

The first call works, the second crashes.

Here's an excertp of the header file associated with the dll:

#define DllExport extern "C"  __declspec( dllexport )
DllExport BOOL CheckInstalled();
DllExport void SetDebug(BOOL onOff);

As I have learned from other posts, crashes with DllCall almost always are due to invalid parameters or the wrong calling convention.

As the script crashes on the first DllCall without the :cdecl (and the absence of a __stdcall token in the source), I assume the calling convention is in fact :cdecl.

And there does not remain much room for more errors, does there?

The dll appears to be working as it does it's thing in the application it has been developped for.

So, has anybody a hint as to what is wrong?

I tested on a 32-bit system.

The source code of the dll can be found in a bazaar repository

The binary dll is part of their binary installation package. I can attach it here if helpful.

Link to comment
Share on other sites

I compiled it by my own and it works.

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.

Link to comment
Share on other sites

You compiled the dll using visual C++ with the project settings given and run my unaltered script (apart from the dll path) with success?

Could you please provide your build to me and/or try with theirs and report back? I would like to find out whether the issue is with the dll build or the environment run in. I attach the one I used.

Unfortunately I am not set up to compiling C programs.

By the way, I use AutoIt Version 3.3.8.0.

pptviewlib.dll

Link to comment
Share on other sites

Your DLL works for me the same way. But I work on Win7 and do not have the PowerPointViewer installed.

BTW: There is nothing in the DLL that can't be easy done with pure AutoIt.

Here is the upload for my compiled version: http://funkey.square7.ch/Temp/pptviewlib.dll

Edit: I build the code with Codeblocks and MinGW. I had to change a few things in the code.

Edited by funkey

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.

Link to comment
Share on other sites

Your DLL works for me the same way. But I work on Win7 and do not have the PowerPointViewer installed.

I tested on a different machine with No PowerPoint installd but PPTVIEW installed and I had success. On my machine, no PPTVIEW is installed explicitely, but one is on disk probably as a component of Office 2007. In the end the crash seems to be due to wrong parameters to strcopy_s in the dll.

Thanks, funkey, for providing valuable information to pinpoint this.

BTW: There is nothing in the DLL that can't be easy done with pure AutoIt.

Well, Callbacks and stuff ... more than I want to tackle!

Moreover, I'd like to take benefit of improvements made by others to the dll without reprogramming its functionality. Thus, using the dll makes more sense.

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