Jump to content

DllOpen fails when I try to open the file COMMG64.dll


Go to solution Solved by Husker_Jason,

Recommended Posts

@martin

I've downloaded the files from this link:

When I tried to call this code, every time it tries to use the COMMG64.DLL, I get an error that it cannot load it.  I reduced the code to this to try troubleshooting it and make sure the file is where I think it is:

#RequireAdmin
$DLLNAME = 'COMMG64.dll'
 If Not FileExists($DLLNAME) Then
    ConsoleWrite ("FAILED" & @CR)            
Else
    ConsoleWrite ("SUCCED" & @CR)            
EndIf    

$hDll = DllOpen($DLLNAME)
If $hDll = -1 Then
    ConsoleWrite ("FAILED" & @CR)            
Else
    ConsoleWrite ("SUCCED" & @CR)            
EndIf

This is what I got for the results:

SUCCED
FAILED

So, the file exists, but for whatever reason, the DllOpen call fails.  Does anyone have any idea what I'm doing wrong?

I'm running this on a Windows 11 in 64bit mode.  The files are in my "My Documents" folder.

Link to comment
Share on other sites

I gave it a shot, but no luck.

In fact, I got a different response.  For some reason the ConsoleWrite statements no longer provide output.  The program ends with no errors, but I get no responses printed.  I added some MSGBOX lines in the same places as the ConsoleWrites, and those did run.  Unfortunately, the responses indicate the same problem.  Program exists, but it can't be opened with the DllOpen statement.

My updated code in case I have a typo.

#RequireAdmin
#AutoIt3Wrapper_UseX64=Y

ConsoleWrite("Start" & @CR)
MsgBox(1,"test","test")

$DLLNAME = 'COMMG64.dll'
 If Not FileExists($DLLNAME) Then
    ConsoleWrite ("FAILED" & @CR)            
    MsgBox(1,"test1","test")
Else
    ConsoleWrite ("SUCCED" & @CR)
    MsgBox(1,"test2","test")    
EndIf    

$hDll = DllOpen($DLLNAME)
If $hDll = -1 Then
    ConsoleWrite ("FAILED" & @CR)
    MsgBox(1,"test3","test")
Else
    ConsoleWrite ("SUCCED" & @CR)
    MsgBox(1,"test4","test")
EndIf

When I run it, I get MsgBox 2 and 3 to trigger (as well as the first one)

Link to comment
Share on other sites

  • Solution

This is all I get in the console log.

>"C:>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" /ErrorStdOut "C:\Users\jason.PASLAN\Documents\AutoIt\FunctionLib\COM_Support_64\test.au3"    
>Exit code: 0

l looked at my SCiTE version and it said it was a 32 bit version so I thought I might have installed the wrong one.  This is a new computer and I was reinstalling software, so I might have screwed up.  That said, I uninstalled AutoIt and redownloaded and installed it again.  I also installed the SciTE4AutoIt3.exe file.

After doing this, the code started working properly.  I also noticed that my console info started showing on the bottom of the screen instead of the side and I got more info when it run.  It has been a while since I did any coding in AutoIt, so not sure what i did wrong to begin with.

Anyway, it appears to be working now.  Thanks for you help though.

My SCiTE version still says 32-bit.  Is that right?

Edited by Husker_Jason
Link to comment
Share on other sites

I have had similar troubles with 32-bit dlls. There are two ways I use to make sure I run the AutoIt script as 32 bit to work properly with 32 bit dlls: 

1. Compile the script to a 32 bit executable.
2. Right-click the script and go to the bottom option "Run Script (x86)". 

But yeah, since it is working now that you have your 32 bit stuff sorted out, that was your problem.

Link to comment
Share on other sites

22 minutes ago, Andreik said:

I want to see how DllOpen fails. Use this and let us know the error code.

$hDll = DllOpen($DLLNAME)
If @error Then ConsoleWrite('Error: ' & @error & @CRLF)

 

"Unfortunately", after I reinstalled AutoIt, it works now so it does not give an error anymore.  I gave it a shot and now it just flys through the error check.  Since I don't know how I originally screwed up my install to begin with, I can't get back to that original state. 

Link to comment
Share on other sites

3 hours ago, Andreik said:

I want to see how DllOpen fails. Use this and let us know the error code.

$hDll = DllOpen($DLLNAME)
If @error Then ConsoleWrite('Error: ' & @error & @CRLF)

 

DllOpen() does not set @error upon failure.  It only signals a failure by returning -1.

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