I need to run more then 1 instance of the same program but also I need to
know which instance is running.
In C++ code was:
int nInstance = 0;
char szAppName[32];
m_dwMutexReturn = ERROR_ALREADY_E XISTS;
while (( m_dwMutexReturn == ERROR_ALREADY_E XISTS ) && ( nInstance <
MAXINSTANCES ))
{
nInstance++;
itoa( nInstance, szTemp, 10 );
strcpy( szAppName, "ProductEng ine" );
strcat( szAppName, szTemp );
m_hMutex = CreateMutex( NULL, TRUE, szAppName );
m_dwMutexReturn = GetLastError();
}
if ( nInstance == MAXINSTANCES )
m_sState->nInstance = 1;
else
m_sState->nInstance = nInstance;
but I can't port this code to C#.
Somebody knows how to do it?
know which instance is running.
In C++ code was:
int nInstance = 0;
char szAppName[32];
m_dwMutexReturn = ERROR_ALREADY_E XISTS;
while (( m_dwMutexReturn == ERROR_ALREADY_E XISTS ) && ( nInstance <
MAXINSTANCES ))
{
nInstance++;
itoa( nInstance, szTemp, 10 );
strcpy( szAppName, "ProductEng ine" );
strcat( szAppName, szTemp );
m_hMutex = CreateMutex( NULL, TRUE, szAppName );
m_dwMutexReturn = GetLastError();
}
if ( nInstance == MAXINSTANCES )
m_sState->nInstance = 1;
else
m_sState->nInstance = nInstance;
but I can't port this code to C#.
Somebody knows how to do it?
Comment