控制进程数量解决方法

控制进程数量
公司的VFP系统,有些部分数据处理量比较大,并发超过1W,然后有人又开很多客户端一起处理。导致有时数据库堵塞。
现在想用C++来做个DLL,控制VFP系统的进程数。让一台电脑只能打开2个客户端。
目前手上只有查找进程是否正在运行的C++代码,后面就完全没了想法。不知道大家是否知道如何控制同一个进程的数量。
现在想做的就是知道进程名字,控制它只能运行两个。就像给QQ加上控制,让一台机子只能登陆两个一样。

------解决方案--------------------
vfp 自己也能解决

C/C++ code
Declare integer CreateToolhelp32Snapshot in win32api integer,integer
Declare integer Process32First in win32api integer,string @
Declare integer Process32Next in win32api integer,string @
Declare integer CloseHandle in win32api integer
CLEAR
lnHand = 0
lnHand = CreateToolhelp32Snapshot(3,0)
If lnHand>0
lctitle=SPACE(256)
If Process32First(lnHand,@lctitle) > 0
    tln = 0
    Do while Process32Next(lnHand,@lctitle)> 0
        m.lnval=SUBSTR(lctitle,37,256)
        m.lnval=left(m.lnval,AT(CHR(0),m.lnval) - 1)
        If Lower(m.lnval) == 'additional.exe'
            tln = tln + 1
            If tln == 3
                Exit
            Endif 
        Endif 
    Enddo
    If tln == 3
        Messagebox("已经运行了两个程序",4096,"Message")
        CloseHandle(lnHand)
        Clear Dlls 
        Clear Events 
        Quit
    Endif 
ENDIF
  CloseHandle(lnHand)
Endif