I work with some COM objects in C #, one of them has a SetLogFile function that accepts IntPtr. How can I create a file in C # and then pass it as IntPtr for this COM function?
EDIT: function requires an open file descriptor: http://msdn.microsoft.com/en-us/library/aa915939.aspx
You are a bit vague about what you need to pass as a “file” - if you have a FileStream, you can pass FileStream.Handle as IntPtr (assuming it expects a HANDLE value)
. " Type HANDLE # ++ DLL".
, SetLogFile IntPtr. COM- # , .
SetLogFile
IntPtr
var ptr = Marshal.GetIUnknownForObject(theParameter); try { theComObject.SetLogFile(ptr); } finally { Marshal.Release(ptr); }
Win32. API , , .
, SafeFileHandle FileStream. , , P/Invoke CreateFile.
Source: https://habr.com/ru/post/1730567/More articles:iPhone Core Data does not update table - databaseHow to initialize a static pointer in C? - cScaling an animated GIF using PHP GD - phpКак получить HTML-текст из Adobe Flex Builder RichTextEditor? - flexSlow jQuery animation in IE - jqueryMultithreaded PinVoked DLL in a managed environment. Is it possible? - c #Listing each individual row using jQuery - jqueryAlgorithm for image search in another image. (Collage) - javaIn OSX, can I use a system call to send a command to a running terminal in a new tab? - terminalCreating a site for answering a question using CMS - joomlaAll Articles