<span style="font-family: Arial, Helvetica, sans-serif;">在main(WinMain、tWinMain)函数之前做1个数据同享段:</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>已有这个实例在运行了;
}