Jump to content

Use a dll in autoit compiled with Visual Basic6 ?


Recommended Posts

  • Moderators

Hi

is it possible to use a VisualBasic compiled dll in autoit?

Must this dll then be registered or may I use the 'dllopen' command?

Has anyone experiences in this?

Greetings Mozart90

If you know the API calls to it, then you can use DLLCall() on it I'm sure.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Yes, like Smoke said. If you know the calls you can use a .dll compiled in any language, probably, since it's already compiled. I've never tried using a .dll compiled in VB, that I know of. But have used .dll compiled in ASM and C++ without having to do anything out of the ordinary to get it to work.

Nomad :D

Link to comment
Share on other sites

Last time I checked, you can't compile DLL's in VB. Maybe I'm wrong.

You may be right about that, I haven't the faintest clue. I've never needed to make a .dll in VB so I've never looked into whether you could or not. ASM is usually the way to go with a .dll.

Nomad :D

Link to comment
Share on other sites

hi

perhaps I write what I did. So it is more practical...

In VB I opend a new ActiveX Dll Project and wrote the following code:

(I want to mention this is only an example - I know there is a much easier method to get the windows system dir in autoit but that is not the question :D ...)

' Vb Code:  The function WinDir will return the Windows Directory as a string 

 Private Declare Function GetWindowsDirectory Lib "KERNEL32" _
     Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, _
     ByVal nSize As Long) As Long
   
  Public Function WinDir() As String
     Dim sDirBuf As String * 255
     StrLen = GetWindowsDirectory(sDirBuf, 255)
     WinDir = Left$(sDirBuf, StrLen)
  End Function

Then the Classmodule was renamed to WINSYSDIR

After that I compiled the dll to the name testdll.dll

Then registering with regsvr32 ....

With the following code I can access the dll in VB

Sub Form_Load()
       Dim Folder As New WINSYSDIR   ' creates the object 
       MsgBox Folder.WinDir              ' calls the function
   End Sub

My poorly try to translate it io autoit looks like that

$obj = objcreate("WINSYSDIR")
$ret= $a.windir
msgbox(0,"info",$ret)

or the other way with dllcall would be:

DllOpen(@ScriptDir & "\testdll.dll")
$ret= DllCall("testdll","str","Windir")
msgbox(0,"info",$ret)

But both ways do not work ...

Perhaps it helps attatching the dll ...

So here it is ..

Greetings Mozart90

testdll.dll

Edited by mozart90
Link to comment
Share on other sites

  • 4 months later...

hi

perhaps I write what I did. So it is more practical...

In VB I opend a new ActiveX Dll Project and wrote the following code:

(I want to mention this is only an example - I know there is a much easier method to get the windows system dir in autoit but that is not the question :lmao: ...)

' Vb Code:  The function WinDir will return the Windows Directory as a string 

 Private Declare Function GetWindowsDirectory Lib "KERNEL32" _
     Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, _
     ByVal nSize As Long) As Long
   
  Public Function WinDir() As String
     Dim sDirBuf As String * 255
     StrLen = GetWindowsDirectory(sDirBuf, 255)
     WinDir = Left$(sDirBuf, StrLen)
  End Function

Then the Classmodule was renamed to WINSYSDIR

After that I compiled the dll to the name testdll.dll

Then registering with regsvr32 ....

With the following code I can access the dll in VB

Sub Form_Load()
       Dim Folder As New WINSYSDIR   ' creates the object 
       MsgBox Folder.WinDir              ' calls the function
   End Sub

My poorly try to translate it io autoit looks like that

$obj = objcreate("WINSYSDIR")
$ret= $a.windir
msgbox(0,"info",$ret)

or the other way with dllcall would be:

DllOpen(@ScriptDir & "\testdll.dll")
$ret= DllCall("testdll","str","Windir")
msgbox(0,"info",$ret)

But both ways do not work ...

Perhaps it helps attatching the dll ...

So here it is ..

Greetings Mozart90

testdll.dll

This thread may be VERY old but you can work with the two together using VBAdvance it comes with the templates to work with. Although Forms in VB6 dlls run as a loop so your autoit application will freeze as long as the visual basic form is being displayed.

But by loading the autoit dll into VB6 i cannot seem to get GetMousePos() to return correctly since normally it returns an array :ph34r:

Link to comment
Share on other sites

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