Wintertree Software Inc.

WGrammar Grammar Checker Engine - Support

Home Site index Contact us Catalog Shopping Cart Products Support Search

You are here: Home > Support > WGrammar Grammar Checker Engine > Using WGrammar Windows SDK with C#

Using WGrammar Windows SDK with C#

Product: WGrammar Grammar Checker Engine Windows SDK

The following declarations may help customers who need to integrate WGrammar Grammara Checker Engine into a C# application.

Function declarations

WGrammar API functions documented in WGrammar Reference Guide are shown in C/C++ syntax. The following table shows how to translate C/C++ data types into C# data types:

C/C++ type

Type description

C/C++ example

Equivalent C# type

C# Example

const char *

String, or more accurately, pointer to an array of characters

const char *fileName
[MarshalAs(UnmanagedType.LPStr)] string
string fileName
char *

Output string.

char *description
[MarshalAs(UnmanagedType.LPStr)] StringBuilder
[MarshalAs(UnmanagedType.LPStr)] StringBuilder description

Signed, 16-bit integer

WS_S16 sid
short sid

Signed, 32-bit integer

WS_S32 offset
int offset
WS_S32 *

Pointer to a signed, 32-bit integer ("pointer" meaning "pass by reference")

WS_S32 *matchLen
ref int
ref int matchLen

For pointer-type parameters (denoted by "*", as in char *str) the keyword "const" indicates that the parameter is passed by reference but will not be modified by the called function. If "const" is missing, the parameter is either an output parameter (meaning it is modified to by the called function) or an input/output parameter (meaning its value is read by the called function and may be modified by the called function).

By default, C# uses wide (2-byte) character strings, but the WGrammar DLL uses single byte strings. For this reason, the [MarshalAs(UnmanagedType.LPStr)] modifier should be applied to string-type parameters (both input and output).

Following is an example function declaration:

(Note that references to wgram232.dll should be changed to the name of the WGrammar DLL included with your version of the WGrammar Windows SDK.)

For more information on calling DLLs from C#, search MSDN for "Platform Invoke Tutorial."

Home Site index Contact us Catalog Shopping Cart Products Support Search

Copyright © 2015 Wintertree Software Inc.