Function Reference


Maps a specified executable module into the address space of the calling process

#include <WinAPI.au3>
_WinAPI_LoadLibraryEx ( $sFileName [, $iFlags = 0] )


$sFileName Names a Win32 executable module (either a .dll or an .exe file). The name specified is the
filename of the executable module.
$iFlags [optional] Specifies the action to take when loading the module. This parameter can be one of the
following values:
$DONT_RESOLVE_DLL_REFERENCES - If this value is used and the executable module is a DLL the system does not call DllMain for process and thread initialization and termination. Also, the system does not load additional executable modules that are referenced by the specified module.
$LOAD_LIBRARY_AS_DATAFILE - If this value is used, the system maps the file into the calling process's address space as if it were a data file. Nothing is done to execute or prepare to execute the mapped file.
$LOAD_WITH_ALTERED_SEARCH_PATH - If this value is used, and $FileName specifies a path, the system uses the alternate file search strategy to find the associated executable modules that the specified module causes to be loaded.

Return Value

Success: A handle to the executable module
Failure: 0, call _WinAPI_GetLastError() to get extended error information


Above constants require #include <WinAPIConstants.au3>


_WinAPI_FreeLibrary, _WinAPI_LoadLibrary, _WinAPI_LoadString

See Also

Search LoadLibraryEx in MSDN Library.


#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $g_idMemo


Func Example()
    Local $hGUI, $idInput, $id_Get, $hReBar, $hInstance, $sText
    ; Create GUI
    $hGUI = GUICreate("WinAPI", 400, 396)

    $idInput = GUICtrlCreateInput("4209", 0, 0, 100, 20)

    ; create the rebar control

    $g_idMemo = GUICtrlCreateEdit("", 2, 55, 396, 200, BitOR($WS_VSCROLL, $WS_HSCROLL))
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ;add band containing the  control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "String ID:")

    $id_Get = GUICtrlCreateButton("Get String", 0, 0, 90, 20)

    ;add band containing the  control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($id_Get), 120, 200)


    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
            Case $id_Get
                GUICtrlSetData($g_idMemo, "")
                $hInstance = _WinAPI_LoadLibraryEx("shell32.dll", $LOAD_LIBRARY_AS_DATAFILE)
                If $hInstance Then
                    $sText = _WinAPI_LoadString($hInstance, GUICtrlRead($idInput))
                    If Not @error Then
                        MemoWrite('Got the String (chars: ' & @extended & '): ' & @CRLF & $sText)
                        MemoWrite("Last Error Message: " & @CRLF & _WinAPI_GetLastErrorMessage())
                    MemoWrite(@CRLF & "Success Freeing? " & _WinAPI_FreeLibrary($hInstance))
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite