为什么会这样呢,最开始时是好使的
后来我加了一个POp菜单,又加了一个TCoolTrayIcon,就不行了
把菜单和TCoolTrayIcon删除也不行

解决方案 »

  1.   

    把这个问题和
    http://www.csdn.net/Expert/TopicView1.asp?id=811701
    综合到一起
    procedure TRunMyApp.ServiceExecute(Sender: TService);
    var Timer,i:Integer;
        lppe: TProcessEntry32;
        found,runing : boolean;
        Hand : THandle;
        aList:TStringList;
        execnames:String;
    begin
        Timer:=3000;
        execnames:='NOTEPAD.EXE';
        while true do begin
            aList:=TStringList.Create;
            aList.Clear;
            Hand := CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
            found := Process32First(Hand,lppe);
            while found do begin
                aList.Add(StrPas(lppe.szExeFile));
                found := Process32Next(Hand,lppe);
            end;
            runing:=false;
            for i:=0 to aList.Count-1 do begin
                if UpperCase(aList.Strings[i])=execnames then
                    runing:=true;
            end;
            if not runing then
                winexec('c:\WINNT\NOTEPAD.exe',SW_SHOWNORMAL);
            sleep(Timer);
        end;
    end;
    谁能告诉我怎么回事!!!
    在服务里NOTEPAD.exe运行了,可是是在后台,只能看到进程,看不到窗口
      

  2.   

    nt和2k不支持ToolHelp32了。要用PSAPI.DLL,它包含在psapi.pas中。
    使用P S A P I获取进程信息,首先要调用E n u m P r o c e s s e s ( )函数,其声明如下:
    FUNCTION ENUMPROCESS(LPIDPROCESS:LPDWORD;CB:DWORD;VAR CBNEEDED:DWORD):BOOL;
    • lpidProcess是一个指向D W O R D数组的指针,由函数用进程I D填充。
    • cb包含由l p i d P r o c e s s指定的数组的元素数。
    • c b N e e d e d返回拷贝到l p i d P r o c e s s数组的实际字节数。用此值除以S i z e O f ( D W O R D )将得到拷贝到
    数组的元素数,即正在运行的进程数。
    调用这个函数后, l p i d P r o c e s s指定的数组将包含一些进程的I D。进程I D在自身进程中无用,但可
    以传递给OpenProcess() API函数以获取进程的句柄。
    这是书上的说明,源代码太长就不贴不。
      

  3.   

    Tool Help
    Process status API
    Performance Data Help
      

  4.   

    大家先帮我看一下,如何在服务里能显示窗口程序就象上面的notepad.exe
    我在大富翁问了,那边说服务就是这样的,能不能有什么折中的办法
      

  5.   

    cszk4兄,告诉我在哪本书上看到的,我找一下
    EnumProcesses我没找到详细点的说明最好麻烦你把源程序贴给我