Windows 10 DLL

Good Day,

I am new to Xojo and looking for some help in regards to windows dll files. I am very proficient with AutoHotKey and migrating into Xojo. It’s easy enough when working with dll calls in AHK but Xojo has a different way to go about it and looking to understand how.

I created a simple dll using PureBasic and looking to call a function from the dll and needed to understand on how to go about implementing that within Xojo.

It’s a simple dll with 2 functions: TaskbarShow and TaskBarHide

I wanted to create a simple button when pressed just calls the function. There is nothing that needs to get passed to the function.

Any help such as an example of code that I would use would be appreciated and understanding windows dll function calls.

Thanks

I have a feeling it’s pretty simple using declare statement and some form of a call to that function but just not sure without seeing an example to better undertstand and know the correct way for future.

In AHK was as easy as:

DllModule := DllCall(“LoadLibrary”, “Str”, myDll)
DllCall(“my.dll\TaskbarShow”)
DllCall(“FreeLibrary”, “Ptr”, DllModule)

Welcome to Xojo.

There’s quite a few snippets of windows declares around the forum, if they’ve been done already you can usually find them by putting their win32 call into search.

If you need a website to look up the types for conversion, take a look here Windows APIs to Xojo data type conversion – Samphire's Solace

There also GitHub - arbp/WFS: Windows Functionality Suite and GitHub - paullefebvre/winapilib: WinAPI Declare Library for use with Xojo but there’s not been many updates to those in a while, but they can be a good source of info to get you heading down the right track.

And of course Declare — Xojo documentation

Let us know if you still need help, post some snippets and we’ll try to point you in the right direction.

Edit: Ah I see you added some code, to call that you would use

Declare Sub TaskbarShow Lib "my.dll" ()
TaskbarShow()
3 Likes

Hello @Greg_Cox and welcome to the forum.

Your right, declares can access the functions within dll using Xojo. Just a few questions before we go down the path of creating a declare:

  1. When the dll was created, are the functions exposed - meaning can other languages access the dll?
  2. Did dll creation keep the naming convention of the functions - sometimes function names get mangled and a function like HelloWorld will get changed to something like Helkei3984kjdf, which doesn’t resemble the original function name.

If the answers are all ‘yes’, then we can give it a try!

What are the function names, parameters, and return types within your dll?

Here are a few resources that exist for Xojo Declares that I can easily remember :slight_smile:

Xojo Declare Docs

Julians’ Xojo-API data type conversion page

Xojo Windows Declare Book

Edit: Julian beat me to it :slight_smile:

2 Likes

Thanks Julian!

Working now I understand the correct syntax to use now … :slight_smile:

2 Likes