WinCe에서 어플리케이션을 하나만 켜는 방법
9893 단어 WinCE
namespace MyNameSpace
{
static class Program
{
[DllImport("Toolhelp.dll")]
public static extern IntPtr CreateToolhelp32Snapshot(uint flags, uint processid);
[DllImport("Toolhelp.dll")]
public static extern int Process32First(IntPtr handle, ref PROCESSENTRY32 pe);
[DllImport("Toolhelp.dll")]
public static extern int Process32Next(IntPtr handle, ref PROCESSENTRY32 pe);
/// <summary>
/// 。
/// </summary>
[MTAThread]
static void Main()
{
IntPtr handle = CreateToolhelp32Snapshot((uint)SnapShotFlags.TH32CS_SNAPPROCESS, 0);
int count = 0;
if ((int)handle != -1)
{
PROCESSENTRY32 pe32 = new PROCESSENTRY32();
pe32.dwSize = (uint)Marshal.SizeOf(typeof(PROCESSENTRY32));
int bMore = Process32First(handle, ref pe32);
while (bMore == 1)
{
if (pe32.szExeFile == " ")
count++;
bMore = Process32Next(handle, ref pe32);
}
}
if (count > 1)
{
MessageBox.Show(" !");
return;
}
else
Application.Run(new FrmLogin());
}
}
[StructLayout(LayoutKind.Sequential)]
public struct PROCESSENTRY32
{
public uint dwSize;
public uint cntUsage;
public uint th32ProcessID;
public IntPtr th32DefaultHeapID;
public uint th32ModuleID;
public uint cntThreads;
public uint th32ParentProcessID;
public int pcPriClassBase;
public uint dwFlags;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]// ,
public string szExeFile;
public uint th32MemoryBase;
public uint th32AccessKey;
}
public enum SnapShotFlags : uint
{
TH32CS_SNAPHEAPLIST = 0x00000001,
TH32CS_SNAPPROCESS = 0x00000002,
TH32CS_SNAPTHREAD = 0x00000004,
TH32CS_SNAPMODULE = 0x00000008,
TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD | TH32CS_SNAPMODULE),
TH32CS_GETALLMODS = 0x80000000
}
}
방법2:
타사 라이브러리 사용:
OpenNETCF
공식 홈페이지: http://www.opennetcf.com
using OpenNETCF.Threading;
namespace MyNameSpace
{
static class Program
{
/// <summary>
/// 。
/// </summary>
[MTAThread]
static void Main()
{
bool firstInstance;
OpenNETCF.Threading.NamedMutex mutex = new OpenNETCF.Threading.NamedMutex(false, " ", out firstInstance);
if (!firstInstance)
{
MessageBox.Show(" ");
return;
}
Application.Run(new FrmLogin());
GC.KeepAlive(mutex);
}
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
wince에 관한 몇 가지 작은 문제나는 나의 360 백신 프로그램을 종료하고 오류가 사라졌다.왜냐하면 나는 정말 조금도 생각이 나지 않는다. 3 개발판 시스템이 시작되고 USB가 컴퓨터에 인식되지 않아 activeSync가 시작되지 않습니다. 우선:...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.