Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2007.01.07;
Скачать: CL | DM;

Вниз

Определить директорию запускаемого файла   Найти похожие ветки 

 
Windows ©   (2006-11-15 20:45) [0]

Как программе определить директорию каждого запускаемого пользователем файла в системе?


 
Rouse_ ©   (2006-11-15 21:31) [1]

ммм. ExtractFilePath вестимо. Вопрос в другом, а как ты определишь наличие > каждого запускаемого пользователем файла в системе


 
KilkennyCat ©   (2006-11-15 23:09) [2]

> [1] Rouse_ ©   (15.11.06 21:31)

микрофоном отслеживать дабл-клик мышки?


 
Германн ©   (2006-11-16 00:28) [3]


> Вопрос в другом, а как ты определишь наличие > каждого запускаемого
> пользователем файла в системе

Так он же Windows. Ему и карты в руки :-)


 
Windows ©   (2006-11-16 15:28) [4]

Rouse_ ©   (15.11.06 21:31) [1]
Вот и я не знаю, поэтому и спрашиваю, может можно как нибудь отслеживат запуск файлов, ну скажем *.ехе...

Германн ©   (16.11.06 00:28) [3]
Не люблю, когда люди попусту тратят свое время, к тому же, тратя время других понапрасну...
ничего не можете сказать по данному вопросу, зачем вообще влезать в дискуссию?


 
Плохиш ©   (2006-11-16 15:38) [5]

А я знаю, надо хук поставить. Вот! :-)


 
Array ©   (2006-11-16 15:42) [6]

Вам отслеживать запускаемые процесы, проверять пути к файлу и если exe то вуаля...


> Не люблю, когда люди попусту тратят свое время

А чем же мытут занимаемся, как не тратим свое время, отвечая на ВАШИ вапросы, включая сваи телепатические шлёмы шобы понять , а шо ВЫ на самом деле хотели спросить и т.д.

З,Ы, сори, но наболело....


 
Elen ©   (2006-11-16 15:51) [7]


> Windows

Некоторые кстати используют FindFistr...FindNext для получения всего имени


 
Игорь Шевченко ©   (2006-11-16 15:51) [8]

Windows ©   (16.11.06 15:28) [4]


> Вот и я не знаю, поэтому и спрашиваю, может можно как нибудь
> отслеживат запуск файлов, ну скажем *.ехе...


С помощью указания отладчика в реестре, например.
В HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options
Отладчиком может быть твоя программа.


> Не люблю, когда люди попусту тратят свое время, к тому же,
>  тратя время других понапрасну...
> ничего не можете сказать по данному вопросу, зачем вообще
> влезать в дискуссию?


Терпи. Тебя сюда тоже не звали.


 
Elen ©   (2006-11-16 16:24) [9]


> Windows

Вот Из Delphi world Forever :

unit Unit1;

interface

uses        tlhelp32,     psapi,
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls;

type
 TForm1 = class(TForm)
   ListBox1: TListBox;
   procedure FormCreate(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}
 function RunningProcessesList(List: TStrings; FullPath: Boolean): Boolean;
   function IsWinXP: Boolean;
begin
  Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and
    (Win32MajorVersion = 5) and (Win32MinorVersion = 1);
end;

function IsWin2k: Boolean;
begin
  Result := (Win32MajorVersion >= 5) and
    (Win32Platform = VER_PLATFORM_WIN32_NT);
end;

function IsWinNT4: Boolean;
begin
  Result := Win32Platform = VER_PLATFORM_WIN32_NT;
  Result := Result and (Win32MajorVersion = 4);
end;

function IsWin3X: Boolean;
begin
  Result := Win32Platform = VER_PLATFORM_WIN32_NT;
  Result := Result and (Win32MajorVersion = 3) and
    ((Win32MinorVersion = 1) or (Win32MinorVersion = 5) or
    (Win32MinorVersion = 51));
end;

  function ProcessFileName(PID: DWORD): string;
  var
    Handle: THandle;
  begin
    Result := "";
    Handle := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False, PID);
    if Handle <> 0 then
      try
        SetLength(Result, MAX_PATH);
        if FullPath then
        begin
          if GetModuleFileNameEx(Handle, 0, PChar(Result), MAX_PATH) > 0 then
            SetLength(Result, StrLen(PChar(Result)))
          else
            Result := "";
        end
        else
        begin
          if GetModuleBaseNameA(Handle, 0, PChar(Result), MAX_PATH) > 0 then
            SetLength(Result, StrLen(PChar(Result)))
          else
            Result := "";
        end;
      finally
        CloseHandle(Handle);
      end;
  end;

  function BuildListTH: Boolean;
  var
    SnapProcHandle: THandle;
    ProcEntry: TProcessEntry32;
    NextProc: Boolean;
    FileName: string;
  begin
    SnapProcHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    Result := (SnapProcHandle <> INVALID_HANDLE_VALUE);
    if Result then
      try
        ProcEntry.dwSize := SizeOf(ProcEntry);
        NextProc := Process32First(SnapProcHandle, ProcEntry);
        while NextProc do
        begin
          if ProcEntry.th32ProcessID = 0 then
          begin
            // PID 0 is always the "System Idle Process" but this name cannot be
           // retrieved from the system and has to be fabricated.
           FileName := "RsSystemIdleProcess";
          end
          else
          begin
            if IsWin2k or IsWinXP then
            begin
              FileName := ProcessFileName(ProcEntry.th32ProcessID);
              if FileName = "" then
                FileName := ProcEntry.szExeFile;
            end
            else
            begin
              FileName := ProcEntry.szExeFile;
              if not FullPath then
                FileName := ExtractFileName(FileName);
            end;
          end;
          List.AddObject(FileName, Pointer(ProcEntry.th32ProcessID));
          NextProc := Process32Next(SnapProcHandle, ProcEntry);
        end;
      finally
        CloseHandle(SnapProcHandle);
      end;
  end;

  function BuildListPS: Boolean;
  var
    PIDs: array [0..1024] of DWORD;
    Needed: DWORD;
    I: Integer;
    FileName: string;
  begin
    Result := EnumProcesses(@PIDs, SizeOf(PIDs), Needed);
    if Result then
    begin
      for I := 0 to (Needed div SizeOf(DWORD)) - 1 do
      begin
        case PIDs[I] of
          0:
            // PID 0 is always the "System Idle Process" but this name cannot be
           // retrieved from the system and has to be fabricated.
           FileName := "RsSystemIdleProcess";
          2:
            // On NT 4 PID 2 is the "System Process" but this name cannot be
           // retrieved from the system and has to be fabricated.
           if IsWinNT4 then
              FileName := "RsSystemProcess"
            else
              FileName := ProcessFileName(PIDs[I]);
            8:
            // On Win2K PID 8 is the "System Process" but this name cannot be
           // retrieved from the system and has to be fabricated.
           if IsWin2k or IsWinXP then
              FileName := "RsSystemProcess"
            else
              FileName := ProcessFileName(PIDs[I]);
            else
              FileName := ProcessFileName(PIDs[I]);
        end;
        if FileName <> "" then
          List.AddObject(FileName, Pointer(PIDs[I]));
      end;
    end;
  end;
begin
  if IsWin3X or IsWinNT4 then
    Result := BuildListPS
  else
    Result := BuildListTH;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  RunningProcessesList(ListBox1.Items, true);
end;

end.


Разбирайся...


 
BiN ©   (2006-11-16 16:31) [10]


> Игорь Шевченко ©   (16.11.06 15:51) [8]

Для "каждого запускаемого пользователем файла" у него будет слишком много экземпляров деббугера - csrss загнется.


 
Windows ©   (2006-11-17 18:41) [11]

Ну с ехе все понятно, а если файл типа тхт, его уже открывает блокнот по умолчанию, следовательно директория будет не та.


> А чем же мытут занимаемся, как не тратим свое время, отвечая
> на ВАШИ вапросы, включая сваи телепатические шлёмы шобы
> понять , а шо ВЫ на самом деле хотели спросить и т.д.
>
> З,Ы, сори, но наболело.

Интересно, что значит тогда вот это
"Так он же Windows. Ему и карты в руки :-)"
Ответы на НАШИ вопросы в таком стиле?:/



Страницы: 1 вся ветка

Текущий архив: 2007.01.07;
Скачать: CL | DM;

Наверх




Память: 0.51 MB
Время: 0.042 c
15-1166426041
data
2006-12-18 10:14
2007.01.07
Еще одна спортивная ветка)


15-1166080755
vidiv
2006-12-14 10:19
2007.01.07
Помогите решить задачу по страхованию...


1-1163691741
gpaul
2006-11-16 18:42
2007.01.07
Изменить размер Canvas компонента Image


15-1166210554
TUser
2006-12-15 22:22
2007.01.07
gmail-странно


15-1166356164
vitv
2006-12-17 14:49
2007.01.07
Вопрос по "промежуточному коду" .NET