您的位置:程序门 -> delphi -> windows sdk/api



如果结束重复运行的程序


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


如果结束重复运行的程序
发表于:2008-01-22 16:07:18 楼主
系统环境为windows   2000   server   终端服务器(即有多个用户同时登录到服务器上运行erp程序),我想控制每个用户登录到windows   2000   server   终端服务器后同一时刻(只是当前用户,其它用户不算)只能开启一个erp程序,假设进程的映像名称为erp2.exe,即如果当前用户已经运行了erp2.exe,第二次运行的erp2.exe将会kill掉.请问delphi如何实现??
发表于:2008-01-22 16:11:241楼 得分:0
注:erp2.exe   是用pb6.5写的
发表于:2008-01-23 16:33:262楼 得分:0
mutexhandle:   thandle;   //定义互斥句柄

          mutexhandle   :=   createmutex(nil,   true,   application.title);
        if   mutexhandle   <>   0   then
        begin
                if   getlasterror   =   error_already_exists   then
                begin
                        messagebox(0,   '程序已经运行...',   '不好意思',   mb_iconhand);
                        closehandle(mutexhandle);
                        halt;   //   initiates   abnormal   termination   of   a   program.
                end;
        end;
发表于:2008-01-23 16:38:183楼 得分:0
将erp2.exe改名为erp2.bin,然后自己再新建一个erp2.exe,这样子先启动的就是你的程序,然后你再createprocess调erp2.exe,如此你便想如何控制都可以。


快速检索

最新资讯
热门点击