Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 1.3 KB

sample_007.md

File metadata and controls

55 lines (40 loc) · 1.3 KB

Home

Using LoadLibrary

Before you begin:

See also:


Code:

DO declare

lpLibFileName = GetSystemDir() + "\mapi32.dll"
hLibModule = LoadLibrary(lpLibFileName)

IF hLibModule <> 0
	? "Library handle:", hLibModule
	= FreeLibrary(hLibModule)
ELSE
	* 1157 = ERROR_DLL_NOT_FOUND
	? "Error code returned:", GetLastError()
ENDIF
* end of main

FUNCTION GetSystemDir
	LOCAL lpBuffer, nSizeRet
	lpBuffer = SPACE(250)
	nSizeRet = GetSystemDirectory(@lpBuffer, Len(lpBuffer))
RETURN Iif(nSizeRet<>0, Left(lpBuffer, nSizeRet), "")

PROCEDURE declare
	DECLARE INTEGER LoadLibrary IN kernel32;
		STRING lpLibFileName

	DECLARE INTEGER FreeLibrary IN kernel32;
		INTEGER hLibModule

	DECLARE INTEGER GetSystemDirectory IN kernel32;
		STRING @ lpBuffer, INTEGER nSize

	DECLARE INTEGER GetLastError IN kernel32  

Listed functions:

FreeLibrary
GetLastError
GetSystemDirectory
LoadLibrary