Have a function as follows once I forage and translate everything into basic types:
The documentation says that lphDoc is "a Pointer to a handle that will be filled with a value uniquely identifying the document to data access. The developer uses this handle in subsequent calls to data access to identify this particular input file. This is not an operating system file handle.Code:unsigned int DAOpenDocument(HANDLE lphDoc, unsigned int dwSpecType, void* pSpec, unsigned int dwFlags);
Once I plugged this into P/Invoke Iterop Assistant I get:
I use lphDoc = (System.IntPtr)GCHandle.Alloc(new Object(), GCHandlerType.Pinned);Code:public partial class NativeMethods { ///Return type: unsigned int ///lphDoc: HANDLE->void* ///dwSpecType: unsigned int ///pSpec: void* ///dwFlags: unsigned int {System.Runtime.InteropServices.DllImportAttribute("sccda.dll", EntryPoint="DAOpenDocument")] public static extern uint DAOpenDocument(System.IntPtr lphDoc, uint dwSpecType, System.IntPtr pSpec, uint dwFlags); }
I know this allocates memory the sizeof Object, since I don't know what is going in there and I want it to be long lived, this seemed like a reasonable assumption. Is it?
pSpec contains a file path which I've done before using System.IntPtr path = Marshal.StringToHGlobalAnsi(String filepath);
Any better alternatives?
Jim




Reply With Quote