For programming masters, this topic is a bit boring, but in some cases it is quite useful. As I deleted uninstall a software, the result is deleted, the service is still there, very indiscriminate, the registration form can't be found, I have to write a small program to delete the service.
First do the interface, as follows:
This is to use the Windows service management function group, first turn on the service manager, this is to include Winsvc.h in the header file.
Put
SC_HANDLE SH; Defines the join dialog box class.
Add the following code to the OnInitDialog member function to initialize service management.
SH = OPENSCMANAGER (0, Services_Active_Database, SC_Manager_All_Access);
IF (! sh)
{
MessageBox ("Faile to Open Scminager);
Return False;
}
Add to the onClose member function
ClosESERVICEHANDLE (SH);
Then process two button events
Void CDELSDLG :: ListServices ()
{
// Todo: Add Your Control Notification Handler Code Here
DWORD EH = 0, D1, NRET, I;
Bool ret;
Scv.resetContent ();
Ret = enumserviceSstatus (sh, service_win32 | service_driver,
Service_INACTIVE, ESS, SIZEOF (ESS), & D1, & NRET, & EH);
IF (! RET)
{
CHAR TEMP [32];
Sprintf (TEMP, "% D", getLastError ());
MessageBox (TEMP);
MessageBox ("Failed to Enum Services");
Return;
}
For (i = 0; i { Scv.addstring (ESS [i] .lpdisplayName); } } Void CDELSDLG :: DELSERVICE () { // Todo: Add Your Control Notification Handler Code Here INT I, RET; CHAR TEMP [256]; i = scv.getcurseel (); Sprintf (Temp, "Do you real want to remove the service / r / n" "% D: / T% S / R / N% S", I, ESS [I] .LPServiceName, ESS [i] .lpdisplayName); RET = MessageBox (Temp, "Alert!", MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2); IF (RET == iDyes) { SC_HANDLE DS; DS = OpenService (SH, ESS [I] .LPServiceName, SC_Manager_all_Access); IF (! DS) { MessageBox ("Failed to Open Service"); Return; } IF (deleteService (DS)) { MessageBox ("Success To Remove The Service"); } Else { Sprintf (Temp, "Failed to Remove The Service / R / NERROR CODE: / T% D", GetLastError ()); MessageBox (TEMP); } ClosESERVICEHANDLE (DS); } } The former enumerates unacceptable service, add it to the list box, the latter directly deletes the corresponding service