如題。我要用tecplot.exe分別打開幾個.mcr檔案,使用 shell命令:
shell "tecplot.exe macro1.mcr"
shell "tecplot.exe macro2.mcr"
shell "tecplot.exe macro3.mcr"
命令可以打開,但會跳出來3個tecplot.exe的界面視窗,如何使后面的macro2.mcr以及macro3.mcr在被打開時使用第一個tecplot界面視窗,即始終只有一個tecplot視窗而不是多個?應該從哪方面入手來解決這個問題,使用MFC可以嗎
uj5u.com熱心網友回復:
類似于用windows視頻播放器一次只能打開一個視頻那樣的uj5u.com熱心網友回復:
windows下可以使用命名互斥體來解決只運行一個實體http://blog.163.com/hack_0xspy/blog/static/1984280252011101141319245/
uj5u.com熱心網友回復:
用一個全域mutex,每次啟動的時候,創建這個mutex,看回傳的錯誤資訊是否說已經存在,如果存在,當前行程退出uj5u.com熱心網友回復:
創建命名的內核物件~uj5u.com熱心網友回復:
在啟動的時候創建一個命名的內核物件,然后判斷這個內核物件是否創建成功,如果是創建失敗的話,那么就表示已經有一個實體啟動了uj5u.com熱心網友回復:
HANDLE hMutex = CreateMutexW(NULL,TRUE, L"mutex");
if(hMutex != NULL)
{
if(GetLastError() == ERROR_ALREADY_EXISTS)//行程互斥
{
return FALSE;
}
}
在程式初始化的時候加上面代碼
uj5u.com熱心網友回復:
// Variables shared across all instances of our application which ensure// that only one instance of this application will run at a given time.
#pragma data_seg("Shared")
static LONG g_lInstanceCount = -1;
#pragma data_seg()
#pragma data_seg(".drectve")
static char szShared[] = "-section:Shared,rws";
#pragma data_seg()
//////////////////////////////////////////////////////////////////////////////////
if (InterlockedIncrement(&g_lInstanceCount) > 0)
{
InterlockedDecrement(&g_lInstanceCount);
MessageBox(NULL, __TEXT("Display Resolution is already running"),
g_szAppName, MB_ICONINFORMATION | MB_OK);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/133329.html
標籤:進程/線程/DLL
上一篇:開發lsp要如何對其進行除錯?
下一篇:請教編程思路
