If you were like me, where the first programming language you learnt was assembler, on computers such as the Commodore series (Vic20, C64 and Amiga), then started programming assembler on the PC platforms, until more sophisticated languages became available, then, you will know the advantages of this low level language, not only to mention speed, produces very small executable files, and having full control control over CPU registers and your program only executes exactly what you want it to.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
The Microsoft Assembler 32 (MASM32) allows you to continue programming assembler language, in the windows 32 bit environment. I will demonstrate how to use assembler language to develop Notes based applications. The Notes C API stores all available functions that reside in nnotes.dll in the notes.lib file, therefore you are not able to call undocumented functions easily (yes you can call undocumented functions in C). So, in fact, you can also call functions available in other notes dll's such as nnotesws.dll (to call the NEMxxxx functions).
In these examples we are bypassing the use of notes.lib and explicitly opening the required dll (nnotes.dll in this case) and getting the call address of each function in the dll that we require.
A simple notes application to initialise a notes session, open a database (local or server), displays the title of the database, then closes the notes session, compiles to 86k when developed using C API. The same application compiled in assembler language compiles to only 3072 bytes (3k).
In the example below, we load nnotes.dll into memory, extract the memory addresses of the functions we require, initialise a notes session, open a database, close the database, then close the notes session.
There is no error checking performed here, the download application includes full error checking routines.
The sample (Title1) includes the code below, to get the title of a database. The application Title1.exe must be copied to the Lotus Notes install directory (if notes is not in the PATH).
There is also (Title2) which is the same as Title1, but the application does not have to be executed from the local notes install directory, it can be executed from anywhere including a shared network drive, as long as, the calling workstation has Lotus Notes installed, and notes does not have to be in the PATH.
The Title1 and Title2 functions also open the nnotesws.dll and use the undocumented function NEMDisplayError for notes error message display.
My web site is still under construction, but, you may download the above applications at:
My other applications can be downloaded at: http://www.users.bigpond.com/dfry/index.htm
The Microsoft Assembler (MASM32 v6) can be downloaded at http://www.zcoder.com/Source.htm
Contact me if you have any queries.
STEP 1 - Loading the notes.dll file
This step will load nnotes.dll into memory. Variable 'nnoteslib" stores the handle to the loaded dll file.
Data Structures used:
nnoteslib dd 0
sznnoteslib db "nnotes.dll",0
invoke LoadLibrary, ADDR sznnoteslib ;load nnotes.dll
mov nnoteslib, eax ;store the handle to the library
STEP 2 - Getting function call addresses
Once we have loaded nnotes.dll, we how have get the memory address for each function that we need to use from the dll.
szNotesInitExtended db "NotesInitExtended",0 ;functions are case sensitive szNotesTerm db "NotesTerm",0 szNSFDbOpen db "NSFDbOpen",0 szNSFDbClose db "NSFDbClose",0 szDatabase db "names.nsf",0 ;server!!database NotesInitExtended dd 0 ;varibales to store the calling addresses NotesTerm dd 0 ;later, we then explicitly the functions NSFDbOpen dd 0 NSFDbClose dd 0 hDB dd 0 ;database handle
invoke GetProcAddress, nnoteslib, ADDR szNotesInitExtended ;get the calling address of NotesInitExtended mov NotesInitExtended, eax ;store the address invoke GetProcAddress, nnoteslib, ADDR szNotesTerm mov NotesTerm, eax invoke GetProcAddress, nnoteslib, ADDR szNSFDbOpen mov NSFDbOpen, eax invoke GetProcAddress, nnoteslib, ADDR szNSFDbClose mov NSFDbClose, eax
STEP 3 - Initialize a notes session
To call a function use: call [function name] If the function needs parameters, you must "push" each parameter onto the stack in the reverse order (ie. last parameter is pushed first)
;Initialize the notes session push CmdLine ;pointer command line parameters push 0 ;number of command line parameters call [NotesInitExtended] ;call NotesInitExtended function ; Open the database lea ecx, hDB ;pointer to the Database Handle push ecx lea ecx, szDatabase ;pointer to the Database String push ecx call [NSFDbOpen] ;call NSFDBOpen function ; Close the database push hDB ;database Handle call [NSFDbClose] ;call NSFDbClose function ; Terminate the notes session call [NotesTerm] ;call NotesTerm function ##### END