Code conversion (Delphi)

Kinda sorta almost works:

//Window.Open
Declare Function ShellExecuteW Lib "Shell32" (HWND As Integer, op As WString, file As WString, params As WString, directory As WString, cmd As Integer) As Integer
  
Const SW_HIDE = 0
If ShellExecuteW(Self.Handle, "open", "notepad.exe", "", App.ExecutableFile.Parent.AbsolutePath, SW_HIDE) <= 32 Then
  MsgBox("Failed to launch")
  Return
End If
  
Declare Function FindWindowW Lib "User32" (ClassName As WString, WindowName As WString) As Integer
Dim HWND As Integer = FindWindowW("Notepad", Nil)
  
If HWND <> 0 Then
    Declare Function SetParent Lib "User32" (Child As Integer, NewParent As Integer) As Integer
    Call SetParent(HWND, Self.Handle)

    Declare Function SetWindowLongW Lib "User32" (HWND As Integer, Index As Integer, NewLong As Integer) As Integer
    Const GWL_STYLE = -16
    Call SetWindowLongW(HWND, GWL_STYLE, 0)
    
    Declare Function SetWindowPos Lib "User32" (HWND As Integer, hWndInstertAfter As Integer, x As Integer, y As Integer, cx As Integer, cy As Integer, flags As Integer) As Boolean
    Const SWP_FRAMECHANGED = &h0020
    Const SWP_ASYNCWINDOWPOS = &h4000
    Call SetWindowPos(HWND, 0, 0, 0, Self.Width, Self.Height, SWP_ASYNCWINDOWPOS Or SWP_FRAMECHANGED)
    
    Declare Function ShowWindow Lib "User32" (HWND As Integer, Command As Integer) As Boolean
    Const SW_SHOW = 5
    Call ShowWindow(HWND, SW_SHOW)
    
  Else
    MsgBox("Failed to find the window")
  End If