DTWAIN_GetSessionDetails

DTWAIN_GetSessionDetailsA

DTWAIN_GetSessionDetailsW

Top  Previous  Next

The DTWAIN_GetSessionDetails function generates a JSON string describing the current TWAIN session.

 

LONG  DTWAIN_GetSessionDetails (

LPTSTR

szSessionDetails,

LONG

MaxLen,

LONG

IndentFactor,

DTWAIN_BOOL

bRefresh );

 

Parameters

 

szSessionDetails

    String buffer.  On return, this is filled in with the JSON string.  Ignored if value is NULL.

 

MaxLen

    Maximum number of characters to write to szSessionDetails.  This argument is ignored if szSessionDetails is NULL.

 

IndentFactor

    Determines the level of indentation the JSON string will contain.


bRefresh

    Determines if the TWAIN session details will be regenerated.


Return Values

The return value is the total number of characters copied to szSessionDetails, or if szSessionDetails is NULL, the total number of characters that make up the JSON string.

 

Character specific version

ANSI version:

DTWAIN_GetSessionDetailsA

Unicode version:

DTWAIN_GetSessionDetailsW

 

Comments

The DTWAIN_GetSessionDetails function generates a JSON string that describes the current TWAIN session, including all TWAIN Data Source information.  


On return, the szSessionDetails will be filled with the JSON string.  The MaxLen argument is the maximum number of characters, including the terminating NULL, that will be copied to szSessionDetails.  If szSessionDetails is NULL, the MaxLen argument is ignored.


The IndentFactor determines the indentation level of the JSON data.  For example, if the IndentFactor is 2, then each level of the JSON data is indented two spaces.  If the IndentFactor is -1, then there is no level of indentation (basically a JSON string that has all indentation and carriage returns removed).


The bRefresh determines if the TWAIN session data should be refreshed, i.e. if DTWAIN has to determine the session details again instead of using a cached version of the session details.  If bRefresh is TRUE, then the session details are refreshed.  If bRefresh is FALSE, then a cached version of the session details is used.  


Note that the initial call to DTWAIN_GetSessionDetails will always result in DTWAIN having to initially go through TWAIN to get the session details, but once this is done, these details are cached, resulting in subsequent calls to DTWAIN_GetSessionDetails with bRefresh as FALSE executing much more quickly than if bRefresh is TRUE.


Here is a small excerpt of the JSON data (with an IndentFactor of 2).  The actual data will consist of much more information, including the names of the TWAIN sources, capabilities of each source, etc.:


{

  "dtwain-version": "5.7.3",

  "session-twain-identity": {

    "device-name": "Demo Program Name",

    "twain-identity": {

      "id": 1282,

      "protocol-major": 1,

      "protocol-minor": 9,

      "supported-groups": "DG_CONTROL,DG_IMAGE,DG_AUDIO",

      "manufacturer": "Demo Program Menu",

      "product-family": "Demo Program Family",

      "product-name": "Demo Program Name",

      "version-majornum": 1,

      "version-minornum": 0,

      "version-language": 13,

      "version-country": 1,

      "version-info": "1.0"

    }

  },

  "device-count": 4,

To get detailed information on only some TWAIN sources, the DTWAIN_GetSourceDetails function can be used.


Prerequisite Function Call(s)

DTWAIN_SysInitialize.