WINCEではプログラムの実行を1つのインスタンスのみ許可しています


.NET CF:
[DllImport("coredll.Dll")] 
private static extern int GetLastError(); 

[DllImport("coredll.Dll")] 
private static extern int ReleaseMutex(IntPtr hMutex); 

[DllImport("coredll.Dll")] 
private static extern IntPtr CreateMutex(SECURITY_ATTRIBUTES lpMutexAttributes,
                                         bool bInitialOwner,
                                         string lpName); 

[StructLayout( LayoutKind.Sequential)] 
public class SECURITY_ATTRIBUTES 
{ 
  public int nLength; 
  public int lpSecurityDescriptor; 
  public int bInheritHandle; 
} 
const int ERROR_ALREADY_EXISTS = 0183; 
static void Main() 
{   
    #region Api_Call CreateMutex; 
    IntPtr hMutex; 
    hMutex=CreateMutex(null,false," "); 
    if (GetLastError()!=ERROR_ALREADY_EXISTS) 
    { 
        Application.Run(new Frmmenu()); 
    } 
    else 
    { 
        MessageBox.Show(" "); 
        ReleaseMutex(hMutex); 
    } 
    #endregion 
}
EVC:
    HANDLE   hMutex=::CreateMutex(NULL,TRUE,L"LiCR");  
    if(hMutex!=NULL)   
    {   
        if(GetLastError()==ERROR_ALREADY_EXISTS)   
        { 
            AfxMessageBox( " ." );    
            ReleaseMutex(hMutex);
            return  FALSE;   
        }   
    }