|PBInvoke quick start guide|
|PBInvoke library documetation > General > Quick Start Guide|
Add PBInvoke library to your project
If libPbInvoke.DLL is not in the PATH nor in the current directory then you'll need to specify the path to it in application's open event before any other call to the library:
n_pi_loader lnv_loader // autoinstantiated lnv_loader.of_preload_dll("modules\libPBInvoke.dll")
Note, you can change the path only, and not the DLL name because it is hard-coded in the external function declarations.
This code can be placed in any convenient script. Usually it's executed once per application session and its results are cached somewhere (e.g. in instance/shared variables).
n_pi_core lnv_core n_pi_library lnv_user32 n_pi_method lnv_SendMessage lnv_user32 = lnv_core.of_declare_library("user32.dll") lnv_SendMessage = lnv_user32.of_declare_method(& "LRESULT WINAPI SendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) ")
Note, that the declaration is a C function prototype which can be directly copied from C header
files or from documentation such as MSDN.
HWND, UINT etc. are Windows types. Many such types are predefined in PBInvoke. But if you get "Type 'XXXX' not found" error message, then you'll need to define the type yourself before using it in declarations.
n_pi_core lnv_core lnv_core.of_declare("typedef int NEWTYPE"); // this is just an example; for real typedef you'll need to // see the documentation or header files for DLL you call. ...of_declare_method(...)
long ll_result ll_result = lnv_SendMessage.of_invoke(Handle(w_somewin), n_pi_winapi.WM_KEYDOWN, 9 /*Tab*/, 0)
n_pi_winapi provides some WinAPI constants.
See the Samples folder in the archive for more complex examples with structures, callbacks etc.
|© 2003-2011 Desta, Ltd. All rights reserved.||SupportDesk|