如何通过C#释放句柄? [英] How to release a handle through C#?
本文介绍了如何通过C#释放句柄?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个应用程序,该应用程序会隐式打开dll/文件上的句柄.在应用程序的某个时刻,我想释放此句柄.我该怎么做?我的应用程序在C#中.
I have an application that IMPLICITLY opens a handle on a dll/file. At some point in the application, I want to release this handle. How can I do it? My application is in C#.
推荐答案
如果您有要关闭的处理程序,请使用PInvoke
use PInvoke if you have an handler that you want to close
[System.Runtime.InteropServices.DllImport("Kernel32")]
private extern static Boolean CloseHandle(IntPtr handle);
这篇关于如何通过C#释放句柄?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文