c#调用dll 中的接口,每次调用以后,程序的句柄增加,如何调用结束以后如何还原。
[DllImport("Msprintdyn.dll", EntryPoint = "GetPrintStatusUSB", CharSet = CharSet.Ansi)]
public static extern int GetPrintStatusUSB();
[DllImport("Msprintdyn.dll", EntryPoint = "SetPrintNameUSB", CharSet = CharSet.Ansi)]
public static extern void SetPrintNameUSB(StringBuilder cName);
[DllImport("Msprintdyn.dll", EntryPoint = "CleanUSBBuffer", CharSet = CharSet.Ansi)]
public static extern void CleanUSBBuffer();
调用位置:
CleanUSBBuffer();
int status = GetPrintStatusUSB();
把句柄保存下来~调用完后主动释放掉