[ _v!rus_ @ 13.03.2005. 19:48 ] @
Ima li neko ideju kako mogu da disable-ujem odredjeni device u sistemu
(eq. u Control Panel->DeviceManager->NekiDevice->BtnDisable) ?

Treba da programski onemogucim pristup mreznoj karti i eventualnom kablovskom modemu u zavisnosti od tamo nekih parametara mog programa.
[ vlaiv @ 13.03.2005. 22:35 ] @
Pogledaj MSDN pod:

Windows base services\device management ...


Tamo ima razno raznih funkcija za listanje device-ova razlicite klase, dobijanje interface-a od datih device-a i sl ... mozda postoji neki Interface koji ima date funkcije ... (nisam detaljno gledao)
[ vlaiv @ 13.03.2005. 22:38 ] @
Pogledaj SetupDiChangeState ....


Citat:

To enable/disable a device in the current hardware profile, set the DICS_FLAG_CONFIGSPECIFIC flag in the SP_PROPCHANGE_PARAMS. To enable/disable a device globally, such as in both the docked and undocked hardware profiles, set the DICS_FLAG_GLOBAL flag.

This function does the following:

DICS_ENABLE
Loads the drivers for the device and starts the device, if possible. If the function is not able to start the device, it sets the DI_NEEDREBOOT flag for the device which indicates to the initiator of the property change request that they must prompt the user to reboot the machine.
DICS_DISABLE
Disables the device. If the device is disableable but this function cannot disable the device dynamically, this function marks the device to be disabled the next time the machine reboots.
DICS_PROPCHANGE
Removes and reconfigures the device so the new properties can take effect. This flag typically indicates that a user has changed a property on a Device Manager property page for the device. The PnP Manager directs the drivers for the device to remove their device objects and then the PnP Manager reconfigures and restarts the device.
[ _v!rus_ @ 13.03.2005. 23:18 ] @
Hvala puno, pogledacu samo da nadjem MSDN, imam na VS6 diskovima, samo se bojim da je mnogo mator.

Mozda ima i drugi nacin programskog onemogucavanja mreze (npr. stopiranjem nekog od kljucnih WinNT servisa za pristup mrezama) ali ni to ne znam kako.

Btw. idealan slucaj sam imao koriscenjem programa WinGate (ruterski program), tu prepravkom samo jednog flaga u registry-u MOMENTALNO se onemogucava internet, samo ovo nije situacija za WinGate...
[ sasas @ 14.03.2005. 09:07 ] @
Za stopiranje servisa možeš koristiti nešto ovako:

Code:

uses ...WinSvc...
.
.
.
var
  ch: array[0..512] of char;
  w: cardinal;
  manager, service: SC_Handle;
  status: SERVICE_STATUS;
begin
  w := sizeof(ch);
  GetComputerName(ch, w);

  manager := OpenSCManager(ch, nil, SC_MANAGER_ALL_ACCESS);
  service := OpenService(manager, PChar('Themes'), SERVICE_ALL_ACCESS);
  if ControlService(service, SERVICE_CONTROL_STOP, status) then 
    ShowMessage('Zaustavio servis');
end;


Ovaj kood zaustavlja servis 'Themes', umesto toga staviš ime nekog mrežnog servisa (ime koje vidiš u spisku servisa je 'Display name', pravo ime servisa vidiš kad otvoriš 'properities' servisa).

Malecka napomena: moguće je da i neki DB servisi (verovatno i neki drugi) koriste mrežne interfejse (zavisi kako se i šta koristi) pa treba biti oprezan sa isključivanjem mrežnih servisa.

A ako se ipak odlučiš za čačkanje po drajverima, srećno (you're gonna need it...)

ss.
[ _v!rus_ @ 14.03.2005. 10:50 ] @
Tnx, radi, samo da proverim radi li i sa non-admin korisnicima.

Citat:
A ako se ipak odlučiš za čačkanje po drajverima, srećno (you're gonna need it...)

I ja bih to izbegao, ali npr. program ProgDVB (za digit. sat. TV) ima opcije Start/Stop device koji upravo radi ono sto meni treba (+ sto sat kartica se registruje kao mrezna kartica...)
[ Brkic @ 17.08.2007. 23:27 ] @
sasas tvoj primer funcionise OK e sada ima jedno pitanje...

probao sam nesto da izmenim tvoj kod ali mi nije uspelo,
moze li se menjati "startup type" da se stavi na disable,manual,automatic ??