GetSystemDirectory A or W module could not be found

Hi Everyone,

I am confused by the declares for GetSystemDirectoryA or GetSystemDirectoryW not available with the System.IsFunctionAvailable command, and yet calling the function will correctly return the System Directory. I have tried many different ways of creating the declare, and am not sure why the IsFunctionAvailable cannot recognize this function. Maybe I have been on the computer too long :slight_smile:

Here is the code which shows that both events are not available:

[code]Sub Action() Handles Action
#If TargetWindows
Soft Declare Function GetSystemDirectoryW Lib “Kernel32.dll” (lpBuffer As Ptr, nSize As UInt32) As UInt32
Soft Declare Function GetSystemDirectoryA Lib “Kernel32.dll” (lpBuffer As Ptr, nSize As UInt32) As UInt32

If System.IsFunctionAvailable("GetSystemDirectoryW", "Kernel32.drv") Then
  System.DebugLog "GetSystemDirectoryW in Action Event is Available"
Else
  System.DebugLog "GetSystemDirectoryW in Action Event is not Available"
End If

If System.IsFunctionAvailable("GetSystemDirectoryA", "Kernel32.drv") Then
  System.DebugLog "GetSystemDirectoryA in Action Event is Available"
Else
  System.DebugLog "GetSystemDirectoryA in Action Event is not Available"
End If
//Error 126 - The specified module could not be found

#Endif

End Sub
[/code]

How can I have this function available? I could just ignore IsFunctionAvailable, and then this would be a concern on an older Windows OS when the Unicode version is called. Any helpful thoughts? Thanks :slight_smile:

Edit: This is on Windows 10, Xojo 2018 r2.

Yep… on the computer for too long… the Kernel32.drv should be Kernel32.dll. :slight_smile:

The power of posting your problem on the forum. 2 minute later you find the issue (after looking at it for a long time) :slight_smile:

You are correct :slight_smile:

https://en.wikipedia.org/wiki/Rubber_duck_debugging :slight_smile:

Anthony,

ThatÂ’s a perfect explanation about debugging, and itÂ’s the first time that I have heard that term. Thanks :slight_smile: