Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 05-08-2001, 09:20 AM
n_pelov n_pelov is offline
Junior Member
 
Join Date: Apr 2001
Posts: 20
Default Help me: Processes.

I want to close any program witch is run in right click menu/open.

I'm making a PC Club program witch will run programs (Games) and close them after a time. But there are and free programs such as winamp. The problem is that in open dialog of winamp anyone can run program or delete file with right click menu. How can I diable running these programs or disable right-click popup menu.
Thank you very much!

Question by Nickolay Pelov,
e-mail: n_pelov@yahoo.com,
home page: http://nick.hit.bg
Reply With Quote
  #2  
Old 05-08-2001, 10:37 AM
Tavares Tavares is offline
Senior Member
 
Join Date: Feb 2001
Posts: 1,318
Default RE: Help me: Processes.

This unit gets all the process runing.See what you can do with it!

unit Unit1;

interface

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

type
TForm1 = class(TForm)
ProcessesListBox: TListBox;
RefreshBtn: TButton;
procedure RefreshBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

uses
TLHelp32, PsApi;

function RunningProcessesList(List: TStrings): Boolean;

function BuildListTH: Boolean;
var
SnapProcHandle: THandle;
ProcEntry: TProcessEntry32;
NextProc: Boolean;
begin
SnapProcHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if SnapProcHandle <> THandle(-1) then
begin
Result := True;
ProcEntry.dwSize := Sizeof(ProcEntry);
NextProc := Process32First(SnapProcHandle, ProcEntry);
while NextProc do
begin
List.AddObject(ProcEntry.szExeFile, Pointer(ProcEntry.th32ProcessID));
NextProc := Process32Next(SnapProcHandle, ProcEntry);
end;
CloseHandle(SnapProcHandle);
end else
Result := False;
end;

function BuildListPS: Boolean;
var
PIDs: array[0..1024] of DWORD;
Handle: THandle;
Needed: DWORD;
I: Integer;
ModuleFileName: array[0..MAX_PATH] of Char;
begin
Result := EnumProcesses(@PIDs, Sizeof(PIDs), Needed);
if not Result then Exit;
for I := 0 to (Needed div Sizeof(DWORD)) - 1 do
if PIDs[I] <> 0 then
begin
Handle := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False, PIDs[I]);
if Handle <> 0 then
begin
if GetModuleFileNameEx(Handle, 0, ModuleFileName, Sizeof(ModuleFileName)) = 0 then
List.AddObject('[System]', Pointer(INVALID_HANDLE_VALUE))
else
List.AddObject(ModuleFileName, Pointer(PIDs[I]));
CloseHandle(Handle);
end;
end;
end;

begin
Assert(Assigned(List));
List.BeginUpdate;
try
List.Clear;
if (Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion = 4) then
Result := BuildListPS
else
Result := BuildListTH;
finally
List.EndUpdate;
end;
end;

{ TForm1 }

procedure TForm1.RefreshBtnClick(Sender: TObject);
begin
RunningProcessesList(ProcessesListBox.Items);
end;

procedure TForm1.FormShow(Sender: TObject);
begin
RefreshBtnClick(nil);
end;

end.




Regards,
Eduardo Tavares
www.tavareswebsite.cjb.net
Reply With Quote
  #3  
Old 05-09-2001, 03:09 AM
PoseFant PoseFant is offline
Senior Member
 
Join Date: Jan 2001
Posts: 1,002
Default RE: Help me: Processes.

Use SetWindowsHookEx with the HWND to WinAmp.
Use SysMsgProc with MSGF_MENU to overload any functionality in the menus to WinAmp.

Remember to place the Callback Procedure in a DLL file.


Regards


/Filip
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 02:12 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.