<span style="font-family: Arial, Helvetica, sans-serif;">在main(WinMain、tWinMain)函数之前做一个数据共享段:</span>
#pragma data_seg("Shared") int volatile g_lAppInstance = 0; #pragma data_seg() #pragma comment(linker,"/section:Shared,RWS")
在进入到主函数中对那个变量做判断:
if (0 == g_lAppInstance) { <span style="white-space:pre"> </span>可以继续运行; } else if (1 == g_lAppInstance) {
<span style="white-space:pre"> </span>已经有这个实例在运行了;
}
原文地址:http://blog.csdn.net/xexiyong/article/details/44095129