|
|
Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
|
Опции темы | Поиск в этой теме | Опции просмотра |
#1
|
|||
|
|||
[Error] Unit1.pas(32): Undeclared identifier: 'exe_running'
Сделал таймер
PHP код:
[Error] Unit1.pas(32): Undeclared identifier: 'exe_running' Что нетак сделал? или чтото надо добавить или компонент какойнить кинуть на форму? |
#2
|
||||
|
||||
Код:
exe_running('notepad.exe', false) возможно имелось ввиду это? Код:
uses ShellApi; ...ShellExecute(Handle, 'open', 'c:\Windows\notepad.exe', nil, nil, SW_SHOWNORMAL); Жизнь такова какова она есть и больше никакова. Помогаю за спасибо. |
#3
|
|||
|
|||
мне нужно так
если этот процесс запущен ***.exe то влючаются таймеры в моей программе, если процесс незапущен вылазит сообщение код взял от сюда http://articles.org.ru/cfaq/index.php?qid=1741&catid=58 не весь код брал только вот етот вставил Код:
// example 1: is a exe-file running ? procedure tform1.button1click(sender: tobject); begin if exe_running('notepad.exe', false) then showmessage('exe is running') else showmessage('exe is not running'); end; |
#4
|
||||
|
||||
Ну так и надо было копировать описание функции, а то вы выдернули только ее вызов.
Код:
function exe_running(filename: string; bfullpath: boolean): boolean; var i: integer; myproclist: tstringlist; begin myproclist := tstringlist.create; try getprocesslist(myproclist); result := false; if myproclist = nil then exit; for i := 0 to myproclist.count - 1 do begin if not bfullpath then begin if comparetext(extractfilename(myproclist.strings[i]), filename) = 0 then result := true end else if comparetext(myproclist.strings[i], filename) = 0 then result := true; if result then break; end; finally myproclist.free; end; end; Жизнь такова какова она есть и больше никакова. Помогаю за спасибо. |
#5
|
|||
|
|||
function exe_running(filename: string; bfullpath: boolean): boolean;
перед var ставить? я втыкнул и мне ошибка вылазит [Error] Unit1.pas(21): Unsatisfied forward or external declaration: 'exe_running' |
#6
|
|||
|
|||
Ктонить напишите эту штук и скиньте иходник,
ниче у меня невыходит, одни ошибки ккието |
#7
|
||||
|
||||
Надо было копировать весь код. Так как по частям он работать не будет
Код:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, psapi, tlhelp32; type TForm1 = class(TForm) Timer1: TTimer; procedure Timer1Timer(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure createwin9xprocesslist(list: tstringlist); var hsnapshot: thandle; procinfo: tprocessentry32; begin if list = nil then exit; hsnapshot := createtoolhelp32snapshot(th32cs_snapprocess, 0); if (hsnapshot <> thandle(-1)) then begin procinfo.dwsize := sizeof(procinfo); if (process32first(hsnapshot, procinfo)) then begin list.add(procinfo.szexefile); while (process32next(hsnapshot, procinfo)) do list.add(procinfo.szexefile); end; closehandle(hsnapshot); end; end; procedure createwinntprocesslist(list: tstringlist); var pidarray: array [0..1023] of dword; cb: dword; i: integer; proccount: integer; hmod: hmodule; hprocess: thandle; modulename: array [0..300] of char; begin if list = nil then exit; enumprocesses(@pidarray, sizeof(pidarray), cb); proccount := cb div sizeof(dword); for i := 0 to proccount - 1 do begin hprocess := openprocess(process_query_information or process_vm_read, false, pidarray[i]); if (hprocess <> 0) then begin enumprocessmodules(hprocess, @hmod, sizeof(hmod), cb); getmodulefilenameex(hprocess, hmod, modulename, sizeof(modulename)); list.add(modulename); closehandle(hprocess); end; end; end; procedure getprocesslist(var list: tstringlist); var ovi: tosversioninfo; begin if list = nil then exit; ovi.dwosversioninfosize := sizeof(tosversioninfo); getversionex(ovi); case ovi.dwplatformid of ver_platform_win32_windows: createwin9xprocesslist(list); ver_platform_win32_nt: createwinntprocesslist(list); end end; function exe_running(filename: string; bfullpath: boolean): boolean; var i: integer; myproclist: tstringlist; begin myproclist := tstringlist.create; try getprocesslist(myproclist); result := false; if myproclist = nil then exit; for i := 0 to myproclist.count - 1 do begin if not bfullpath then begin if comparetext(extractfilename(myproclist.strings[i]), filename) = 0 then result := true end else if comparetext(myproclist.strings[i], filename) = 0 then result := true; if result then break; end; finally myproclist.free; end; end; procedure TForm1.Timer1Timer(Sender: TObject); begin if exe_running('notepad.exe', false) then begin timer2.Enabled:=True; timer3.Enabled:=True; timer4.Enabled:=True; end else showmessage('??????? ?????????'); end; end. Помогаю за Спасибо |
#8
|
|||
|
|||
v1s2222
Спасибо огромное, очень помог |