CSingleInstance是一个 C++ 类,旨在帮助高级计算机用户(如程序员或软件开发人员)将他们的应用程序变成单个实例,这可能是一个棘手的过程,因为最近一些本地组件已被删除,而其他一些组件最近已被引入。
Win32 可能难以从目标应用程序中创建单个实例,因为 hPrevInstance 参数已从 WinMain 中删除,同时引入了单独的地址空间。
CSingleInstance尽管 Internet 有许多方法可供用户使用以将其应用程序限制为单个实例,但在线发布的一些代码需要对 MFC(Microsoft Foundation Classes 的简称)有深入的了解和操作。
CSingleInstance由于 Win32 环境,其他使用 FindWindowEx 或 FindWindow 的类似方法不能保证产生预期的效果。因此,CSingleInstance 可能意味着无论何时尝试从程序中创建单个实例,都要保持安全。
此 C++ 类包含一个 MMF(内存映射文件),其中包含目标应用程序主窗口的句柄。每当执行目标应用程序的第二个实例时,就会检测到 MMF 的存在,检索窗口句柄并重新激活旧窗口。
CSingleInstance is a C++ class that was designed to help advanced computer users such as programmers or software developers make their applications into single instances, which can be a tricky process since lately some native components have been removed while others have been recently introduced.
Win32 can make it difficult to create single instances out of target applications since the hPrevInstance parameter has been removed from WinMain while separate address spaces have been introduced.