home *** CD-ROM | disk | FTP | other *** search
- {
- WORK ONLY ON WIN2000 OR BETTER!
- This script automatically disables sharing when any specified .exe
- program is active. Usefull for lazy gamers ;).
- }
- program FreeResourcesForThis;
-
- const RefreshInterval=20;//Refresh interval, seconds
-
- function IsGameExe(exe:string):boolean;
- begin
- {
- Specify here any .exe on start of wich script should disable sharing
- Note that exe must be specified in lower case!
- }
- Result:=((exe='quake.exe') or (exe='quake2.exe') or (exe='quake3.exe') or
- (exe='rangers.exe') or (exe='hl.exe') or (exe='calc.exe'));
- end;
-
-
- type PROCESSENTRY32=record
- size:Longint;
- cntUsage:Longint;
- th32ProcessID:Longint;
- th32DefaultHeapID:Longint;
- th32ModuleID:Longint;
- cntThreads:Longint;
- th32ParentProcessID:Longint;
- pcPriClassBase:Longint;
- dwFlags:Longint;
- szExeFile:array [0..259] of char;
- end;
-
- function CreateToolhelp32Snapshot(flg,pid:longint): Longint; external 'CreateToolhelp32Snapshot@kernel32.dll stdcall';
- function Process32First(snp:Longint;var lppe:PROCESSENTRY32): Longint; external 'Process32First@kernel32.dll stdcall';
- function Process32Next(snp:Longint;var lppe:PROCESSENTRY32): Longint; external 'Process32Next@kernel32.dll stdcall';
- function CloseHandle(hObject :Longint): Longint; external 'CloseHandle@kernel32.dll stdcall';
-
- var snp:Longint;
- e,v1,v2,i,j:integer;
- pe:PROCESSENTRY32;
- s:string;
- gamecon,con:boolean;
-
- Begin
- SetTimer(RefreshInterval*1000);
- con:=false;
- repeat
- e:=WaitEvent(v1,v2);
- if e=8 then
- begin
- snp:=CreateToolhelp32Snapshot(2,0);
- if snp<>-1 then
- begin
- gamecon:=false;
- pe.size:=sizeof(pe);
- if Process32First(snp,pe)<>0 then
- begin
- repeat
- i:=0;
- while(i<260) and (pe.szExeFile[i]<>chr(0)) do i:=i+1;
- setlength(s,i);
- for j:=1 to i do s[j]:=pe.szExeFile[j-1];
- s:=LowerCase(ExtractFileName(s));
- if IsGameExe(s)then gamecon:=true;
- until Process32Next(snp,pe)=0;
- end;
- CloseHandle(snp);
- if gamecon then
- begin
- if NVWatcher.GetSharingEnabled then
- begin
- NVWatcher.SetSharingEnabled(false);
- con:=true;
- end;
- end else
- begin
- if con and (not NVWatcher.GetSharingEnabled) then
- begin
- NVWatcher.SetSharingEnabled(true);
- con:=false;
- end;
- end;
- end;
- end;
- until e=0;
- End.
-