

CheckSpelling es un corrector ortográfico basado en el corrector de Microsoft Word, usa el propio corrector de Microsoft Word y devuelve el texto corregido, esta dll tiene alguna cadencias pero bueno es la primera versión así que ciertamente es normal que tenga algunos detalles por pulir...
Funciones:
- CheckSpelling - Retorno String "devuelve el string corregido, lógicamente antes lanza la ventana de corrección de errores de word."
UnmanagedExports.cs:
using System;
using RGiesecke.DllExport;
////////////////////////////////
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Reflection;
using WordInter = Microsoft.Office.Interop.Word;
////////////////////////////////
using System.Runtime.InteropServices;
namespace CheckSpelling
{
internal static class CheckSpellingClass
{
#region Minimize
[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true)]
static extern IntPtr SendMessage(IntPtr hWnd, Int32 Msg, IntPtr wParam, IntPtr lParam);
const int WM_COMMAND = 0x111;
const int MIN_ALL = 419;
const int MIN_ALL_UNDO = 416;
//System.Threading.Thread.Sleep(2000);
//SendMessage(lHwnd, WM_COMMAND, (IntPtr)MIN_ALL_UNDO, IntPtr.Zero);
private static void MinimizeAll()
{
IntPtr lHwnd = FindWindow("Shell_TrayWnd", null);
SendMessage(lHwnd, WM_COMMAND, (IntPtr)MIN_ALL, IntPtr.Zero);
}
#endregion Minimize
#region Functions
[DllExport("CheckSpelling", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
static string CheckSpelling(string Textstr, int activeMinimize)
{
//int activeMinimize = 0;
if (activeMinimize == 1)
{
MinimizeAll();
}
WordInter.Application app = new WordInter.Application();
int errors = 0;
if (Textstr.Length > 0)
{
app.Visible = false;
object template = Missing.Value;
object newTemplate = Missing.Value;
object documentType = Missing.Value;
object visible = true;
WordInter._Document doc1 = app.Documents.Add(ref template, ref newTemplate, ref documentType, ref visible);
doc1.Words.First.InsertBefore(Textstr);
WordInter.ProofreadingErrors spellErrorsColl = doc1.SpellingErrors;
errors = spellErrorsColl.Count;
object optional = Missing.Value;
doc1.CheckSpelling(ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional);
object first = 0;
object last = doc1.Characters.Count - 1;
Textstr = doc1.Range(ref first, ref last).Text;
}
object saveChanges = false;
object originalFormat = Missing.Value;
object routeDocument = Missing.Value;
app.Visible = true;
app.Application.Quit(ref saveChanges, ref originalFormat, ref routeDocument);
return Textstr;
}
}
#endregion Functions
}
Ejemplo DLL.CallFunction:
if Input.GetText("Input1") ~= "" then
arg = "\"" .. Input.GetText("Input1") .. "\",0" -- 1 to minimize all, 0 to no minimize all
DLLPath = _SourceFolder.."\\AutoPlay\\Docs\\CheckSpelling.dll";
result = DLL.CallFunction(DLLPath, "CheckSpelling", arg, DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL);
Input.SetText("Input2", result);
Window.Restore(Application.GetWndHandle());
end
Nota Importante: este ejemplo usa el corrector ortográfico de Microsoft Word de modo que si no tenéis instalado dicho programa esta dll no funcionara correctamente!