G
Guest
Dear all,
how can I check whether a specified application is running. I tried the
following code below...but still not able to detect
private static readonly int ERROR_ALREADY_EXIST = 183;
[DllImport("coredll.dll", SetLastError=true)]
public static extern int CreateProcess(
string strImageName, string strCmdLine, IntPtr pProcessAttributes,
IntPtr pThreadAttributes , int bInheritsHandle, int dwCreationFlags,
IntPtr pEnvironment,
IntPtr pCurrentDir, Byte[] bArray, ProcessInfo oProc);
[DllImport("coredll.dll", EntryPoint="GetLastError")]
private static extern int GetLastError();
[DllImport("coredll.dll", EntryPoint="CreateMutexW")]
public static extern int CreateMutex(
IntPtr lpMutexAttributes, bool bInitialOwner, string MutexName);
if (CreateMutex(IntPtr.Zero, true, "iexplore.exe") != 0)
{
int lstErr = GetLastError();
if (lstErr == ERROR_ALREADY_EXIST)
{
return true;
}
}
return false;
I tried to put iexplore.exe or Internet Explorer, still return false
any suggestion?
how can I check whether a specified application is running. I tried the
following code below...but still not able to detect
private static readonly int ERROR_ALREADY_EXIST = 183;
[DllImport("coredll.dll", SetLastError=true)]
public static extern int CreateProcess(
string strImageName, string strCmdLine, IntPtr pProcessAttributes,
IntPtr pThreadAttributes , int bInheritsHandle, int dwCreationFlags,
IntPtr pEnvironment,
IntPtr pCurrentDir, Byte[] bArray, ProcessInfo oProc);
[DllImport("coredll.dll", EntryPoint="GetLastError")]
private static extern int GetLastError();
[DllImport("coredll.dll", EntryPoint="CreateMutexW")]
public static extern int CreateMutex(
IntPtr lpMutexAttributes, bool bInitialOwner, string MutexName);
if (CreateMutex(IntPtr.Zero, true, "iexplore.exe") != 0)
{
int lstErr = GetLastError();
if (lstErr == ERROR_ALREADY_EXIST)
{
return true;
}
}
return false;
I tried to put iexplore.exe or Internet Explorer, still return false
any suggestion?