Date: 02-16-2022
Return to Index
created by gbSnippets
'The content of a DLL can be accessed once it has been loaded
'using LoadLibary. Once loaded, procedures and resources of
'the DLL may be accessed.
'Do not use LoadLibrary to start an EXE file (use CreateProcess instead)
'Primary Code:
hLib = LoadLibrary("winmsg.dll")
pAddress = GetProcAddress(hLib, "WindowMessageA") 'use ALIAS
Call DWord pAddress Using WinMsg(%WM_InitDialog) To Result 'use Declared name
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
'Declare Function WinMsg LIB "WINMSG.DLL" ALIAS "WindowMessageA" (ByVal MsgNum As Long) AS String
Declare Function WinMsg (ByVal MsgNum As Long) As String 'take out LIB and ALIAS sections
Global hDlg As DWord
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Use Function in DLL", 30,10,130,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = 100 AND CB.Ctlmsg = %BN_Clicked Then
Local hLib As DWord, pAddress As DWord, Result As String
If IsFile("winmsg.dll") Then
hLib = LoadLibrary("winmsg.dll")
pAddress = GetProcAddress(hLib, "WindowMessageA") 'use ALIAS
Call DWord pAddress Using WinMsg(%WM_InitDialog) To Result 'use Declared name
FreeLibrary hLib
MsgBox Result
End If
End If
End Function
'gbs_00540
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm