Subject: Re: Calling ImportRTF in NIRTF.DLL from Visual Basic.NET
Thanks for the reply.
Here’s what I have so far in my Module1:
======================================================
Imports System.Runtime.InteropServices
Public Structure EditImportData
Dim FileName As String * 100
Dim FontID As Long
End Structure
Module Module1
<DllImport("NIRTF.dll", CharSet:=CharSet.Unicode)> _
Function ImportRTF(ByVal D As EditImportData, _
ByVal F As Integer, _
ByVal M As Long, _
ByVal A As String, _
ByVal N As String) As Integer
End Function
Sub main()
Dim D As EditImportData
D.FileName = "c:\DeleteMe.tmp" & Chr(0)
D.FontID = 0
Dim s As Integer
s = ImportRTF(D, 3, 0, "", "C:\test.rtf")
End Sub
End Module
======================================================
The compiler doesn’t like the “* 100” part of the structure and will not run the module. If I remove it, the module will run, but it blows up on the Import() function call with this unhandled exception:
======================================================
=====================================================
Here are the details:
System.AccessViolationException was unhandled
Message=“Attempted to read or write protected memory. This is often an indication that other memory is corrupt.”
Source=“NotesAPI”
StackTrace:
at NotesAPI.Module1.ImportRTF(EditImportData D, Int32 F, Int64 M, String A, String N)
at NotesAPI.Module1.main() in C:\Users\bfields\Documents\Visual Studio 2008\Projects\NotesAPI\NotesAPI\Module1.vb:line 25
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: