FunctionNotFoundException

Hello,

I am using this code and it raises a FunctionNotFoundException.

Dim f As FolderItem
Dim MemBlock As MemoryBlock
Dim Result As Integer

Soft Declare Function AddIcon Lib “Carbon” Alias “SetLoginPasswordWindowProxyFSSpec” (wPtr As WindowPtr, spec As Ptr) As Integer
Soft Declare Function Initialize Lib “Carbon” Alias “FSMakeFSSpec” (fileName As PString, spec As Ptr) As Integer
Soft Declare Function WindowModified Lib “Carbon” Alias “SetWindowModified” (w As WindowPtr, modified As Boolean) As Integer

f = app.ExecutableFile.Parent.Parent.Parent
MemBlock = New MemoryBlock(7 + Len(f.Name))
'Result = Initialize(f.MacVRefNum, f.MacDirID, f.NativePath, MemBlock)
'Result = Initialize(f.MacVRefNum, f.MacDirID, f.NativePath, MemBlock)
Result = Initialize(f.NativePath, MemBlock) // FunctionNotFoundException

Apparently, it may be due to one of those Soft Declares above, how can I fix it?
I did not write this code.
Chip Apple M1
Memory 8 GB
Startup disk Macintosh HD
macOS Sonoma 14.2.1
XOJO 2023 Release 4

Thanks.

Lennox

For this you just use Window.Changed, see DesktopWindow — Xojo documentation

Used Window.Changed and WindowChanged, same error…

Dim f As FolderItem
Dim MemBlock As MemoryBlock
Dim Result As Integer

Soft Declare Function AddIcon Lib “Carbon” Alias “SetLoginPasswordWindowProxyFSSpec” (wPtr As WindowPtr, spec As Ptr) As Integer
Soft Declare Function Initialize Lib “Carbon” Alias “FSMakeFSSpec” (fileName As PString, spec As Ptr) As Integer
Soft Declare Function WindowChanged Lib “Carbon” Alias “SetWindowModified” (w As WindowPtr, modified As Boolean) As Integer

f = app.ExecutableFile.Parent.Parent.Parent
MemBlock = New MemoryBlock(7 + Len(f.Name))
Result = Initialize(f.NativePath, MemBlock)

If Result = 0 Then
Result = AddIcon(Self, MemBlock)
If Result = 0 Then
Result = WindowChanged(Self, False)
End If
End If

FunctionNotFoundException
RuntimeRaiseException
RuntimeRaiseFunctionNotFoundException
Hx.Hx.AddIcon%%o<Hx.Hx>
Hx.Hx.Event_Open%%o<Hx.Hx>
FireWindowOpenEvents
Window.Constructor%%o

No declare needed, inside a Window method you would just do this:

  self.changed = true

The other two declares - I can’t help you with, but since both are part of the Carbon library, there is a good chance they no longer work, since Carbon has been discontinued as of macOS 10.15. See Carbon (API) - Wikipedia

Thanks.
Lennox

Can you say what you are trying to accomplish with these Declares? Perhaps I or someone else can help.

This is a guess, but if you are trying to change the icon of the running application in the dock, you may want to use DesktopApplication.DockItem, see here: DesktopApplication — Xojo documentation