Imports System.IO
Imports System.Runtime.InteropServices
Module ModNotepad
Public intPtr As IntPtr
Private Const DLL_FILE_NAME As String = "Notepad2.dll"
Public Function GetModulePath() As String
Dim strPath As String = Path.Combine(Path.Combine(Path.Combine(If(IntPtr.Size = 4, "x86", "x64"))), DLL_FILE_NAME)
If File.Exists(strPath) Then
strPath = strPath
End If
Dim csIntPtr As IntPtr = LoadLibraryA(strPath)
Return strPath
End Function
Public Sub ResizeWindow()
ShowWindow(intPtr, 0)
ShowWindow(intPtr, 3)
End Sub
Public Sub SetParent(ByVal hWndNewParent As IntPtr)
SetParent(intPtr, hWndNewParent)
ShowWindow(intPtr, 3)
End Sub
Public Delegate Sub NotificationCallback(ByVal message As String)
<DllImport(DLL_FILE_NAME, CallingConvention:=CallingConvention.Cdecl)>
Public Sub RegisterCallback(ByVal callback As NotificationCallback)
End Sub
<DllImport(DLL_FILE_NAME, CallingConvention:=CallingConvention.Cdecl)>
Public Function GetHWND() As Integer
End Function
<DllImport(DLL_FILE_NAME, CallingConvention:=CallingConvention.Cdecl)>
Public Sub AddText(bolClear As Boolean, message As String)
End Sub
<DllImport(DLL_FILE_NAME, CallingConvention:=CallingConvention.Cdecl)>
Public Function GetMain_HWND() As IntPtr
End Function
<DllImport(DLL_FILE_NAME, CallingConvention:=CallingConvention.Cdecl)>
Public Sub CloseExe()
End Sub
<DllImport(DLL_FILE_NAME, CallingConvention:=CallingConvention.Cdecl)>
Public Sub Style_Loadvb()
End Sub
<DllImport(DLL_FILE_NAME, CallingConvention:=CallingConvention.Cdecl)>
Public Function GetTextL2() As IntPtr
End Function
<DllImport(DLL_FILE_NAME, CallingConvention:=CallingConvention.Cdecl)>
Public Function wWinMainDLL(ByVal lpCmdLine As String, ByVal nShowCmd As Integer) As Integer
End Function
<DllImport("user32.dll ", EntryPoint:="SetParent")>
Private Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
End Function
<DllImport("user32.dll", EntryPoint:="ShowWindow", CharSet:=CharSet.Auto)>
Public Function ShowWindow(ByVal hwnd As IntPtr, ByVal nCmdShow As Integer) As Integer
End Function
<DllImport("kernel32")>
Private Function LoadLibraryA(<MarshalAs(UnmanagedType.LPStr)> ByVal fileName As String) As IntPtr
End Function
End Module