标签:style size get int window 工作 mil 应用 for name form
unit 使应用程序只运行一个实例;
interface
uses Windows;
const
  
// - 互斥体唯一的名字
  
_Mutex_Name = ‘{19631971-1976-1981-1989-199319941995}‘;
var
  
_Mutex_Handle: THandle;
implementation
initialization // - 载入时调用的代码
// - 创建互斥体对象
_Mutex_Handle := CreateMutex(nil, 
False, LPCWSTR(_Mutex_Name));
// 
- 若互斥体对象存在则
if 
GetLastError = ERROR_ALREADY_EXISTS then
  
// - 结束程序,可有 Integer 参数给操作系统
  
Halt(ERROR_ALREADY_EXISTS);
// - 
工作在调试状态时检测内存泄漏
{$WARN 
SYMBOL_PLATFORM OFF}
ReportMemoryLeaksOnShutdown := 
Boolean(DebugHook);
{$WARN SYMBOL_PLATFORM ON}
finalization // - 释放时调用的代码
// - 释放互斥体
ReleaseMutex(_Mutex_Handle);
end.
只运行一个实例以及内存泄漏检测,布布扣,bubuko.com
标签:style size get int window 工作 mil 应用 for name form
原文地址:http://www.cnblogs.com/haim/p/3698424.html