Visual Prolog 7.0 Examples and DemosHow to Use Visual Prolog DLL from .NetWritten by Yuri Ilyin The example:
Main IssuesThe two main issues should be considered, when using Visual Prolog DLL from .Net:
Declaration of an Invoked Predicate in Visual Basic .NETLet us consider the declaration, used in this example. Public Declare Unicode Function touch Lib "myDll"
Alias "touch" (ByVal lpClassName As String) As String
EXPORTS touch Declaration of an Invoked Predicate in Visual C .NETIf it is necessary to declare the appropriate function in Visual C .NET, then the following declaration can be used. [DllImport(@"myDll.dll", EntryPoint = "touch", CharSet=CharSet.Unicode)] wchar_t* touch(wchar_t* lpClassName);
Memory HandlingVisual Prolog 6 uses a garbage collector to free used memory, therefore special efforts are necessary to pass parameters to Visual Basic program. The simplest way is to pass parameters, using COM memory, which is not freed by the Garbage Collector. The current example does this by invocation: basicString::toBstr Another way is to allocate the memory in the .NET program, and pass a pointer to the Visual Prolog 6 DLL, so the Visual Prolog 6 DLL can use the predicate. memory::copy to fill data into this memory. NoteThe example requires Visual Prolog 7.0 Commercial Edition, Build 7001 or higher. If you use the Personal Edition, but need the features supported only in the Commercial Edition, you are welcome to order the latest build of this Edition just now: Order! Users of previous versions of Visual Prolog are welcome to upgrade to the current version of Visual Prolog to use the latest versions of the Visual Prolog examples.
Examples for previous versions are still available. |
|
|