Sentry Spelling Checker Engine - Support
You are here: Home > Support > Sentry Spelling Checker Engine > Do I need to call SSCE_OpenSession?
Product: Sentry Spelling Checker Engine Windows SDK, all versions
Question: Do I need to call SSCE_OpenSession in my application?
The short answer: Probably not.
If you are calling only functions in Sentry's Windows API, such as SSCE_CheckCtrlDlg, SSCE_CheckCtrlBackground, or SSCE_CheckBlockDlg, you do not need to call SSCE_OpenSession. The Sentry DLL automatically opens a session, then opens lexicons and sets options within that session from properties defined in the system registry or INI file. Because the Sentry DLL opens a session automatically, there is no need for you to open one.
If your application never uses the return value from SSCE_OpenSession, or only uses it to pass to SSCE_CloseSession, then you don't need to call SSCE_OpenSession. Calling SSCE_OpenSession without using the return value just wastes time and memory.
In most cases, if your application calls functions in Sentry's Core API, such as SSCE_CheckString or SSCE_CheckWord, you can pass the return value from SSCE_GetSid as the sid parameter. If you do that, you don't need to call SSCE_OpenSession. Again, the Sentry DLL automatically opens a session, and sets that session up with lexicons and option settings from the system registry or INI file. You can take advantage of all the work this entails by simply calling SSCE_GetSid. If you simply want to use the configuration defined in the system registry or INI file, just use SSCE_GetSid and don't bother calling SSCE_OpenSession.
If you do call SSCE_OpenSession, then you must also take responsibility for opening lexicons and setting options in the session you opened. Otherwise, the session you open will have no lexicons (dictionaries) open, so all words will be reported as misspelled. For example, this will not work:
sid = SSCE_OpenSession();
result = SSCE_CheckString(sid, str, cursor, ...);
SSCE_CheckString would report that every word was misspelled, because the session you opened is empty. You would need to insert calls to SSCE_OpenLex and SSCE_SetOption after the call to SSCE_OpenSession. You can do all that work if you like, but it's much simpler to call SSCE_CheckString like this instead:
result = SSCE_CheckString(SSCE_GetSid(), str, cursor, ...);
When would you need to call SSCE_OpenSession? Usually, only if you have a very specific requirement. For example, suppose your application uses the Sentry engine to check spelling, but also to validate part numbers. You have a .clx or .tlx file containing valid part numbers. You don't want to set MainLexFiles to your part-number dictionary, because the part numbers aren't used when checking regular text. Instead, you would keep MainLexFiles set to general-purpose dictionaries, such as ssceam.tlx and ssceam2.clx, and open a special session used only for validating part numbers. You would open your part-number dictionary file within the part-number session. Thus, you would have two separate Sentry sessions available:
The one opened automatically by the Sentry DLL, configured with properties set in the system registry or INI file, used for checking regular text
The special one you opened via SSCE_OpenSession, containing your part-number dictionary, used for validating part numbers.
One of the reasons the Sentry engine uses sessions is to support this kind of special-purpose use: If you need to use the Sentry engine in several different ways, you could use several different sessions, each configured as required for each use. But if you simply want to use the standard configuration defined in the system registry or INI file, just use SSCE_GetSid.
See also: Differences between "Core API" and "Windows API"
Copyright © 2015 Wintertree Software Inc.